/* ============================================
   HSchool - Application de gestion scolaire
   Feuille de style principale
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #0f172a;
    --success: #16a34a;
    --success-light: #dcfce7;
    --info: #0891b2;
    --info-light: #cffafe;
    --warning: #ca8a04;
    --warning-light: #fef9c3;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --light: #f8fafc;
    --gray: #64748b;
    --gray-light: #e2e8f0;
    --border: #cbd5e1;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--light);
    color: var(--secondary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--primary);
}

a:hover {
    text-decoration: underline;
}

/* ============================================
   PAGE DE CONNEXION
   ============================================ */
.login-page {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 30px 25px;
    text-align: center;
}

.login-header .logo {
    width: 70px;
    height: 70px;
    background: var(--white);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 32px;
    font-weight: bold;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-header p {
    opacity: 0.9;
    font-size: 14px;
}

.login-form {
    padding: 30px 25px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control:disabled {
    background: var(--light);
    cursor: not-allowed;
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-family: inherit;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

.btn-success { background: var(--success); color: var(--white); }
.btn-danger  { background: var(--danger);  color: var(--white); }
.btn-warning { background: var(--warning); color: var(--white); }
.btn-info    { background: var(--info);    color: var(--white); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-block { display: block; width: 100%; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--secondary);
}
.btn-outline:hover { background: var(--light); }

/* ============================================
    MISE EN PAGE - HEADER + SIDEBAR
    ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--secondary);
    color: var(--white);
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    margin-bottom: 3px;
}

.sidebar-header p {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-menu {
    padding: 10px 0;
}

/* Style pour les items de menu normaux (non-toggle) */
.sidebar-menu .menu-item {
    margin: 0;
}

.sidebar-menu .menu-item a.menu-link,
.sidebar-menu .menu-toggle-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    border-right: none;
    border-top: none;
    border-bottom: none;
    font-size: 14px;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    outline: none;
}

.sidebar-menu .menu-item a.menu-link:hover,
.sidebar-menu .menu-toggle-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--white);
    text-decoration: none;
}

.sidebar-menu .menu-item a.menu-link.active,
.sidebar-menu .menu-toggle-btn.active {
    background: rgba(37, 99, 235, 0.2);
    border-left-color: var(--primary);
    color: var(--white);
}

.sidebar-menu .menu-item a.menu-link .icon,
.sidebar-menu .menu-toggle-btn .icon {
    width: 24px;
    margin-right: 12px;
    text-align: center;
    font-size: 16px;
}

/* Sections de menu déroulants */
.sidebar-menu .menu-section {
    margin: 0;
}

.sidebar-menu .menu-section .menu-toggle-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    border-right: none;
    border-top: none;
    border-bottom: none;
    font-size: 14px;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.sidebar-menu .menu-section .menu-toggle-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--white);
}

.sidebar-menu .menu-section .menu-toggle-btn .arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.3s ease;
    color: rgba(255,255,255,0.4);
}

.sidebar-menu .menu-section .menu-toggle-btn.open .arrow {
    transform: rotate(180deg);
}

/* Sous-menus */
.sidebar-menu .submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 0;
    background: rgba(0,0,0,0.15);
}

.sidebar-menu .submenu.open {
    max-height: 500px;
    opacity: 1;
}

.sidebar-menu .submenu li a {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 54px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.sidebar-menu .submenu li a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
    text-decoration: none;
}

.sidebar-menu .submenu li a.active {
    background: rgba(37, 99, 235, 0.15);
    border-left-color: var(--primary);
    color: var(--white);
}

/* Menu mobile */
.menu-toggle-mobile {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary);
    padding: 0;
    margin-right: 15px;
    line-height: 1;
}

@media (max-width: 768px) {
    .menu-toggle-mobile {
        display: inline-block;
    }
}

.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: var(--white);
    padding: 12px 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar-title h1 {
    font-size: 18px;
    color: var(--secondary);
}

.top-bar-title p {
    font-size: 12px;
    color: var(--gray);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu .user-info {
    text-align: right;
}

.user-menu .user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
}

.user-menu .user-info .role {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}

.content {
    padding: 25px;
    flex: 1;
}

