/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f5f7fa;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* ─────────────────────────────────────────
   Mobile Header (caché par défaut, visible <768px)
───────────────────────────────────────── */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #2c3e50;
    color: white;
    padding: 12px 15px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    height: 56px;
}

.mobile-header .menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 5px 10px;
}

.mobile-logo h2 {
    font-size: 18px;
}

.mobile-user {
    font-size: 13px;
    color: #ecf0f1;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─────────────────────────────────────────
   Sidebar
   IMPORTANT : on anime avec `left`, jamais `transform`,
   car le sidebar-overlay est imbriqué DANS .sidebar
   (voir index.php) et `transform` sur le parent piège
   les enfants en position:fixed dans son propre repère.
───────────────────────────────────────── */
.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1050;
    transition: width 0.3s ease;
}

.sidebar-content {
    padding: 20px 0;
    position: relative;
    z-index: 2;
}

.sidebar-overlay {
    display: none;
}

.sidebar .logo {
    padding: 0 20px 30px;
    border-bottom: 1px solid #34495e;
}

.sidebar .logo h2 {
    font-size: 24px;
    font-weight: bold;
}

.sidebar .logo p {
    color: #95a5a6;
    font-size: 14px;
}

.sidebar nav a {
    display: block;
    padding: 12px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s;
    white-space: nowrap;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: #34495e;
    border-left: 4px solid #3498db;
}

.sidebar nav a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar nav a.logout-link {
    margin-top: 20px;
    border-top: 1px solid #34495e;
    padding-top: 20px;
}

/* Sidebar repliée (icônes seules, tablette) */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .logo h2,
.sidebar.collapsed .logo p,
.sidebar.collapsed nav a span {
    display: none;
}

.sidebar.collapsed nav a {
    text-align: center;
    padding: 15px;
}

.sidebar.collapsed nav a i {
    margin-right: 0;
}

/* ─────────────────────────────────────────
   Main Content
───────────────────────────────────────── */
.main-content {
    margin-left: 250px;
    flex: 1;
    padding: 20px;
    transition: margin-left 0.3s ease;
    width: 100%;
}

body:has(.sidebar.collapsed) .main-content {
    margin-left: 70px;
}

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle-desktop {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #2c3e50;
    padding: 5px;
    display: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    text-transform: uppercase;
    flex-shrink: 0;
}

.content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 10px;
}

/* Buttons */
.btn-primary {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-edit {
    background: #f39c12;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

.btn-delete {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
}

/* Table — scroll horizontal sur petit écran */
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.data-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Status Badge */
.status {
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.status.disponible { background: #27ae60; color: white; }
.status.occupé { background: #f39c12; color: white; }
.status.indisponible { background: #e74c3c; color: white; }
.status.en_attente { background: #95a5a6; color: white; }
.status.attribuée { background: #3498db; color: white; }
.status.en_cours { background: #f39c12; color: white; }
.status.terminée { background: #27ae60; color: white; }

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px; /* évite le zoom auto sur iOS */
}

.form-group textarea {
    resize: vertical;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal .close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
}

/* Alert */
.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f7fa;
    padding: 15px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.login-box h1 {
    text-align: center;
    color: #2c3e50;
}

.login-box h2 {
    text-align: center;
    color: #7f8c8d;
    font-weight: normal;
    margin: 10px 0 30px;
}

/* SMS */
.sms-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.contact-selection .checkbox-group {
    margin: 10px 0;
}

.contact-selection .checkbox-group.scrollable {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
}

.contact-selection .checkbox-group label {
    display: block;
    margin: 5px 0;
}

.char-count {
    text-align: right;
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 5px;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */

/* Tablette : sidebar repliable via bouton desktop */
@media (max-width: 992px) {
    .menu-toggle-desktop {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile : sidebar en panneau glissant + header mobile */
@media (max-width: 768px) {

    .mobile-header {
        display: flex;
    }

    .menu-toggle-desktop {
        display: none;
    }

    .sidebar {
        width: 260px;
        left: -260px; /* hors écran, animé via `left` et non `transform` */
        top: 0;
        padding-top: 56px;
        transition: left 0.3s ease;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar.collapsed {
        width: 260px; /* on annule le mode "icônes seules" sur mobile */
    }

    .sidebar.collapsed .logo h2,
    .sidebar.collapsed .logo p,
    .sidebar.collapsed nav a span {
        display: block;
    }

    .sidebar.collapsed nav a {
        text-align: left;
        padding: 12px 20px;
    }

    .sidebar.collapsed nav a i {
        margin-right: 10px;
    }

    /* Overlay : imbriqué dans .sidebar, mais comme .sidebar n'utilise
       plus `transform`, il reste bien fixé à la fenêtre entière */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.45);
        z-index: 1;
    }

    .sidebar.active .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px;
        padding-top: 70px;
    }

    header {
        display: none;
    }

    .content {
        padding: 15px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header .btn-primary {
        width: 100%;
        text-align: center;
    }

    .sms-container {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 20px;
    }

    /* Dashboard : cards moins coincées */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card {
        padding: 18px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 600px) and (min-width: 481px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .mobile-logo h2 {
        font-size: 16px;
    }

    .mobile-user {
        max-width: 70px;
        font-size: 11px;
    }

    .login-box {
        padding: 25px;
    }

    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 10px;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 20px;
        margin-right: 0;
    }

    .stat-info h3 {
        font-size: 20px;
    }
}