/* ============================================
   Berry Theme Overrides for MudBlazor v8
   Matching Python SAP Analyzer webapp style
   ============================================ */

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Force Roboto everywhere + fix MudBlazor letter-spacing */
:root {
    --mud-typography-default-family: 'Roboto', sans-serif !important;
    --mud-typography-default-size: 16px !important;
    --mud-typography-default-letterspacing: normal !important;
}

html, body, *, *::before, *::after {
    font-family: 'Roboto', sans-serif !important;
    letter-spacing: normal !important;
}

/* Body base size matching Python webapp */
body {
    font-size: 16px !important;
    line-height: 1.5 !important;
}

/* MudBlazor typography overrides to match Python sizes */
.mud-typography-h1 { font-size: 2.25rem !important; } /* 36px */
.mud-typography-h2 { font-size: 1.5rem !important; }  /* 24px */
.mud-typography-h3 { font-size: 1.25rem !important; } /* 20px */
.mud-typography-h4 { font-size: 1.125rem !important; } /* 18px */
.mud-typography-h5 { font-size: 1rem !important; }    /* 16px */
.mud-typography-h6 { font-size: 0.9375rem !important; } /* 15px */
.mud-typography-body1 { font-size: 0.9375rem !important; } /* 15px */
.mud-typography-body2 { font-size: 0.8125rem !important; } /* 13px */
.mud-typography-caption { font-size: 0.75rem !important; } /* 12px */

/* ── Berry Shadow System ── */
.berry-shadow-sm { box-shadow: 0 1px 4px 0 rgba(32, 40, 45, 0.06); }
.berry-shadow { box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08); }
.berry-shadow-lg { box-shadow: 0 4px 20px 0 rgba(32, 40, 45, 0.12); }

/* ── Berry Card ── */
.berry-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08);
    border: 1px solid transparent;
    transition: box-shadow 0.3s ease;
}
.berry-card:hover {
    box-shadow: 0 4px 20px 0 rgba(32, 40, 45, 0.12);
}

/* ── Animations ── */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes scale-in { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.animate-fade-in { animation: fade-in 0.4s ease-out; }
.animate-slide-up { animation: slide-up 0.4s ease-out; }
.animate-scale-in { animation: scale-in 0.3s ease-out; }

/* ── Buttons ── */
.mud-button-root {
    text-transform: none !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    border-radius: 0.5rem !important;
    box-shadow: none !important;
    transition: all 0.2s ease !important;
    font-size: 0.8125rem !important;
}
.mud-button-filled {
    box-shadow: 0 1px 4px 0 rgba(32, 40, 45, 0.06) !important;
}
.mud-button-outlined {
    border-color: #e2e8f0 !important;
}
.mud-button-outlined:hover {
    background-color: #f8fafc !important;
}

/* ── Inputs ── */
.mud-input-outlined .mud-input-outlined-border {
    border-radius: 0.5rem !important;
    border-color: #e2e8f0 !important;
    transition: border-color 0.2s ease !important;
}
.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: #cbd5e1 !important;
}
.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: #7c3aed !important;
    border-width: 1.5px !important;
}
.mud-input { font-size: 0.875rem !important; }
.mud-input-label { font-size: 0.8125rem !important; font-weight: 500 !important; }