/* ============================================
   COMPOSANTS UI
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 22px;
    color: var(--secondary);
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--gray);
    margin-top: 3px;
}

.card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-light);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--secondary);
}

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--white);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.info    { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.info .stat-icon    { background: var(--info-light);    color: var(--info); }
.stat-card.warning .stat-icon { background: var(--warning-light); color: var(--warning); }
.stat-card.danger .stat-icon  { background: var(--danger-light);  color: var(--danger); }

.stat-info h3 {
    font-size: 13px;
    color: var(--gray);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-info .value {
    font-size: 26px;
    font-weight: bold;
    color: var(--secondary);
    margin-top: 3px;
}

/* Tableaux */
.table-responsive {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

table.data-table th,
table.data-table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-light);
    font-size: 13px;
}

table.data-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.3px;
}

table.data-table tr:hover {
    background: var(--primary-light);
}

table.data-table td.actions {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--gray-light); color: var(--gray); }

/* Alertes */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    border-left: 4px solid;
    font-size: 14px;
}

.alert-success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-color: var(--info); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger); }

/* Boutons d'action */
.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

/* Filtres */
.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    align-items: end;
}

.filters .form-group {
    margin-bottom: 0;
    min-width: 180px;
    flex: 1;
}

/* Bulletin */
.bulletin-container {
    background: var(--white);
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-width: 900px;
    margin: 0 auto;
}

.bulletin-header {
    text-align: center;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.bulletin-header h1 {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 5px;
}

.bulletin-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 25px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
}

.bulletin-info div {
    font-size: 13px;
}

.bulletin-info strong {
    color: var(--secondary);
}

.bulletin-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.bulletin-table th,
.bulletin-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: center;
    font-size: 13px;
}

.bulletin-table th {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
}

.bulletin-table td.matiere {
    text-align: left;
    font-weight: 500;
}

.bulletin-table tfoot td {
    background: var(--light);
    font-weight: bold;
}

.bulletin-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
    text-align: center;
    font-size: 13px;
}

.bulletin-footer div {
    padding-top: 60px;
    border-top: 1px solid var(--secondary);
    font-weight: 500;
}

/* Modal (simple) */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: 10px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray);
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: var(--secondary);
}

.modal-body {
    padding: 20px 25px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Saisie de notes */
.notes-table {
    width: 100%;
    border-collapse: collapse;
}

.notes-table th,
.notes-table td {
    padding: 8px;
    border: 1px solid var(--gray-light);
    text-align: center;
    font-size: 13px;
}

.notes-table th {
    background: var(--light);
    font-weight: 600;
}

.notes-table input.notes-input {
    width: 70px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.notes-table input.notes-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Impression bulletin */
@media print {
    .sidebar, .top-bar, .no-print { display: none !important; }
    .main-content { margin-left: 0; }
    .content { padding: 0; }
    .bulletin-container { box-shadow: none; max-width: 100%; }
    body { background: white; }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .filters { flex-direction: column; }
    .filters .form-group { min-width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .bulletin-info { grid-template-columns: 1fr; }
    .bulletin-footer { grid-template-columns: 1fr; }
}

/* Utilitaires */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-bold { font-weight: 600; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.4;
}

/* ============================================
   CLÔTURE DE JOURNÉE
   ============================================ */
.summary-hero {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.summary-hero .total-amount {
    font-size: 3em;
    font-weight: 800;
    color: var(--white);
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.summary-hero .total-label {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
    margin-top: 8px;
    font-weight: 500;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.summary-item {
    background: var(--white);
    padding: 18px 14px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid var(--gray-light);
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.summary-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.summary-item .summary-value {
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 4px;
}

.summary-item .summary-label {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.summary-item.blue {
    border-color: var(--info);
    background: linear-gradient(135deg, #ffffff 0%, var(--info-light) 100%);
}
.summary-item.blue .summary-value { color: var(--info); }

.summary-item.green {
    border-color: var(--success);
    background: linear-gradient(135deg, #ffffff 0%, var(--success-light) 100%);
}
.summary-item.green .summary-value { color: var(--success); }

.summary-item.primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-light) 100%);
}
.summary-item.primary .summary-value { color: var(--primary); }

.summary-item.warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, #ffffff 0%, var(--warning-light) 100%);
}
.summary-item.warning .summary-value { color: var(--warning); }

.cloture-actions {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.cloture-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-badge.closed {
    background: var(--success);
    color: var(--white);
    animation: pulse 2s infinite;
}

.status-badge.open {
    background: var(--gray);
    color: var(--white);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.table-total-row {
    background: var(--light) !important;
    font-weight: 700;
}

.table-total-row td {
    border-top: 2px solid var(--border) !important;
    padding: 12px !important;
}
