/* css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Playfair+Display:wght@600&display=swap');

:root {
    --primary: #1a4fa0;
    --primary-light: #2563eb;
    --primary-dark: #0f2d5e;
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 10px;
    --radius-lg: 16px;
    --sidebar-w: 260px;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

/* ---- LOGIN ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    position: relative;
    overflow: hidden;
}

    .login-page::before {
        content: '';
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: url('../logos/logo.png') no-repeat center center;
        background-size: contain;
        opacity: 0.07;
        width: 800px;
        height: 800px;
        pointer-events: none;
        z-index: 0;
    }

    .login-page::after {
        content: '';
        position: fixed;
        width: 500px;
        height: 500px;
        border-radius: 50%;
        background: rgba(26, 79, 160, 0.06);
        top: -150px;
        right: -150px;
        pointer-events: none;
        z-index: 0;
    }

.login-circle-bottom {
    position: fixed;
    width: 350px;
    height: 350px;
    border-radius: 50%;
    background: rgba(26, 79, 160, 0.05);
    bottom: -100px;
    left: -100px;
    pointer-events: none;
    z-index: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 430px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    position: relative;
    z-index: 1;
    text-align: center;
    animation: loginFadeIn 0.5s ease forwards;
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

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

.login-school-logo {
    display: block;
    margin: 0 auto 1.25rem auto;
    max-width: 280px;
    height: auto;
}

.login-logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(26, 79, 160, 0.3);
}

.login-school-name {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-school-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.login-divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.login-form-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.login-card .form-group {
    text-align: left;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    box-shadow: 0 4px 15px rgba(26, 79, 160, 0.3);
}

    .btn-login:hover {
        background: linear-gradient(135deg, var(--primary-dark), var(--primary));
        box-shadow: 0 6px 20px rgba(26, 79, 160, 0.4);
        transform: translateY(-1px);
    }

    .btn-login:active {
        transform: translateY(0);
    }

/* ---- LAYOUT ---- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-logo-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .sidebar-logo-icon img.sidebar-logo {
        max-width: 90%;
        max-height: 90%;
        object-fit: contain;
        display: block;
    }

.sidebar-header h2 {
    font-size: 20px;
    margin: 0;
    color: #fff;
    line-height: 1.2;
}

.sidebar-header span {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    line-height: 1.1;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    padding: 0.75rem 1.5rem 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 1.5rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

    .nav-item:hover {
        background: rgba(255,255,255,0.08);
        color: #fff;
        border-left-color: rgba(255,255,255,0.3);
    }

    .nav-item.active {
        background: rgba(255,255,255,0.12);
        color: #fff;
        border-left-color: var(--accent);
    }

    .nav-item .icon {
        font-size: 20px;
        width: 20px;
        flex-shrink: 0;
    }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.5rem 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    color: #fff;
    font-weight: 500;
    flex: 1;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    margin-top: 4px;
    transition: all 0.2s;
}

    .btn-logout:hover {
        color: #fff;
        background: rgba(255,255,255,0.08);
    }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-content {
    padding: 2rem;
    flex: 1;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 1.5rem;
}

/* ---- STATS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

    .stat-icon.blue {
        background: #dbeafe;
    }

    .stat-icon.green {
        background: var(--success-light);
    }

    .stat-icon.amber {
        background: var(--accent-light);
    }

    .stat-icon.red {
        background: var(--danger-light);
    }

.stat-info label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info .val {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

/* ---- FORMS ---- */
.form-section {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .form-group.full {
        grid-column: 1 / -1;
    }

.moyenne-inline {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px;
}

    .moyenne-inline input {
        border: 1px solid #ccc !important;
        background-color: #fff;
        color: #333;
        padding: 10px;
        border-radius: 6px;
        font-size: 14px;
        outline: none;
    }

        .moyenne-inline input:focus {
            border-color: #4CAF50;
        }

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"], input[type="date"], input[type="password"],
input[type="tel"], input[type="email"], select, textarea {
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

    input:focus, select:focus, textarea:focus {
        outline: none;
        border-color: var(--primary-light);
        box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    }

textarea {
    resize: vertical;
    min-height: 70px;
}

/* ---- PHONE ROWS ---- */
.phones-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.phone-row {
    display: grid;
    grid-template-columns: 1fr 130px auto auto;
    gap: 8px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
}

.whatsapp-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #128C7E;
    font-weight: 500;
    white-space: nowrap;
}

    .whatsapp-badge input[type="checkbox"] {
        accent-color: #128C7E;
        width: 15px;
        height: 15px;
        cursor: pointer;
    }

.btn-del-phone {
    width: 30px;
    height: 30px;
    background: var(--danger-light);
    border: none;
    border-radius: 6px;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

    .btn-del-phone:hover {
        background: #fecaca;
    }

.btn-add-phone {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin-top: 4px;
}

    .btn-add-phone:hover {
        border-color: var(--primary-light);
        color: var(--primary);
        background: #eff6ff;
    }

/* ---- FRATRIE ROWS ---- */
.fratrie-row {
    display: grid;
    grid-template-columns: 1fr 1fr 130px 90px auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 8px;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

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

    .btn-primary:hover {
        background: var(--primary-dark);
        box-shadow: 0 4px 12px rgba(26,79,160,0.3);
    }

.btn-success {
    background: var(--success);
    color: #fff;
}

    .btn-success:hover {
        background: #047857;
    }

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

    .btn-danger:hover {
        background: #b91c1c;
    }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 7px;
    border-radius: 8px;
}

/* ---- TABLE ---- */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

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

tbody tr:hover {
    background: #f8fafc;
}

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-sec {
    background: var(--success-light);
    color: #065f46;
}

.badge-active {
    background: var(--success-light);
    color: #065f46;
}

.badge-inactive {
    background: #f1f5f9;
    color: var(--text-muted);
}

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ---- SEARCH ---- */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.search-input {
    flex: 1;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}

    .search-input:focus {
        outline: none;
        border-color: var(--primary-light);
    }

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

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

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

    .page-content {
        padding: 1rem;
    }

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

    /* Phone row mobile — 2 lignes */
    .phone-row {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        padding: 8px;
    }

        .phone-row input[type="tel"] {
            grid-column: 1;
            grid-row: 1;
        }

        .phone-row .btn-del-phone {
            grid-column: 2;
            grid-row: 1;
        }

        .phone-row .label-input {
            grid-column: 1;
            grid-row: 2;
        }

        .phone-row .whatsapp-badge {
            grid-column: 2;
            grid-row: 2;
            justify-self: end;
        }

    /* Fratrie row mobile — grille 2 colonnes */
    .fratrie-row {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto auto;
    }

        .fratrie-row > .form-group:nth-child(1) {
            grid-column: 1 / -1;
        }

        .fratrie-row > .form-group:nth-child(2) {
            grid-column: 1 / -1;
        }

        .fratrie-row > .form-group:nth-child(3) {
            grid-column: 1;
        }

        .fratrie-row > .form-group:nth-child(4) {
            grid-column: 2;
        }

        .fratrie-row > .btn-del-phone {
            grid-column: 1 / -1;
            width: 100%;
            height: 34px;
            border-radius: 6px;
        }

    /* Topbar */
    .topbar {
        padding: 0 1rem;
    }

    .topbar-right {
        gap: 0.5rem;
    }
}

/* ---- MISC ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

    .page-header h1 {
        font-size: 20px;
        font-weight: 700;
        color: var(--text);
    }

.whatsapp-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #128C7E;
    font-size: 13px;
    text-decoration: none;
}

    .whatsapp-link:hover {
        text-decoration: underline;
    }

.phone-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phone-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.wa-icon {
    font-size: 14px;
}

.eleve-name {
    font-weight: 600;
    color: var(--text);
}

.eleve-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

    .empty-state .icon {
        font-size: 48px;
        margin-bottom: 1rem;
    }

    .empty-state h3 {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.page-link {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

    .page-link:hover, .page-link.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }
