/* ============================================================
   main.css — Variables, reset, layout global
   CrèchePlanning v1.0
   ============================================================ */

:root {
    /* Couleurs principales */
    --color-primary:     #1e3a5f;
    --color-primary-light: #2d5a8e;
    --color-accent:      #3b82f6;
    --color-success:     #22c55e;
    --color-warning:     #eab308;
    --color-danger:      #ef4444;
    --color-info:        #3b82f6;

    /* Statuts planning */
    --color-present:     #22c55e;
    --color-pause:       #eab308;
    --color-absent:      #e5e7eb;
    --color-sp:          #3b82f6;
    --color-ho:          #f97316;
    --color-cg:          #374151;
    --color-reunion:     #8b5cf6;
    --color-alerte:      #ef4444;

    /* Neutres */
    --color-bg:          #f8fafc;
    --color-surface:     #ffffff;
    --color-border:      #e2e8f0;
    --color-text:        #1e293b;
    --color-text-muted:  #64748b;

    /* Dimensions */
    --header-height:     64px;
    --sidebar-width:     300px;
    --border-radius:     8px;
    --border-radius-sm:  4px;
    --shadow:            0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:         0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg:         0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.app-header {
    height: var(--header-height);
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-icon {
    font-size: 1.75rem;
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.header-brand p {
    font-size: 0.75rem;
    opacity: 0.8;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.5rem 0.875rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* ---- Layout principal ---- */
.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title-row h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---- Boutons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--color-accent);   color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #f1f5f9; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success   { background: var(--color-success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-danger    { background: var(--color-danger);  color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.3rem 0.625rem; font-size: 0.8rem; }
.btn-filter { background: #f1f5f9; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-filter.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* ---- Semaine navigation ---- */
.week-nav-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.week-badge {
    background: var(--color-primary);
    color: white;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 0.625rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.tab-btn:hover { color: var(--color-primary); background: #f8fafc; }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    color: var(--color-text);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.75rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.modal p { margin-bottom: 0.75rem; color: var(--color-text-muted); font-size: 0.9rem; }

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    justify-content: flex-end;
}

/* ---- Tables admin ---- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    font-size: 0.875rem;
}

.admin-table thead tr {
    background: var(--color-primary);
    color: white;
}

.admin-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.admin-table tbody tr:hover { background: #f8fafc; }
.admin-table tbody tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-cat1 { background: #dcfce7; color: #166534; }
.badge-cat2 { background: #fef3c7; color: #92400e; }
.badge-reg  { background: #dbeafe; color: #1e40af; }
.badge-occ  { background: #f3e8ff; color: #6b21a8; }

/* ---- Section titles ---- */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin: 1.25rem 0 0.5rem 0;
    padding-bottom: 0.375rem;
    border-bottom: 2px solid var(--color-border);
}

/* ---- KPI Dashboard ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.375rem;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.kpi-success { color: var(--color-success); }
.kpi-warning { color: var(--color-warning); }
.kpi-danger  { color: var(--color-danger); }

/* ---- Dashboard sections ---- */
.dashboard-section {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.dashboard-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.chart-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

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

/* ---- Table heures ---- */
.table-heures {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table-heures th {
    background: #f1f5f9;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
}

.table-heures td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.status-ok    { color: var(--color-success); font-weight: 600; }
.status-over  { color: var(--color-warning); font-weight: 600; }
.status-under { color: var(--color-text-muted); }

.progress-bar {
    background: #e5e7eb;
    border-radius: 4px;
    height: 8px;
    width: 120px;
    overflow: hidden;
}

.progress-fill {
    background: var(--color-success);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* ---- Welcome page ---- */
.welcome-section {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.welcome-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 900px;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.welcome-card h2 {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.welcome-card > p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

.week-selector-card {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.week-selector-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.week-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.week-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
}

.week-label {
    font-weight: 600;
    color: var(--color-primary);
    font-size: 0.9rem;
}

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

.action-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--color-text);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    background: white;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent);
}

.action-icon { font-size: 2rem; }

.action-card strong { display: block; font-size: 0.9rem; margin-bottom: 0.2rem; }
.action-card p { font-size: 0.8rem; color: var(--color-text-muted); margin: 0; }

.action-enfants:hover   { border-color: var(--color-success); }
.action-equipe:hover    { border-color: var(--color-accent); }
.action-dashboard:hover { border-color: var(--color-warning); }

/* ---- Info section ---- */
.info-section { margin-bottom: 1.5rem; }

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

.info-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.info-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.info-card ul {
    list-style: none;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.info-card ul li {
    padding: 0.25rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.info-card ul li:last-child { border-bottom: none; }
.info-card ul li::before { content: "▸ "; color: var(--color-accent); }

.legend-grid {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 0.375rem 0.5rem;
    align-items: center;
    font-size: 0.85rem;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    font-family: monospace;
}

/* ---- Footer ---- */
.app-footer {
    background: var(--color-primary);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 0.75rem;
    font-size: 0.8rem;
    margin-top: auto;
}

/* ---- Toast notifications ---- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    max-width: 350px;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--color-accent);
}

.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

/* ---- Misc ---- */
.loading { color: var(--color-text-muted); font-style: italic; padding: 1rem; }
.empty-state { color: var(--color-text-muted); text-align: center; padding: 2rem; font-style: italic; }
.save-status { font-size: 0.8rem; color: var(--color-text-muted); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-header { flex-direction: column; height: auto; padding: 0.75rem; gap: 0.5rem; }
    .header-nav { flex-wrap: wrap; justify-content: center; }
    .main-content { padding: 1rem; }
    .page-header { flex-direction: column; }
    .week-nav { flex-direction: column; }
    .quick-actions { grid-template-columns: 1fr; }
}

@media print {
    .app-header, .app-footer, .page-actions, .tabs, .sticky-counter { display: none !important; }
    .main-content { padding: 0; }
    body { background: white; }
}
