/* AIO Monitor — Light/Clean Theme with Purple Sidebar */

/* ----------------------------------------------------------------
   Base Typography & Layout
   ---------------------------------------------------------------- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #fafafa;
    color: #111827;
    font-size: 0.9375rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------------------
   Sidebar — Dark Indigo/Purple
   ---------------------------------------------------------------- */
.sidebar {
    width: 260px;
    min-width: 260px;
    position: sticky;
    top: 0;
    overflow-y: auto;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sidebar-brand {
    font-weight: 600;
    font-size: 1.05rem;
    color: #ffffff;
    letter-spacing: 0;
}

.sidebar .nav-link {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(224, 231, 255, 0.75);
    transition: background-color 0.15s, color 0.15s;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
    width: 1.2em;
    text-align: center;
}

.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.12);
    opacity: 1;
    margin: 0.75rem 0;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(224, 231, 255, 0.45);
    margin-bottom: 0.25rem;
    padding-left: 0.75rem;
}

/* Brand group in sidebar */
.sidebar-brand-group {
    margin-bottom: 0.5rem;
}

.sidebar-brand-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(224, 231, 255, 0.9);
}

.sidebar-brand-toggle {
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.15s;
    user-select: none;
}

.sidebar-brand-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-brand-toggle.active {
    color: #ffffff;
}

