@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #f5f7f4;
    --bg-card: rgba(255, 255, 255, 0.78);
    --bg-sidebar: #ebefe9;
    --border-color: rgba(120, 140, 100, 0.18);
    --border-hover: rgba(120, 140, 100, 0.35);
    
    --color-text-main: #1d2218;
    --color-text-muted: #5e6656;
    
    --accent-green: #15803d;
    --accent-green-glow: rgba(21, 128, 61, 0.15);
    --accent-orange: #ea580c;
    --accent-orange-glow: rgba(234, 88, 12, 0.15);
    --accent-blue: #1d4ed8;
    --accent-blue-glow: rgba(29, 78, 216, 0.15);
    --accent-red: #b91c1c;
    --accent-red-glow: rgba(185, 28, 28, 0.15);
    --accent-yellow: #a16207;
    --accent-yellow-glow: rgba(161, 98, 7, 0.15);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --card-shadow: 0 8px 32px 0 rgba(120, 140, 100, 0.06), 0 2px 8px 0 rgba(0, 0, 0, 0.02);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--color-text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(120, 140, 100, 0.25);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 140, 100, 0.45);
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo-container {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 10px rgba(21, 128, 61, 0.1);
}

.logo-container h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #1d2218, #5e6656);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-container .tag {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(21, 128, 61, 0.08);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    border-radius: 4px;
    font-weight: 600;
}

.nav-links {
    list-style: none;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.nav-links a:hover, .nav-links li.active a {
    color: var(--color-text-main);
    background: rgba(120, 140, 100, 0.06);
    border-color: rgba(120, 140, 100, 0.1);
}

.nav-links li.active a {
    border-color: var(--border-color);
    background: rgba(120, 140, 100, 0.1);
}

.nav-links a svg {
    width: 20px;
    height: 20px;
    transition: var(--transition-fast);
}

.nav-links li.active a svg, .nav-links a:hover svg {
    transform: scale(1.05);
}

/* Simulation Selector in Sidebar */
.simulation-panel {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.02);
}

.simulation-panel h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.simulation-select {
    width: 100%;
    background: #fbfcfb;
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
    padding: 10px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.simulation-select:hover {
    border-color: var(--border-hover);
}

/* Main Content Area */
.main-content {
    margin-left: 280px;
    padding: 40px;
    flex-grow: 1;
    min-height: 100vh;
    padding-right: 460px; /* Space for AI Drawer */
    transition: var(--transition-normal);
}

/* Scenario Notification Banner */
.scenario-banner {
    padding: 16px 24px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid transparent;
    animation: fadeIn 0.4s ease;
}

.scenario-banner.default {
    background: rgba(21, 128, 61, 0.06);
    border-color: rgba(21, 128, 61, 0.15);
    color: var(--accent-green);
}

.scenario-banner.demand_surge {
    background: rgba(234, 88, 12, 0.06);
    border-color: rgba(234, 88, 12, 0.15);
    color: var(--accent-orange);
}

.scenario-banner.supply_bottleneck {
    background: rgba(185, 28, 28, 0.06);
    border-color: rgba(185, 28, 28, 0.15);
    color: var(--accent-red);
}

.scenario-banner.quality_warning {
    background: rgba(161, 98, 7, 0.06);
    border-color: rgba(161, 98, 7, 0.15);
    color: var(--accent-yellow);
}

.scenario-banner h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.scenario-banner p {
    font-size: 14px;
    opacity: 0.9;
}

/* Layout Grid / Cards */
.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-header p {
    color: var(--color-text-muted);
    font-size: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(120, 140, 100, 0.1), 0 4px 12px 0 rgba(0, 0, 0, 0.02);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Key Metrics Cards */
.metric-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.metric-unit {
    font-size: 16px;
    color: var(--color-text-muted);
    font-weight: 400;
}

.metric-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.trend-up { color: var(--accent-green); }
.trend-down { color: var(--accent-red); }

/* Alert Feed Widget */
.alert-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    font-size: 14px;
}

.alert-item.danger { border-left-color: var(--accent-red); }
.alert-item.warning { border-left-color: var(--accent-yellow); }
.alert-item.info { border-left-color: var(--accent-blue); }

.alert-item-content {
    flex-grow: 1;
}

.alert-item-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text-main);
}

.alert-item-desc {
    color: var(--color-text-muted);
    line-height: 1.4;
}

.alert-item-time {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 6px;
}

/* To-Do List Widget */
.todo-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
}

.todo-item.urgent {
    border-left: 3px solid var(--accent-red);
}

.todo-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
    cursor: pointer;
}