/* ── Tabs — minimal style matching Python webapp ── */
.mud-tabs { border-radius: 12px !important; overflow: hidden; }
.mud-tabs-header {
    background: white !important;
    border-bottom: 1px solid #e5e7eb !important;
}
.mud-tab {
    text-transform: none !important;
    font-weight: 500 !important;
    font-size: 0.8125rem !important;
    letter-spacing: normal !important;
    min-width: auto !important;
    padding: 0.75rem 1rem !important;
    color: #6b7280 !important;
    transition: all 0.2s ease !important;
}
.mud-tab .mud-icon-root {
    font-size: 1rem !important;
    color: #9ca3af !important;
}
.mud-tab:hover { color: #374151 !important; }
.mud-tab.mud-tab-active { color: #1e293b !important; font-weight: 600 !important; }
.mud-tab.mud-tab-active .mud-icon-root { color: #7c3aed !important; }
.mud-tab-slider { background: #7c3aed !important; height: 2px !important; }
/* Hide badge numbers on tabs */
.mud-tab .mud-badge { display: none !important; }

/* ── Paper / Cards — Berry shadows ── */
.mud-paper {
    border-radius: 12px !important;
    box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08) !important;
}
.mud-paper-outlined {
    border-color: #e2e8f0 !important;
    box-shadow: none !important;
}
.mud-paper[style*="border: 1px solid"],
.mud-paper[style*="border:1px solid"] {
    box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08) !important;
}

/* Dashboard stat/dept cards */
.stat-card, .dept-card, .onboarding-step {
    box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08) !important;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    transition: box-shadow 0.3s ease, transform 0.2s ease !important;
}
.stat-card:hover, .dept-card:hover {
    box-shadow: 0 4px 20px 0 rgba(32, 40, 45, 0.12) !important;
    transform: translateY(-1px);
}

/* ── Chips ── */
.mud-chip {
    border-radius: 9999px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    height: auto !important;
    padding: 0.125rem 0.625rem !important;
}

/* ── DataGrid / Tables ── */
.mud-table, .mud-data-grid {
    border-radius: 12px !important;
    overflow: hidden !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 2px 14px 0 rgba(32, 40, 45, 0.08) !important;
}
.mud-table-head .mud-table-cell, .mud-data-grid .mud-table-head .mud-table-cell {
    background: #f8fafc !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    color: #475569 !important;
    padding: 0.625rem 0.875rem !important;
    border-bottom: 1px solid #e2e8f0 !important;
}
.mud-table-body .mud-table-cell, .mud-data-grid .mud-table-body .mud-table-cell {
    font-size: 0.8125rem !important;
    padding: 0.5rem 0.875rem !important;
    border-bottom: 1px solid #f1f5f9 !important;
    color: #334155 !important;
}
.mud-table-body .mud-table-row:hover, .mud-data-grid .mud-table-body .mud-table-row:hover {
    background: #f8fafc !important;
}
.mud-table-body .mud-table-row:nth-child(even) { background: #fafbfc !important; }
.mud-table-body .mud-table-row:nth-child(even):hover { background: #f1f5f9 !important; }
.mud-table-pagination, .mud-data-grid-pager {
    border-top: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
    font-size: 0.8125rem !important;
    padding: 0.5rem 0.875rem !important;
}

/* ── Dialogs ── */
.mud-dialog {
    border-radius: 12px !important;
    box-shadow: 0 25px 50px -12px rgba(32, 40, 45, 0.2) !important;
}
.mud-dialog-title { padding: 1.25rem 1.5rem 0.75rem !important; }
.mud-dialog-content { padding: 0 1.5rem !important; }
.mud-dialog-actions { padding: 0.75rem 1.5rem 1.25rem !important; }

/* ── Alerts ── */
.mud-alert { border-radius: 0.5rem !important; font-size: 0.8125rem !important; }

/* ── Upload Drop Zone ── */
.upload-dropzone-btn {
    border: 2px dashed #d1d5db !important;
    border-radius: 12px !important;
    padding: 3rem 2rem !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    min-height: 280px !important;
    background: #fafafa !important;
    cursor: pointer !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
}
.upload-dropzone-btn:hover {
    border-color: #7c3aed !important;
    background: rgba(124, 58, 237, 0.02) !important;
}
.upload-dropzone-btn .mud-button-label {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0 !important;
    width: 100% !important;
}

/* ── Berry Nav (Pure HTML sidebar — no MudBlazor components) ── */
.berry-nav-section {
    margin-bottom: 1.5rem;
}

.berry-nav-label {
    padding: 0 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.berry-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.berry-nav-item:hover {
    background: #f3f4f6;
    color: #111827;
}

.berry-nav-active {
    background: rgba(124, 58, 237, 0.08) !important;
    color: #7c3aed !important;
    font-weight: 500;
}

.berry-nav-group-btn {
    font-weight: 500;
}

.berry-nav-subitem {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 1.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 400;
    color: #6b7280;
    text-decoration: none;
    transition: all 0.2s ease;
}

.berry-nav-subitem:hover {
    background: #f3f4f6;
    color: #374151;
}

.berry-nav-subitem.berry-nav-active {
    background: rgba(124, 58, 237, 0.08);
    color: #7c3aed;
    font-weight: 500;
}

/* ── MudBlazor Nav overrides (fallback for any remaining MudNav usage) ── */
.mud-drawer .mud-nav-link {
    border-radius: 0.5rem !important;
    margin: 1px 0 !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    color: #4b5563 !important;
    min-height: 40px !important;
    padding: 0.375rem 1rem !important;
    transition: all 0.2s ease !important;
}
.mud-drawer .mud-nav-link:hover {
    background: #f3f4f6 !important;
    color: #111827 !important;
}
.mud-drawer .mud-nav-link.active {
    background: rgba(124, 58, 237, 0.08) !important;
    color: #7c3aed !important;
    font-weight: 500 !important;
}
/* Sub-items inside nav groups (admin, departments) */
.mud-drawer .mud-nav-group .mud-collapse .mud-nav-link {
    font-size: 0.8125rem !important;
    font-weight: 400 !important;
    color: #6b7280 !important;
    min-height: 36px !important;
    padding-left: 1.75rem !important;
}
.mud-drawer .mud-nav-group .mud-collapse .mud-nav-link:hover {
    color: #374151 !important;
    background: #f3f4f6 !important;
}
.mud-drawer .mud-nav-group .mud-collapse .mud-nav-link.active {
    color: #7c3aed !important;
    background: rgba(124, 58, 237, 0.08) !important;
    font-weight: 500 !important;
}
.mud-drawer .mud-nav-group .mud-collapse .mud-nav-link .mud-icon-root {
    font-size: 0.875rem !important;
}
/* Nav group header text */
.mud-drawer .mud-nav-group .mud-nav-link {
    font-weight: 500 !important;
    color: #4b5563 !important;
}

/* ── Progress Bars ── */
.mud-progress-linear { border-radius: 9999px !important; overflow: hidden !important; }
.mud-progress-linear .mud-progress-linear-bar { border-radius: 9999px !important; }

/* ── Snackbar ── */
.mud-snackbar {
    border-radius: 12px !important;
    box-shadow: 0 4px 20px 0 rgba(32, 40, 45, 0.12) !important;
    font-size: 0.8125rem !important;
}

/* ── Drawer / Sidebar — shadow instead of border ── */
.mud-drawer {
    border-right: none !important;
    box-shadow: 2px 0 14px 0 rgba(32, 40, 45, 0.06) !important;
}

/* ── AppBar — shadow instead of border ── */
.mud-appbar {
    border-bottom: none !important;
    box-shadow: 0 1px 4px 0 rgba(32, 40, 45, 0.06) !important;
}

/* ── Badge ── */
.mud-badge .mud-badge-content {
    font-size: 0.625rem !important;
    font-weight: 600 !important;
    border-radius: 9999px !important;
}

/* ── Select / Menu / Popover ── */
.mud-popover-paper {
    border-radius: 12px !important;
    box-shadow: 0 4px 20px 0 rgba(32, 40, 45, 0.12) !important;
    border: 1px solid #e2e8f0 !important;
}
.mud-list-item {
    font-size: 0.8125rem !important;
    border-radius: 0.375rem !important;
    margin: 1px 4px !important;
}
.mud-list-item:hover { background: #f8fafc !important; }

/* ── Icon Button ── */
.mud-icon-button {
    border-radius: 0.5rem !important;
    transition: all 0.2s ease !important;
}

/* ── Expansion Panel ── */
.mud-expand-panel {
    border-radius: 12px !important;
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
}

/* ── AI Response HTML Tables ── */
table.md-table,
.answer-content table,
.markdown-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1rem 0;
    font-size: 0.8125rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px 0 rgba(32, 40, 45, 0.06);
}
table.md-table thead th,
.answer-content table thead th,
.answer-content th,
.markdown-body th {
    background: #f8fafc !important;
    font-weight: 600 !important;
    text-align: left;
    padding: 0.625rem 0.875rem;
    border-bottom: 2px solid #e2e8f0;
    color: #475569;
    font-size: 0.75rem;
    white-space: nowrap;
}
table.md-table tbody td,
.answer-content table tbody td,
.answer-content td,
.markdown-body td {
    padding: 0.5rem 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}
.answer-content tbody tr:hover,
.markdown-body tbody tr:hover { background: #f8fafc; }
.answer-content tbody tr:nth-child(even),
.markdown-body tbody tr:nth-child(even) { background: #fafbfc; }

/* Scrollable content */
.answer-content, .markdown-body { overflow-x: auto; }

/* ── AI Response Typography ── */
.answer-content h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: #1e293b;
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #f1f5f9;
}
.answer-content h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #334155;
    margin: 1rem 0 0.375rem;
}
.answer-content p {
    font-size: 0.8125rem;
    line-height: 1.65;
    color: #475569;
    margin: 0.375rem 0;
}
.answer-content strong { color: #7c3aed; }
.answer-content ul, .answer-content ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.answer-content li { font-size: 0.8125rem; color: #475569; margin: 0.25rem 0; }
.answer-content code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: #7c3aed;
}
.answer-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    font-size: 0.8125rem;
}
.answer-content pre code { background: transparent; color: inherit; padding: 0; }

/* Main content area */
.main-content { animation: fade-in 0.4s ease-out; }
