/* ========== CSS Variables & Reset ========== */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a2642 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== Dashboard Container ========== */
.dashboard-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* ========== Header ========== */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.dashboard-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.875rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    stroke: var(--primary-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.last-update {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========== Buttons ========== */
.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ========== Dashboard Grid ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== Widget Card ========== */
.widget {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #a78bfa);
}

.widget:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.widget.widget-large {
    grid-column: span 2;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.widget-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-icon {
    width: 1.5rem;
    height: 1.5rem;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.widget-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

/* ========== Metric Widget ========== */
.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.5rem 0;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.metric-unit {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-change {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.metric-change.positive {
    color: var(--secondary-color);
}

.metric-change.negative {
    color: var(--danger-color);
}

.metric-change svg {
    width: 1rem;
    height: 1rem;
}

.metric-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ========== List Widget ========== */
.widget-list {
    list-style: none;
}

.widget-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.widget-list-item:hover {
    background: #475569;
}

.list-item-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.list-item-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* ========== Chart Widget ========== */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 1rem;
}

.chart-container canvas {
    max-height: 100%;
}

/* ========== Loading States ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
}

.widget-error {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-md);
    color: var(--danger-color);
    font-size: 0.875rem;
}

/* ========== Responsive Design ========== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
    
    .widget.widget-large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 1rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dashboard-title {
        font-size: 1.5rem;
    }
    
    .metric-value {
        font-size: 2rem;
    }
}

/* ========== Utility Classes ========== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}