.todo-item.done span {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

/* Tables Styling */
.table-container {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

th, td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(120, 140, 100, 0.04);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.badge.success { background: rgba(21, 128, 61, 0.08); color: var(--accent-green); border: 1px solid rgba(21, 128, 61, 0.15); }
.badge.warning { background: rgba(161, 98, 7, 0.08); color: var(--accent-yellow); border: 1px solid rgba(161, 98, 7, 0.15); }
.badge.danger { background: rgba(185, 28, 28, 0.08); color: var(--accent-red); border: 1px solid rgba(185, 28, 28, 0.15); }
.badge.info { background: rgba(29, 78, 216, 0.08); color: var(--accent-blue); border: 1px solid rgba(29, 78, 216, 0.15); }

/* SVG Charts & Visuals */
.chart-container {
    height: 240px;
    position: relative;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding-top: 20px;
}

.bar-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 8px;
}

.bar {
    width: 100%;
    background: linear-gradient(to top, rgba(120, 140, 100, 0.2), rgba(120, 140, 100, 0.6));
    border-radius: 6px 6px 0 0;
    transition: height 0.5s ease-out;
    position: relative;
}

.bar:hover {
    filter: brightness(0.9);
}

.bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-main);
}

.bar-label {
    font-size: 12px;
    color: var(--color-text-muted);
}

.bar.belana { background: linear-gradient(to top, rgba(21, 128, 61, 0.15), var(--accent-green)); }
.bar.gala { background: linear-gradient(to top, rgba(234, 88, 12, 0.15), var(--accent-orange)); }
.bar.agria { background: linear-gradient(to top, rgba(29, 78, 216, 0.15), var(--accent-blue)); }
.bar.queen { background: linear-gradient(to top, rgba(161, 98, 7, 0.15), var(--accent-yellow)); }

/* Map Widget */
.map-widget {
    background: radial-gradient(circle at center, #edf1eb 0%, var(--bg-card) 100%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    height: 240px;
    position: relative;
    overflow: hidden;
}

.map-label {
    position: absolute;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-main);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.map-label::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
}

.map-label.nord { top: 20%; left: 45%; }
.map-label.ost { top: 40%; left: 70%; }
.map-label.sued { top: 75%; left: 55%; }
.map-label.west { top: 50%; left: 25%; }

.map-label.alert::before {
    background: var(--accent-red);
    animation: pulse 1.2s infinite;
}

/* Packbetrieb Line load meters */
.line-load-widget {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.line-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.line-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.line-meta {
    font-size: 12px;
    color: var(--color-text-muted);
}

.progress-bar-container {
    height: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}

.progress-bar-fill.optimal { background: var(--accent-green); }
.progress-bar-fill.underloaded { background: var(--accent-blue); }
.progress-bar-fill.overloaded { background: var(--accent-red); }
.progress-bar-fill.maintenance { background: var(--color-text-muted); }

/* AI Assistant Floating Panel */
.ai-drawer {
    width: 420px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    position: fixed;
    right: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.03);
}

.ai-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-header svg {
    width: 28px;
    height: 28px;
    color: var(--accent-orange);
}

.ai-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.ai-header p {
    font-size: 12px;
    color: var(--color-text-muted);
}

.ai-chat-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* AI Thinking Trace block */
.thinking-trace {
    background: rgba(255, 255, 255, 0.6);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    padding: 14px;
    font-family: monospace;
    font-size: 11px;
    color: #c2410c;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.thinking-step {
    display: flex;
    gap: 8px;
}

.thinking-step::before {
    content: '➔';
}

/* Chat Messages */
.chat-message {
    padding: 14px 18px;
    border-radius: 14px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.ai {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.chat-message.ai h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.chat-message.ai ul, .chat-message.ai ol {
    margin-left: 18px;
    margin-top: 8px;
}

.chat-message.user {
    background: var(--accent-green);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(21, 128, 61, 0.15);
}

.action-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.btn-action {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-action.btn-success { background: var(--accent-green); color: #fff; }
.btn-action.btn-success:hover { background: #166534; }
.btn-action.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-action.btn-primary:hover { background: #1e40af; }
.btn-action.btn-warning { background: var(--accent-orange); color: #fff; }
.btn-action.btn-warning:hover { background: #c2410c; }
.btn-action.btn-danger { background: var(--accent-red); color: #fff; }
.btn-action.btn-danger:hover { background: #991b1b; }

.ai-chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.02);
}

.ai-chat-form {
    display: flex;
    gap: 10px;
}

.ai-chat-input {
    flex-grow: 1;
    background: #fbfcfb;
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
    padding: 12px 16px;
    border-radius: 8px;
    outline: none;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}

.ai-chat-input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 10px rgba(234, 88, 12, 0.15);
}

.ai-chat-submit {
    background: var(--accent-orange);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-fast);
}

.ai-chat-submit:hover {
    background: #c2410c;
}

.quick-questions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.quick-question-btn {
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 2px 6px rgba(0,0,0,0.01);
}

.quick-question-btn:hover {
    color: var(--color-text-main);
    border-color: var(--border-hover);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(185, 28, 28, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); }
}

/* Responsive Overrides */
@media(max-width: 1400px) {
    .main-content {
        padding-right: 40px; /* AI Drawer becomes relative/toggled? */
    }
}
@media(max-width: 992px) {
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { width: 80px; }
    .sidebar h1, .sidebar span.tag, .sidebar select { display: none; }
    .main-content { margin-left: 80px; }
}
