:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.student-list {
    list-style: none;
}

.student-item {
    padding: 14px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    border: 1px solid transparent;
}

.student-item:hover {
    background-color: #f1f5f9;
}

.student-item.active {
    background-color: #eef2ff;
    color: var(--primary-color);
    border-color: rgba(79, 70, 229, 0.2);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.05);
}

.student-info-minimal {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.student-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.student-status-hint {
    font-size: 0.75rem;
    color: var(--danger-color);
    margin-top: 2px;
}

.student-status-hint.success {
    color: var(--success-color);
    opacity: 0.8;
}

.unpaid-dot {
    width: 8px;
    height: 8px;
    background-color: var(--danger-color);
    border-radius: 50%;
    flex-shrink: 0;
}

.student-avatar {
    width: 44px;
    height: 44px;
    background-color: #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.student-item.active .student-avatar {
    background-color: var(--primary-color);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    padding: 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.2;
}

.details-view {
    flex: 1;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.student-info h2 {
    font-size: 2rem;
    font-weight: 700;
}

.student-info p {
    color: var(--text-muted);
    margin-top: 4px;
}

/* Totals Grid */
.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.total-card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.total-card .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.total-card .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.status-paid .value {
    color: var(--success-color);
}

.status-unpaid .value {
    color: var(--danger-color);
}

/* Table */
.session-section {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

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

.table-container {
    overflow-x: auto;
}

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

th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
}

td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
}

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

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

.status-badge.unpaid {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-list-msg {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -15px;
    margin-bottom: 20px;
}


/* Footer */
.global-footer {
    margin-top: auto;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.global-summary {
    display: flex;
    gap: 24px;
    color: var(--text-muted);
}

.global-summary span i {
    margin-right: 6px;
}

.data-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.875rem;
}

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

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

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-outline {
    border-color: var(--border-color);
    background: white;
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-main);
}

.btn-danger {
    color: var(--danger-color);
}

.btn-danger-bg {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 32px;
    border-radius: var(--radius);
    width: 600px;
    max-width: 90%;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

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

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.875rem;
}

input,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
    height: 100px;
    resize: none;
}

.toggle-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toggle-group input {
    width: auto;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.hidden {
    display: none;
}

/* Responsive */

/* Mobile Top Bar - hidden by default */
.mobile-top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
}

.mobile-logo {
    font-weight: 700;
    color: var(--primary-color);
}

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 950;
}

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

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .app-container {
        grid-template-columns: 1fr;
        padding-top: 60px;
        /* Space for top bar */
    }

    .mobile-top-bar {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        bottom: 0;
        width: 320px;
        z-index: 1000;
        transition: transform 0.3s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.mobile-open {
        transform: translateX(320px);
    }

    .main-content {
        padding: 20px;
    }

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

    .total-card {
        padding: 15px;
    }

    .total-card .value {
        font-size: 1.25rem;
    }

    /* Table to Card Transformation */
    .session-section {
        padding: 15px;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid var(--border-color);
        margin-bottom: 15px;
        border-radius: var(--radius);
        padding: 10px;
        background: #fff;
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50% !important;
        text-align: right !important;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    td:last-child {
        border-bottom: none;
    }

    td:before {
        position: absolute;
        left: 12px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-muted);
        content: attr(data-label);
        font-size: 0.8rem;
    }

    /* Target specific columns for data labels */
    td:nth-of-type(1):before {
        content: "Date";
    }

    td:nth-of-type(2):before {
        content: "Début";
    }

    td:nth-of-type(3):before {
        content: "Fin";
    }

    td:nth-of-type(4):before {
        content: "Durée";
    }

    td:nth-of-type(5):before {
        content: "Matière";
    }

    td:nth-of-type(6):before {
        content: "Notes";
    }

    td:nth-of-type(7):before {
        content: "Statut";
    }

    td:nth-of-type(8):before {
        content: "Montant";
    }

    .session-note {
        text-align: right !important;
        font-style: italic;
        color: var(--text-muted);
    }

    /* Footer Responsive */
    .global-footer {
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
        padding: 20px 0;
    }

    .global-summary {
        flex-direction: column;
        gap: 10px;
    }

    .data-info {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .btn-secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .totals-grid {
        grid-template-columns: 1fr;
    }

    .student-info h2 {
        font-size: 1.5rem;
    }
}