/* ========================================
   GLOBAL STYLES
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #e2e8f0;
    background: linear-gradient(135deg, #0f172a 0%, #1a1f35 100%);
    min-height: 100vh;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   LAYOUT
   ======================================== */

.layout {
    display: flex;
    height: 100vh;
    background: #0f172a;
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #0f172a 0%, #1a1f35 100%);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
    padding: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.logo-icon {
    font-size: 24px;
    color: #6366f1;
    animation: fadeIn 0.6s ease;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.5px;
}

/* Navigation Menu */
.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: #6366f1;
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #e2e8f0;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.nav-item.active::before {
    height: 20px;
}

/* User Profile Section */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-profile:hover {
    background: rgba(99, 102, 241, 0.1);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #0f172a;
}

/* Header */
.header {
    padding: 28px 32px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.5), rgba(30, 41, 59, 0.3));
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn-secondary {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
    border-color: rgba(99, 102, 241, 0.4);
}

/* ========================================
   METRICS SECTION
   ======================================== */

.metrics-section {
    padding: 32px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.3));
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.metric-card:hover {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.5));
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.metric-card:hover::before {
    transform: scaleX(1);
}

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

.metric-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

.metric-badge.positive {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.metric-badge.negative {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 4px;
}

.metric-value.green {
    color: #22c55e;
}

.metric-value.red {
    color: #ef4444;
}

.metric-subtitle {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 12px;
}

.metric-bar {
    height: 4px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.metric-progress {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 2px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-progress.negative {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* ========================================
   CHARTS SECTION
   ======================================== */

.charts-section {
    padding: 0 32px 32px;
}

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.chart-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.3));
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.3s ease;
}

.chart-card:hover {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.5));
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1);
}

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

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #f1f5f9;
}

.chart-meta {
    font-size: 12px;
    color: #94a3b8;
    background: rgba(99, 102, 241, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

/* ========================================
   TABLES
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
}

table thead {
    background: rgba(99, 102, 241, 0.05);
}

table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(148, 163, 184, 0.1);
}

table td {
    padding: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    font-size: 14px;
}

table tbody tr {
    transition: all 0.2s ease;
}

table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* ========================================
   FORMS
   ======================================== */

.form {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.3));
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 14px;
    padding: 24px;
}

.form input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    color: #f1f5f9;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form input::placeholder {
    color: #64748b;
}

.form input:focus {
    outline: none;
    background: rgba(15, 23, 42, 0.7);
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form button {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.form button:active {
    transform: translateY(0);
}

/* ========================================
   COLOR UTILITIES
   ======================================== */

.green {
    color: #22c55e;
}

.red {
    color: #ef4444;
}

.yellow {
    color: #facc15;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-content {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(148, 163, 184, 0.1);
        flex-direction: row;
        align-items: center;
        padding: 12px;
    }

    .sidebar-header {
        padding: 0;
        border: none;
        margin-right: 20px;
    }

    .nav-menu {
        flex-direction: row;
        gap: 4px;
        padding: 0;
        flex: 1;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 12px;
    }

    .nav-item span {
        display: none;
    }

    .sidebar-footer {
        padding: 0;
        border: none;
        margin-left: auto;
    }

    .main {
        flex: 1;
    }

    .header {
        padding: 20px 16px;
    }

    .page-title {
        font-size: 22px;
    }

    .metrics-section,
    .charts-section {
        padding: 16px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-value {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 4px;
    }

    .btn-secondary {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .logo-icon {
        font-size: 18px;
    }

    .logo {
        font-size: 16px;
    }

    .page-title {
        font-size: 20px;
    }

    .chart-wrapper {
        height: 250px;
    }
}