/* ============================================================
   THEME "CAHIER D'ECOLE"
   Feuille chargee en DERNIER (apres admin-style.css / style.css)
   pour surcharger les styles par defaut.
   Encres : rouge cahier + lignes seyes bleues.
   ============================================================ */

.cahier-ink-red { --ink: #c0392b; }

:root, [data-theme="light"] {
    --ink: #c0392b;
    --paper: #f7f4ec;
    --paper-white: #fffdf7;
    --line-clear: #e9dfc7;
    --line-rule: rgba(37, 99, 235, 0.07);
    --seye: rgba(46, 95, 225, 0.28);
}

[data-theme="dark"] {
    --ink: #e06c60;
    --paper: #0f1722;
    --paper-white: #16202e;
    --line-clear: #293548;
    --line-rule: rgba(148, 180, 255, 0.06);
    --seye: rgba(120, 150, 235, 0.18);
}

/* ------------------------------------------------------------------
   Arriere-plan "feuille reylee" (marges rouges invisibles derriere
   les cartes, lignes seyes horizontales du cahier).
------------------------------------------------------------------ */
.admin-content {
    background-color: var(--paper);
    background-image:
        linear-gradient(var(--line-rule) 1px, transparent 1px);
    background-size: 100% 32px;
}

/* ------------------------------------------------------------------
   Cartes / feuilles : marge rouge a gauche + coins volontairement
   irreguliers + ligne de regle sous le titre.
------------------------------------------------------------------ */
.panel,
.table-wrapper,
.kpi-card,
.card,
.login-card {
    position: relative;
    background-color: var(--paper-white);
    border: 1px solid var(--line-clear);
    border-radius: 5px 16px 5px 16px;
    box-shadow: 3px 4px 0 rgba(60, 50, 20, 0.05);
}

.panel:hover,
.table-wrapper:hover {
    border-color: rgba(192, 57, 43, 0.35);
    box-shadow: 5px 6px 0 rgba(60, 50, 20, 0.06);
}

.panel::before,
.table-wrapper::before,
.kpi-card::before,
.card::before,
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 6px;
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--ink), transparent 85%);
    opacity: 0.85;
    pointer-events: none;
}

/* Certains panneaux ont un padding-left inline de 12 a 16px : la marge
   rouge doit rester dans la gouttiere et ne jamais mordre sur le contenu. */
.kpi-card { padding-left: 1.55rem; }
.panel { padding-left: 1.75rem; }
.table-wrapper { position: relative; }

/* ------------------------------------------------------------------
   Titres de panneaux : petit losange d'encre + trait pointille.
------------------------------------------------------------------ */
.panel-title {
    border-bottom: 1px dashed rgba(192, 57, 43, 0.4);
}

.panel-title::before {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--ink);
    transform: rotate(45deg) translateY(1px);
}

.table-header {
    border-bottom: 1px dashed rgba(192, 57, 43, 0.4);
    background: linear-gradient(180deg, var(--paper-white) 0%, var(--paper) 100%);
}

/* ------------------------------------------------------------------
   Tableaux : en-tete souligne d'encre, lignes pointillees, zebrure
   tres legere (lignes du cahier).
------------------------------------------------------------------ */
table thead th {
    background: var(--paper);
    color: var(--ink);
    font-size: 0.72rem;
    border-top: 3px solid rgba(192, 57, 43, 0.55);
    border-bottom: 1px solid rgba(192, 57, 43, 0.4);
    letter-spacing: 0.08em;
}

table th,
table td {
    border-bottom: 1px dotted var(--line-rule);
}

tbody tr:nth-child(even) {
    background: rgba(46, 95, 225, 0.04);
}

tbody tr:hover {
    background: rgba(192, 57, 43, 0.05);
}

/* ------------------------------------------------------------------
   Champs de saisie : encre bleue -> trait noir feu, focus rouge.
------------------------------------------------------------------ */
.form-control,
[class*="form-"] input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    border: 1.5px solid #cfc6ae;
    border-radius: 5px;
    background-color: var(--paper-white);
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.14);
    outline: none;
}

/* ------------------------------------------------------------------
   Boutons : coins nets, leger relief "papier".
------------------------------------------------------------------ */
.btn {
    border-radius: 6px;
}

.btn-primary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-info {
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.btn-primary:hover,
.btn-success:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-info:hover {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

/* ------------------------------------------------------------------
   Sidebar : entree active avec trait rouge "souligne au stylo".
------------------------------------------------------------------ */
.sidebar-nav li a {
    border-bottom: 1px dotted rgba(255, 255, 255, 0.06);
    border-radius: 0;
    padding-left: 1.25rem;
}

.sidebar-nav li a.active,
.sidebar-nav li a.active:hover {
    background: rgba(192, 57, 43, 0.16);
    box-shadow: inset 3px 0 0 var(--ink);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-section {
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 1rem;
}

.sidebar-brand {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

.sidebar-brand::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 0.5rem;
    border-radius: 50%;
    background: var(--ink);
}

/* ------------------------------------------------------------------
   En-tetes de pages publiques : trait d'encre sous le titre.
------------------------------------------------------------------ */
.page-header {
    border-bottom: 1px dashed rgba(192, 57, 43, 0.4);
}

.page-header h1::after {
    content: '';
    display: block;
    width: 3.5rem;
    height: 3px;
    margin-top: 0.4rem;
    border-radius: 2px;
    background: var(--ink);
    opacity: 0.7;
}

/* ------------------------------------------------------------------
   Alertes : coins irreguliers + liseres stylo.
------------------------------------------------------------------ */
.alert {
    border-radius: 4px 12px 4px 12px;
    border-width: 1px;
    border-left-width: 5px;
}

/* ------------------------------------------------------------------
   Icones SVG de l'interface (dessinees au trait, meme graisse).
------------------------------------------------------------------ */
.cahier-icon {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.sidebar-nav li a .cahier-icon {
    display: inline-block;
    color: var(--sidebar-active);
    margin-right: 0.6rem;
    transition: color var(--transition);
}

.sidebar-nav li a:hover .cahier-icon,
.sidebar-nav li a.active .cahier-icon {
    color: var(--ink);
}

.kpi-icon .cahier-icon {
    width: 1.35em;
    height: 1.35em;
}

.theme-toggle-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.panel-title .cahier-icon,
.table-header h2 .cahier-icon {
    color: var(--ink);
    margin-right: 0.35rem;
}

/* ------------------------------------------------------------------
   Badges de context (dates de saisie) : pastille encre au lieu d'emoji.
------------------------------------------------------------------ */
.context-badge::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0 2px, var(--ink) 2px);
    box-shadow: 0 0 0 1px rgba(192, 57, 43, 0.35);
}

/* ------------------------------------------------------------------
   Variantes sombres
------------------------------------------------------------------ */
[data-theme="dark"] .panel,
[data-theme="dark"] .table-wrapper,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .card,
[data-theme="dark"] .login-card {
    box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] table thead th {
    background: var(--paper-white);
    border-top-color: rgba(224, 108, 96, 0.5);
}

[data-theme="dark"] tbody tr:nth-child(even) {
    background: rgba(140, 160, 235, 0.05);
}