/**
 * Monitoring Dashboard Styles
 * Accessible, responsive, and visually clear monitoring interface
 */

/* Dashboard container */
.monitoring-dashboard {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.monitoring-dashboard.active {
    display: flex;
    opacity: 1;
}

/* Backdrop */
.monitoring-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* Panel */
.monitoring-panel {
    position: relative;
    margin: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.monitoring-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #E2E8F0;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
}

.monitoring-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.monitoring-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.monitoring-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.monitoring-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Content area */
.monitoring-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Tabs */
.monitoring-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #E2E8F0;
    overflow-x: auto;
}

.monitoring-tab {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #64748B;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.monitoring-tab:hover {
    color: #667EEA;
    background: rgba(102, 126, 234, 0.05);
}

.monitoring-tab.active {
    color: #667EEA;
    border-bottom-color: #667EEA;
}

.monitoring-tab:focus {
    outline: 2px solid #667EEA;
    outline-offset: -2px;
}

/* Sections */
.monitoring-section {
    margin-bottom: 28px;
}

.monitoring-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1E2740;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stats grid */
.monitoring-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #F8FAFC;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}

.stat-label {
    font-size: 14px;
    color: #64748B;
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #1E2740;
}

.stat-value.stat-success {
    color: #00C9A7;
}

.stat-value.stat-error {
    color: #FF6B6B;
}

.stat-value.stat-warning {
    color: #FFB020;
}

/* Storage usage bar */
.storage-usage-bar {
    position: relative;
    height: 40px;
    background: #E2E8F0;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 20px;
}

.storage-usage-fill {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease;
    position: relative;
}

.storage-usage-fill.good {
    background: linear-gradient(90deg, #00C9A7, #00E5BF);
}

.storage-usage-fill.warning {
    background: linear-gradient(90deg, #FFB020, #FFC857);
}

.storage-usage-fill.critical {
    background: linear-gradient(90deg, #FF6B6B, #FF8787);
}

.storage-usage-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 14px;
    color: #1E2740;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Storage breakdown */
.storage-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.breakdown-item {
    display: grid;
    grid-template-columns: 150px 1fr 100px;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #F1F5F9;
}

.breakdown-label {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breakdown-bar {
    height: 8px;
    background: #E2E8F0;
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    background: linear-gradient(90deg, #667EEA, #764BA2);
    transition: width 0.3s ease;
}

.breakdown-value {
    font-size: 12px;
    color: #64748B;
    text-align: right;
}

/* Operations list */
.operations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.operation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #F8FAFC;
    border-radius: 6px;
    border-left: 3px solid #FFB020;
}

.operation-time {
    font-size: 12px;
    color: #64748B;
    font-family: 'Monaco', 'Courier New', monospace;
}

.operation-name {
    flex: 1;
    margin: 0 12px;
    font-size: 14px;
    color: #1E2740;
}

.operation-duration {
    font-size: 14px;
    font-weight: 600;
    color: #FFB020;
}

/* Latency chart */
.latency-chart {
    background: #F8FAFC;
    padding: 20px;
    border-radius: 8px;
}

.latency-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 100px;
}

.latency-bar {
    flex: 1;
    min-width: 8px;
    height: 100%;
    position: relative;
    cursor: help;
}

.latency-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(180deg, #667EEA, #764BA2);
    border-radius: 3px 3px 0 0;
    transition: height 0.3s ease;
    min-height: 2px;
}

.latency-bar:hover .latency-fill {
    opacity: 0.8;
}

/* Errors */
.errors-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #F8FAFC;
    border-radius: 6px;
    border-left: 3px solid #FF6B6B;
}

.category-name {
    font-size: 14px;
    color: #1E2740;
    font-weight: 500;
    text-transform: capitalize;
}

.category-count {
    font-size: 16px;
    font-weight: 700;
    color: #FF6B6B;
}

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

.error-item {
    padding: 14px;
    background: #FFF5F5;
    border-radius: 8px;
    border-left: 4px solid #FF6B6B;
}

.error-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.error-category {
    font-size: 12px;
    font-weight: 600;
    color: #FF6B6B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.error-time {
    font-size: 12px;
    color: #64748B;
}

.error-message {
    font-size: 14px;
    color: #1E2740;
    margin-bottom: 8px;
}

.error-details {
    margin-top: 8px;
}

.error-details summary {
    font-size: 13px;
    color: #64748B;
    cursor: pointer;
    user-select: none;
}

.error-details summary:hover {
    color: #1E2740;
}

.error-details pre {
    margin-top: 8px;
    padding: 12px;
    background: white;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    color: #334155;
}

/* Actions */
.monitoring-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Footer */
.monitoring-footer {
    padding: 12px 24px;
    border-top: 1px solid #E2E8F0;
    background: #F8FAFC;
    text-align: center;
}

.monitoring-footer small {
    color: #64748B;
    font-size: 12px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 32px;
    color: #94A3B8;
    font-size: 14px;
    font-style: italic;
}

/* Monitoring status indicator (small badge in header) */
.monitoring-status-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.monitoring-status-button {
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    font-size: 24px;
}

.monitoring-status-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.monitoring-status-button:focus {
    outline: 3px solid #667EEA;
    outline-offset: 3px;
}

.monitoring-status-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #FF6B6B;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
}

/* Responsive design */
@media (max-width: 768px) {
    .monitoring-panel {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .monitoring-content {
        padding: 16px;
    }

    .monitoring-stats {
        grid-template-columns: 1fr;
    }

    .breakdown-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .breakdown-bar {
        grid-column: 1 / -1;
    }

    .breakdown-value {
        text-align: left;
    }

    .monitoring-status-indicator {
        bottom: 80px; /* Above mobile nav */
    }

    .latency-bars {
        height: 80px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .monitoring-panel {
        background: #1E2740;
        color: #E2E8F0;
    }

    .monitoring-header {
        border-bottom-color: #334155;
    }

    .monitoring-section h3 {
        color: #E2E8F0;
    }

    .stat-item {
        background: #0F172A;
        border-color: #334155;
    }

    .stat-label {
        color: #94A3B8;
    }

    .stat-value {
        color: #E2E8F0;
    }

    .storage-usage-bar {
        background: #334155;
    }

    .storage-usage-text {
        color: white;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    .breakdown-item {
        border-bottom-color: #334155;
    }

    .breakdown-label,
    .breakdown-value {
        color: #94A3B8;
    }

    .breakdown-bar {
        background: #334155;
    }

    .operation-item,
    .category-item,
    .latency-chart {
        background: #0F172A;
    }

    .operation-name,
    .category-name,
    .error-message {
        color: #E2E8F0;
    }

    .error-item {
        background: rgba(239, 68, 68, 0.1);
    }

    .error-details pre {
        background: #0F172A;
        color: #94A3B8;
    }

    .monitoring-footer {
        background: #0F172A;
        border-top-color: #334155;
    }

    .empty-state {
        color: #64748B;
    }

    .monitoring-tabs {
        border-bottom-color: #334155;
    }

    .monitoring-tab {
        color: #94A3B8;
    }

    .monitoring-tab:hover {
        background: rgba(102, 126, 234, 0.1);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .monitoring-dashboard,
    .monitoring-close,
    .storage-usage-fill,
    .latency-fill,
    .monitoring-tab {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .monitoring-panel {
        border: 2px solid currentColor;
    }

    .stat-item,
    .operation-item,
    .category-item,
    .error-item {
        border: 1px solid currentColor;
    }
}
