/* ===== CSS Variables / Color Scheme ===== */
:root {
    --orange: #E8501E;
    --orange-dark: #D04518;
    --orange-light: #FF6B3D;
    --yellow: #F5C518;
    --yellow-light: #FFD54F;
    --dark: #1A1A2E;
    --dark-light: #16213E;
    --blue: #4FC3F7;
    --blue-light: #81D4FA;
    --white: #FFFFFF;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #ADB5BD;
    --gray-500: #6C757D;
    --gray-600: #495057;
    --gray-700: #343A40;
    --gray-800: #212529;
    --success: #2ECC71;
    --danger: #E74C3C;
    --warning: #F39C12;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: contain;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--white);
}

.nav-item.active {
    background: var(--orange);
    color: var(--white);
}

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

/* ===== Main Wrapper ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

/* ===== Top Bar ===== */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 20px;
    z-index: 900;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.sidebar-toggle:hover {
    background: var(--gray-100);
}

.topbar-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}

.topbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 0.85rem;
}

.topbar-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--gray-50);
    transition: var(--transition);
    font-family: inherit;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--orange);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(232, 80, 30, 0.1);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.topbar-icon {
    position: relative;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.topbar-icon:hover {
    background: var(--gray-100);
    color: var(--orange);
}

.topbar-icon .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--orange);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--orange);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
}

/* ===== Content Area ===== */
.content {
    padding: 28px;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.5px;
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    transition: var(--transition);
    border: 1px solid var(--gray-100);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.825rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.stat-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-500);
}

.stat-badge.stat-up {
    background: rgba(46, 204, 113, 0.1);
    color: var(--success);
}

.stat-badge.stat-down {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
}

/* ===== Cards ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
}

.card-action {
    font-size: 0.825rem;
    color: var(--orange);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.card-action:hover {
    color: var(--orange-dark);
}

.card-body {
    padding: 20px 24px;
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    text-align: left;
    font-size: 0.85rem;
}

.data-table th {
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table tr:not(:last-child) td {
    border-bottom: 1px solid var(--gray-100);
}

.data-table tr:hover td {
    background: var(--gray-50);
}

/* ===== Status Badges ===== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-resolved {
    background: rgba(46, 204, 113, 0.1);
    color: var(--success);
}

.status-progress {
    background: rgba(245, 197, 24, 0.15);
    color: var(--warning);
}

.status-open {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

/* ===== Type Badges ===== */
.type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.type-swap {
    background: rgba(232, 80, 30, 0.1);
    color: var(--orange);
}

.type-stuck {
    background: rgba(245, 197, 24, 0.15);
    color: var(--warning);
}

.type-charging {
    background: rgba(79, 195, 247, 0.15);
    color: var(--blue);
}

.type-completed {
    background: rgba(46, 204, 113, 0.12);
    color: var(--success);
}

.type-returned {
    background: rgba(155, 89, 182, 0.12);
    color: #9B59B6;
}

/* ===== Rack List ===== */
.rack-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rack-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.rack-item:hover {
    background: var(--gray-50);
}

.rack-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rack-status.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}

.rack-status.offline {
    background: var(--danger);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.4);
}

.rack-info {
    flex: 1;
}

.rack-info strong {
    display: block;
    font-size: 0.875rem;
    color: var(--dark);
}

.rack-info span {
    font-size: 0.775rem;
    color: var(--gray-500);
}

.slots-available {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--success);
}

.slots-warning {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--danger);
}

.slots-low {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--warning);
}

/* ===== Alerts ===== */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    color: #1B7A3D;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    color: #C0392B;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    color: inherit;
}

.alert-close:hover {
    opacity: 1;
}

/* =========================================
   AUTH PAGES (Login / Register)
   ========================================= */
.auth-body {
    background: var(--dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container {
    display: flex;
    width: 900px;
    max-width: 95vw;
    min-height: 560px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    top: -80px;
    right: -80px;
}

.auth-left::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    bottom: -60px;
    left: -60px;
}

.auth-left-content {
    text-align: center;
    color: var(--white);
    position: relative;
    z-index: 1;
}

.auth-logo {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: contain;
    margin-bottom: 24px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.auth-left-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-left-content p {
    font-size: 1rem;
    opacity: 0.9;
}

.auth-tagline {
    margin-top: 20px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
    backdrop-filter: blur(4px);
}

.auth-right {
    flex: 1;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.auth-form-wrapper {
    width: 100%;
    max-width: 360px;
}

.auth-form-wrapper h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group label {
    display: block;
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper > i {
    position: absolute;
    left: 14px;
    color: var(--gray-400);
    font-size: 0.85rem;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--gray-50);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--orange);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(232, 80, 30, 0.1);
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--gray-600);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--orange);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--orange-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232, 80, 30, 0.3);
}

.btn-block {
    width: 100%;
}

.auth-footer-text {
    text-align: center;
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.auth-footer-text a {
    color: var(--orange);
    font-weight: 600;
}

.auth-footer-text a:hover {
    color: var(--orange-dark);
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .topbar-search {
        display: none;
    }

    .user-name {
        display: none;
    }

    .content {
        padding: 20px 16px;
    }

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

    /* Auth responsive */
    .auth-container {
        flex-direction: column;
        min-height: auto;
    }

    .auth-left {
        padding: 30px;
    }

    .auth-logo {
        width: 80px;
        height: 80px;
    }

    .auth-left-content h1 {
        font-size: 1.5rem;
    }

    .auth-right {
        padding: 30px 24px;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.35rem;
    }
}