.sidebar-chevron {
    font-size: 0.65rem;
    color: rgba(224, 231, 255, 0.4);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-brand-toggle[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-brand-toggle:hover .sidebar-chevron {
    color: rgba(224, 231, 255, 0.7);
}

.sidebar-brand-header img {
    border-radius: 4px;
}

.sidebar-sub-nav {
    padding-left: 0.5rem;
}

.sidebar-sub-nav .nav-link {
    font-size: 0.825rem;
    padding: 0.3rem 0.65rem 0.3rem 1.75rem;
    color: rgba(224, 231, 255, 0.6);
}

.sidebar-sub-nav .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-sub-nav .nav-link.active {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.13);
}

.sidebar-sub-nav .nav-link i {
    font-size: 0.75rem;
    margin-right: 0.4rem;
    width: 1rem;
}

/* ----------------------------------------------------------------
   Main Content Area
   ---------------------------------------------------------------- */
.main-content {
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #fafafa;
    padding: 2rem !important;
}

/* ----------------------------------------------------------------
   Section Headers
   ---------------------------------------------------------------- */
h2, h3, h4 {
    font-weight: 600;
    color: #111827;
    letter-spacing: -0.01em;
}

h5, h6 {
    font-weight: 600;
    color: #1f2937;
}

/* ----------------------------------------------------------------
   Cards (General)
   ---------------------------------------------------------------- */
.card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    background-color: #ffffff;
    transition: box-shadow 0.15s;
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #f3f4f6;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* ----------------------------------------------------------------
   Metric Cards — colored left border, label above, big value
   ---------------------------------------------------------------- */
.metric-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    border-left: 3px solid var(--metric-accent, #4f46e5);
    background: #ffffff;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.metric-card .metric-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #9ca3af;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.metric-card .metric-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 0.6rem;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}

.metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.1;
}

.metric-card .metric-delta {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.35rem;
}

.metric-card .metric-delta .delta-up {
    color: #16a34a;
}

.metric-card .metric-delta .delta-down {
    color: #dc2626;
}

.metric-card .metric-delta .delta-neutral {
    color: #9ca3af;
}

/* Accent color variants */
.metric-card.accent-indigo  { --metric-accent: #4f46e5; }
.metric-card.accent-blue    { --metric-accent: #2563eb; }
.metric-card.accent-purple  { --metric-accent: #7c3aed; }
.metric-card.accent-green   { --metric-accent: #16a34a; }
.metric-card.accent-amber   { --metric-accent: #d97706; }
.metric-card.accent-gray    { --metric-accent: #6b7280; }
.metric-card.accent-teal    { --metric-accent: #0891b2; }
.metric-card.accent-rose    { --metric-accent: #e11d48; }

/* ----------------------------------------------------------------
   Chart Cards
   ---------------------------------------------------------------- */
.chart-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chart-card .chart-card-header {
    padding: 0.85rem 1.25rem 0.65rem;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.chart-card .chart-card-header h6 {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0;
    color: #374151;
    margin: 0;
}

.chart-card .chart-card-body {
    padding: 1rem 1.25rem;
    flex: 1;
    min-height: 0;
    position: relative;
}

.chart-card .chart-card-body canvas {
    width: 100% !important;
}

/* Fixed-height chart body for evolution/line charts — comfortable size */
.chart-body--fixed {
    height: 220px;
    flex: none;
}

/* Compact chart body for doughnuts/pies — keeps them small */
.chart-body--compact {
    max-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-body--compact canvas {
    max-height: 200px;
}

/* Auto-height chart body — expands to content (e.g. bar chart with N items) */
.chart-body--auto {
    flex: none;
    min-height: 120px;
}

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table th {
    font-weight: 500;
    font-size: 0.825rem;
    color: #6b7280;
    text-transform: none;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1rem;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #f3f4f6;
}

.table-hover tbody tr:hover {
    background-color: #f9fafb;
}

/* ----------------------------------------------------------------
   Badges
   ---------------------------------------------------------------- */
.badge {
    font-weight: 500;
    border-radius: 6px;
    font-size: 0.75rem;
    padding: 0.3em 0.65em;
}

.badge-metric {
    background-color: #eff6ff;
    color: #2563eb;
}

.badge-citation {
    background-color: #ecfdf5;
    color: #059669;
}

.badge-soft-primary {
    background-color: #eef2ff;
    color: #4f46e5;
}

.badge-soft-success {
    background-color: #ecfdf5;
    color: #059669;
}

.badge-soft-warning {
    background-color: #fffbeb;
    color: #d97706;
}

.badge-soft-danger {
    background-color: #fef2f2;
    color: #dc2626;
}

.badge-soft-secondary {
    background-color: #f3f4f6;
    color: #6b7280;
}

.badge-soft-indigo {
    background-color: #eef2ff;
    color: #4f46e5;
}

/* ----------------------------------------------------------------
   Breadcrumbs
   ---------------------------------------------------------------- */
.breadcrumb {
    font-size: 0.85rem;
    background: transparent;
    padding: 0;
    margin-bottom: 0;
}

.breadcrumb-item a {
    color: #6b7280;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: #4f46e5;
}

.breadcrumb-item.active {
    color: #9ca3af;
}

/* ----------------------------------------------------------------
   Dashboard Brand Cards (Main Page) — Premium Tiles
   ---------------------------------------------------------------- */
@keyframes dashMetricReveal {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.dash-card {
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.dash-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
    border-color: #d1d5db;
}

.dash-card-accent {
    height: 3px;
    background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 35%, #0891b2 70%, #059669 100%);
    opacity: 0.85;
}

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1.5rem;
}

.dash-brand-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid #f3f4f6;
}

.dash-brand-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.dash-brand-avatar--empty {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4f46e5;
    font-size: 1.05rem;
    border-color: #e0e7ff;
}

.dash-brand-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
    letter-spacing: -0.01em;
}

.dash-brand-meta {
    font-size: 0.8rem;
    color: #9ca3af;
    line-height: 1.3;
}

/* Action buttons */
.dash-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.8rem;
    border-radius: 8px;
    font-size: 0.825rem;
    font-weight: 500;
    text-decoration: none;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dash-btn:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #d1d5db;
}

.dash-btn--primary {
    color: #4f46e5;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.dash-btn--primary:hover {
    background: #e0e7ff;
    color: #4338ca;
    border-color: #a5b4fc;
}

/* Metrics Grid */
.dash-metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.625rem;
    padding: 1rem 1.5rem 1.35rem;
    border-top: 1px solid #f3f4f6;
}

.dash-metric {
    background: var(--m-bg, #f9fafb);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    border: 1px solid transparent;
    transition: all 0.25s ease;
    cursor: default;
    animation: dashMetricReveal 0.45s ease-out both;
    position: relative;
    overflow: hidden;
}

/* Subtle progress fill bar at bottom of metric tile */
.dash-metric::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2.5px;
    width: calc(var(--m-pct, 0) * 1%);
    background: linear-gradient(90deg, var(--m-accent, #6b7280), color-mix(in srgb, var(--m-accent, #6b7280) 70%, white));
    border-radius: 0 2px 0 0;
    opacity: 0;
    transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s, opacity 0.4s ease 0.4s;
}

.dash-card:hover .dash-metric::after,
.dash-metrics-grid--standalone .dash-metric::after {
    opacity: 0.55;
}

.dash-metric:hover::after {
    opacity: 0.85 !important;
}

.dash-metric:nth-child(1) { animation-delay: 0.04s; }
.dash-metric:nth-child(2) { animation-delay: 0.08s; }
.dash-metric:nth-child(3) { animation-delay: 0.12s; }
.dash-metric:nth-child(4) { animation-delay: 0.16s; }
.dash-metric:nth-child(5) { animation-delay: 0.20s; }
.dash-metric:nth-child(6) { animation-delay: 0.24s; }

.dash-metric:hover {
    border-color: var(--m-border, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.dash-metric-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--m-accent, #6b7280);
    margin-bottom: 0.6rem;
    box-shadow: 0 0 0 3px var(--m-bg, #f9fafb);
}

.dash-metric-value {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #111827;
    line-height: 1;
    letter-spacing: -0.025em;
    margin-bottom: 0.35rem;
    font-variant-numeric: tabular-nums;
}

.dash-metric-unit {
    font-size: 0.8rem;
    font-weight: 500;
    color: #9ca3af;
    margin-left: 1px;
    letter-spacing: 0;
}

.dash-metric-label {
    font-size: 0.675rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    line-height: 1.3;
}

.dash-metric-label .metric-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #9ca3af;
    font-size: 0.55rem;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.dash-metric-label .metric-info:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #6b7280;
}

/* Dashboard empty state */
.dash-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: #9ca3af;
}

.dash-empty-icon {
    font-size: 1.75rem;
    color: #d1d5db;
    margin-bottom: 0.5rem;
}

.dash-empty p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.dash-empty-link {
    font-size: 0.825rem;
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

.dash-empty-link:hover {
    color: #4338ca;
    text-decoration: underline;
}

/* Dash-metric delta (for monitoring dashboard) */
.dash-metric .metric-delta {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.dash-metric .metric-delta .delta-up {
    color: #059669;
}

.dash-metric .metric-delta .delta-down {
    color: #dc2626;
}

.dash-metric .metric-delta .delta-neutral {
    color: #9ca3af;
}

/* Standalone metrics grid (used on monitoring dashboard pages) */
.dash-metrics-grid--standalone {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    border-top: none;
}

/* Auto-fit for grids with fewer items (3-4 metrics) */
.dash-metrics-grid--standalone.dash-metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Responsive dashboard grid */
@media (max-width: 1200px) {
    .dash-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dash-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* ----------------------------------------------------------------
   Section Card (for page sections)
   ---------------------------------------------------------------- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h4 {
    margin-bottom: 0;
}

/* ----------------------------------------------------------------
   Sentiment bars
   ---------------------------------------------------------------- */
.sentiment-bar-container {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #f3f4f6;
}

.sentiment-bar-positive { background-color: #16a34a; }
.sentiment-bar-neutral  { background-color: #d97706; }
.sentiment-bar-negative { background-color: #dc2626; }

/* ----------------------------------------------------------------
   AIO Result Card
   ---------------------------------------------------------------- */
.aio-result-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.aio-result-card .aio-query {
    font-weight: 500;
    color: #111827;
    margin-bottom: 0.5rem;
}

.aio-result-card .aio-text {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.5;
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn-sm {
    border-radius: 8px;
    font-size: 0.825rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
}

.btn-outline-secondary {
    border-color: #e5e7eb;
    color: #6b7280;
}

.btn-outline-secondary:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}

/* ----------------------------------------------------------------
   Report Container (legacy fallback — main styles in report_view.html)
   ---------------------------------------------------------------- */

/* ----------------------------------------------------------------
   Spinner / Loading
   ---------------------------------------------------------------- */
.spinner-border {
    color: #4f46e5 !important;
}

/* ----------------------------------------------------------------
   Empty State
   ---------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state i {
    font-size: 3rem;
    color: #d1d5db;
    display: block;
    margin-bottom: 0.75rem;
}

/* ----------------------------------------------------------------
   Misc Utilities
   ---------------------------------------------------------------- */
.text-muted {
    color: #9ca3af !important;
}

.rounded-container {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    margin-bottom: 0;
}
