/* css/monitoring.css — Premium OCR & AI Monitoring Center Styles */

/* KPI grid layout */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-4); /* 16px */
    margin-bottom: var(--space-6); /* 24px */
}

@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4); /* 16px */
    }
}

/* Premium KPI Card */
.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6); /* 20px top/bottom, 24px left/right */
    position: relative;
    overflow: hidden;
    transition: box-shadow var(--duration-base), border-color var(--duration-base), transform var(--duration-base);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 120px;
    height: 100%;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-default);
    box-shadow: var(--shadow-lg);
}

/* Subtle decorative gradient overlay on cards */
.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-purple));
    opacity: 0.85;
}

.metric-card.danger::before {
    background: linear-gradient(90deg, var(--color-danger), #f87171);
}

.metric-card.success::before {
    background: linear-gradient(90deg, var(--color-success), #34d399);
}

.metric-card.warning::before {
    background: linear-gradient(90deg, var(--color-warning), #fbbf24);
}

.metric-title {
    font-size: var(--font-size-xs); /* 11px */
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2); /* 8px */
}

.metric-value {
    font-size: var(--font-size-3xl); /* 30px */
    font-weight: var(--font-weight-extrabold);
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: var(--space-1); /* 4px */
    letter-spacing: -0.03em;
}

.metric-subtext {
    font-size: var(--font-size-xs); /* 11px */
    color: var(--text-tertiary);
}

/* Dashboard Grid split (e.g. chart on left, list/pie on right) */
.monitoring-dashboard-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6); /* 24px */
    margin-bottom: var(--space-6); /* 24px */
}

@media (max-width: 1024px) {
    .monitoring-dashboard-split {
        grid-template-columns: 1fr;
        gap: var(--space-6); /* 24px */
    }
}

.dashboard-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-6); /* 24px */
    box-shadow: var(--shadow-card);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Charts Wrapper */
.chart-container {
    position: relative;
    width: 100%;
    height: 380px; /* Standard height 380px */
}

/* Filters row styling */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4); /* 16px */
    padding: var(--space-4); /* 16px */
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6); /* 24px */
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-2); /* 8px */
}

.filter-group label {
    font-size: var(--font-size-xs); /* 11px */
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.filter-input {
    height: 32px;
    padding: 0 var(--space-2); /* 8px */
    font-size: var(--font-size-sm); /* 13px */
    background: var(--bg-page);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--duration-fast);
}

.filter-input:focus {
    border-color: var(--border-brand);
}

/* Table elements */
.monitoring-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    overflow: hidden;
    margin-top: 20px;
}

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

.monitoring-table th {
    background: var(--bg-page);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.monitoring-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

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

.monitoring-table tr:hover td {
    background: var(--bg-page);
}

/* Mini Dot Status Indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.success { background-color: var(--color-success); }
.status-dot.danger { background-color: var(--color-danger); }
.status-dot.warning { background-color: var(--color-warning); }

/* Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-page);
    border-radius: 10px;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: var(--border-subtle);
}

.leaderboard-rank {
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    margin-right: 12px;
}

.leaderboard-item:nth-child(1) .leaderboard-rank { background: #ffd700; color: #16162a; } /* Gold */
.leaderboard-item:nth-child(2) .leaderboard-rank { background: #c0c0c0; color: #16162a; } /* Silver */
.leaderboard-item:nth-child(3) .leaderboard-rank { background: #cd7f32; color: #16162a; } /* Bronze */

.leaderboard-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.leaderboard-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-sub {
    font-size: 11px;
    color: var(--text-tertiary);
}

.leaderboard-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Quality Incident Alerts Panel */
.active-alerts-panel {
    background: var(--color-danger-bg);
    border: 1px solid var(--color-danger-light);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.alert-message-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-danger-light);
}

.alert-message-item:last-child {
    border-bottom: none;
}

.alert-desc {
    color: var(--color-danger-text);
    font-size: 13px;
    font-weight: 500;
}

/* Sticky table headers for monitoring tables */
.monitoring-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-page);
    border-bottom: 2px solid var(--border-default);
}

