@import url('../../css/design-tokens.css');

body {
    font-family: var(--font-ui), var(--font-body), system-ui, sans-serif;
    background: var(--light);
    color: var(--dark);
    margin: 0;
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--white);
    color: var(--dark);
    padding: 2rem 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

.logo {
    padding: 0 2rem 2rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    text-decoration: none;
    display: block;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    color: var(--gray);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    font-weight: 500;
}

.nav-item a:hover,
.nav-item a.active {
    background: var(--light);
    color: var(--dark);
    border-left-color: var(--primary);
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
    fill: none;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    max-width: calc(100% - 260px);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 700;
}

.btn-logout {
    padding: 0.5rem 1.5rem;
    background: transparent;
    border: 1px solid var(--gray);
    border-radius: 50px;
    color: var(--gray);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fee2e2;
}

/* Cards */
.card {
    background: var(--white);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--light);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--gray);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 217, 217, 0.3);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--light);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray);
    font-size: 0.85rem;
    border-bottom: 2px solid #e2e8f0;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--light);
}

.table tr:hover {
    background: #f8fafc;
}

/* Badges */
.badge {
    padding: 0.35rem 1rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef9c3;
    color: #854d0e;
}

.badge-info {
    background: #e0e7ff;
    color: #3730a3;
}

/* Mobile menu toggle button */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--white);
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.mobile-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--dark);
    margin: 4px 0;
    transition: 0.3s;
    border-radius: 1px;
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

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

    .main-content {
        margin-left: 240px;
        max-width: calc(100% - 240px);
        padding: 1.5rem;
    }

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

/* Responsive - Mobile */
@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }

    .mobile-overlay.active {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        width: 280px;
    }

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

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 1rem;
        padding-top: 4rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .welcome-title h1 {
        font-size: 1.5rem;
    }

    /* Cards */
    .card {
        border-radius: 12px;
    }

    .card-body {
        padding: 1rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    .stat-card .label {
        font-size: 0.75rem;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .table {
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    /* Forms */
    .form-control {
        padding: 0.875rem;
        font-size: 16px;
        /* Prevents iOS zoom */
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 1rem;
    }

    /* Buttons */
    .btn-primary {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
    }

    /* Filters */
    .filters {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filters select,
    .filters input {
        width: 100%;
    }

    /* Page Header */
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Charts */
    .chart-container {
        height: 250px !important;
    }

    /* Badge */
    .badge {
        padding: 0.25rem 0.75rem;
        font-size: 0.7rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
        padding-top: 3.5rem;
    }

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

    .stat-card {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .stat-card .icon {
        order: 2;
    }

    .welcome-title h1 {
        font-size: 1.25rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-item a {
        padding: 1.25rem 2rem;
        min-height: 48px;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 44px;
    }

    .form-control {
        min-height: 44px;
    }
}