/* Dialog drawer */
.monitoring-detail-drawer {
    position: fixed;
    top: 0;
    right: -500px;
    width: 460px;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    box-shadow: -10px 0 30px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.monitoring-detail-drawer.open {
    right: 0;
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.drawer-field {
    margin-bottom: 16px;
}

.drawer-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.drawer-val {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-all;
}

.drawer-json {
    font-family: monospace;
    font-size: 11px;
    background: var(--bg-page);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    max-height: 200px;
    white-space: pre-wrap;
    border: 1px solid var(--border-subtle);
}

/* System Health Monitor Panel CSS */
.monitor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

.progress-track {
    height: 6px;
    background: var(--bg-sunken);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-2);
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s var(--easing-out);
    background: linear-gradient(90deg, var(--color-primary), var(--color-purple));
}

.progress-fill.warning {
    background: var(--color-warning);
}

.progress-fill.danger {
    background: var(--color-danger);
}

.service-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--bg-page);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    gap: var(--space-3);
    transition: border-color var(--duration-fast);
}

.service-row:last-child {
    margin-bottom: 0;
}

.service-row:hover {
    border-color: var(--border-default);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px transparent;
    transition: box-shadow var(--duration-base);
}

.status-dot.healthy {
    background: var(--color-success);
    box-shadow: 0 0 0 3px var(--color-success-bg);
}

.status-dot.down {
    background: var(--color-danger);
    box-shadow: 0 0 0 3px var(--color-danger-bg);
}

.status-dot.warning {
    background: var(--color-warning);
    box-shadow: 0 0 0 3px var(--color-warning-bg);
}

.db-table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: background-color var(--duration-fast);
}

.db-table-row:hover {
    background: var(--bg-sunken);
}

.system-stat-icon-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.system-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-md);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
}

.system-stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--color-purple);
}

.system-stat-icon.blue {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-primary);
}

.system-stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

@media (max-width: 768px) {
    .monitor-grid {
        grid-template-columns: 1fr;
    }
}

.service-row-expanded {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
}

.gv-details {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-left: 26px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.db-tables-container {
    display: flex;
    flex-direction: column;
}

/* OCR Specific Layout & Custom Styles */
.ocr-filter-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-4); /* 16px */
    margin-bottom: var(--space-6); /* 24px */
    display: flex;
    flex-direction: column;
    gap: var(--space-2); /* 8px spacing below label */
}

.ocr-filter-label {
    font-size: var(--font-size-xs); /* 11px */
    font-weight: var(--font-weight-bold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.ocr-filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3); /* 12px gap between inputs and buttons */
}

.ocr-filter-to {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    user-select: none;
}

/* Unified 60/40 Dashboard Rows */
.ocr-dashboard-row {
    display: grid;
    grid-template-columns: 6fr 4fr;
    gap: 24px;
    align-items: stretch;
    margin-bottom: 24px;
}

.ocr-chart-card, .ocr-table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-6); /* 24px */
    box-shadow: var(--shadow-card);
    height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ocr-chart-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
}

@media (max-width: 768px) {
    .ocr-dashboard-row {
        grid-template-columns: 1fr; /* Stack cards vertically */
    }
    .ocr-chart-card, .ocr-table-card {
        height: auto;
        min-height: 420px;
    }
    .ocr-chart-container {
        height: 320px;
    }
}

/* AI Cost Monitoring specific layout styles */
.cost-dashboard-row {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: 24px;
    align-items: stretch;
}

.cost-dashboard-row-55-45 {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: 24px;
    align-items: stretch;
}

.cost-chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    height: 420px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

@media (max-width: 1024px) {
    .cost-dashboard-row, .cost-dashboard-row-55-45 {
        grid-template-columns: 6fr 4fr;
    }
}

@media (max-width: 768px) {
    .cost-dashboard-row, .cost-dashboard-row-55-45 {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .cost-chart-card {
        height: auto;
        min-height: 420px;
    }
    .donut-chart-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .donut-legend-container {
        width: 100%;
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Skeleton Loading State styling */
.skeleton-loader {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, var(--bg-page) 25%, var(--border-subtle) 50%, var(--bg-page) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-md);
    color: transparent !important;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Donut chart legends */
.donut-legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background-color var(--duration-fast);
}

.donut-legend-item:hover {
    background-color: var(--bg-sunken);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Clickable Provider Row in Cost Monitoring Table */
.clickable-provider-row {
    transition: background-color var(--duration-fast) var(--easing-standard);
}

.clickable-provider-row:hover td {
    background-color: rgba(91, 76, 240, 0.08) !important;
}

/* Custom scrollbar styling for the provider table viewport */
#provider-table-view::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#provider-table-view::-webkit-scrollbar-track {
    background: transparent;
}
#provider-table-view::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
}
#provider-table-view::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

