/* FICHIER STYLE RÉVISÉ - SAINT DENIS TIMES 1899 */
/* Structure conservée : 642 lignes */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=Special+Elite&display=swap');
@font-face {
    font-family: 'Chomsky';
    src: url('/assets/fonts/Chomsky.otf') format('opentype');
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    /* Police Serif pour l'élégance ancienne */
    font-family: 'Playfair Display', Georgia, serif; 
    background: #1a120b url("https://www.transparenttextures.com/patterns/dark-leather.png");
    color: #2c1e14; /* Encre sépia */
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-page {
    min-height: 100vh;
    /* Fond cuir sombre et texturé */
    background: #1a120b url("https://www.transparenttextures.com/patterns/dark-leather.png");
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.auth-wrapper {
    width: 100%;
    max-width: 520px;
}

.auth-card {
    /* Texture papier parchemin épais */
    background: #e8dcc4 url("https://www.transparenttextures.com/patterns/old-map.png");
    color: #24180f;
    /* Bordure type couverture de livre relié */
    border: 10px solid #3d2b1f;
    border-image: url("https://www.transparenttextures.com/patterns/dark-wood.png") 30 round;
    box-shadow: 0 25px 60px rgba(0,0,0,0.8);
    padding: 32px;
    border-radius: 4px;
}

.auth-card h1 {
    margin: 0 0 8px 0;
    text-align: center;
    font-size: 38px;
    text-transform: uppercase;
    letter-spacing: -1px;
    font-family: 'Playfair Display', serif;
}

.subtitle {
    text-align: center;
    margin: 0 0 20px 0;
    font-style: italic;
    opacity: 0.8;
}

.auth-seal {
    text-align: center;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 14px;
    /* Rouge sceau de cire */
    color: #8b0000; 
    font-weight: bold;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form input,
.ledger-form input,
.ledger-form select,
.ledger-form textarea {
    width: 100%;
    padding: 12px 14px;
    /* Bordure fine comme un trait d'encre */
    border: 1px solid #2c1e14;
    background: rgba(255, 255, 255, 0.2);
    color: #1a120b;
    font-size: 16px;
    border-radius: 0;
    font-family: 'Special Elite', cursive; /* Look dactylo pour les formulaires */
    outline: none;
}

.auth-form button,
.ledger-form button,
.action-btn {
    display: inline-block;
    padding: 12px 18px;
    /* Couleur Rouge Bordeaux d'époque */
    background: #5a0000;
    color: #f2e7cf;
    border: 2px solid #2c1e14;
    border-radius: 0;
    font-weight: bold;
    font-family: 'Playfair Display', serif;
    text-transform: uppercase;
    cursor: pointer;
    transition: 0.2s ease;
    box-shadow: 2px 2px 0px #000;
}

.auth-form button:hover,
.ledger-form button:hover,
.action-btn:hover {
    background: #8b0000;
    transform: translate(-1px, -1px);
}

.alert-error {
    background: #4a0000;
    color: #f2e7cf;
    padding: 12px;
    border-radius: 0;
    margin-bottom: 16px;
    border: 1px solid #000;
    text-align: center;
    font-family: 'Special Elite', cursive;
}

.topbar {
    /* Bandeau bois sombre */
    background: #2c1e14 url("https://www.transparenttextures.com/patterns/dark-wood.png");
    border-bottom: 5px solid #8b0000;
    padding: 20px 30px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.6);
}

.topbar h1 {
    margin: 0;
    font-size: 64px;
    color: #e8dcc4;
    font-family: 'Chomsky', serif;
    letter-spacing: -1px;
    -webkit-font-smoothing: antialiased;
    text-shadow: 0.5px 0.5px 0px rgba(0,0,0,0.2);
}

.topbar p {
    margin: 6px 0 0;
    color: #a89178;
    font-style: italic;
}

.topnav {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topnav a {
    padding: 10px 14px;
    background: #3d2b1f;
    border: 1px solid #2c1e14;
    border-radius: 0;
    color: #d9c3a0;
    font-size: 13px;
    font-family: 'Special Elite', cursive;
}

.topnav a:hover {
    background: #8b0000;
    color: #fff;
}

.main-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.page-title-block {
    margin-bottom: 24px;
    /* Papier journal jauni */
    background: #d7bc8e url("https://www.transparenttextures.com/patterns/cream-paper.png");
    color: #24170f;
    padding: 18px 22px;
    border-left: 10px solid #5a0000;
    border-radius: 0;
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.page-title-block h2 {
    margin: 0 0 8px 0;
    font-size: 30px;
    text-transform: uppercase;
}

.page-title-block p {
    margin: 0;
    font-style: italic;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.info-card {
    /* Étiquette de bureau ancienne */
    background: #f4ece1;
    color: #2e1f14;
    padding: 22px;
    border: 1px solid #a89178;
    border-bottom: 5px solid #8b6a43;
    border-radius: 0;
    box-shadow: 3px 3px 12px rgba(0,0,0,0.1);
}

.info-card h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    text-transform: uppercase;
    border-bottom: 1px solid #2c1e14;
}

.big-number {
    font-size: 30px;
    font-weight: bold;
    font-family: 'Special Elite', cursive; /* Chiffres style dactylo */
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.panel {
    background: #e8dcc4;
    color: #25190f;
    border: 1px solid #2c1e14;
    border-radius: 0;
    padding: 22px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.05);
}

.panel h3 {
    margin-top: 0;
    font-family: 'Playfair Display', serif;
    border-bottom: 2px solid #2c1e14;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.action-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    color: #24170f;
    border-radius: 0;
}

.ledger-table th {
    background: #2c1e14;
    color: #e8dcc4;
    padding: 12px;
    text-align: left;
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    text-transform: uppercase;
}

.ledger-table td {
    padding: 12px;
    border-bottom: 1px solid #2c1e14;
    font-family: 'Special Elite', cursive; /* Données style tampon */
    font-size: 14px;
}

.ledger-table tr:nth-child(even) td {
    background: rgba(0,0,0,0.04);
}

.form-panel {
    max-width: 700px;
}

.ledger-form {
    display: grid;
    gap: 14px;
}

.ledger-form label {
    font-weight: bold;
    color: #2c1e14;
    text-transform: uppercase;
    font-size: 12px;
}

@media (max-width: 900px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }

    .panel-head {
        flex-direction: column;
        align-items: flex-start;
    }
}

.table-link {
    /* Bleu encre ancienne */
    color: #003366; 
    font-weight: bold;
    text-decoration: underline;
}

.table-link:hover {
    color: #8b0000;
}

.sale-items-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.sale-items-head {
    font-weight: bold;
    color: #2c1e14;
    margin-top: 8px;
    text-transform: uppercase;
    font-size: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 800px) {
    .sale-items-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.status-paid {
    color: #1f5e2f;
    font-weight: bold;
    font-style: italic;
}

.status-unpaid {
    color: #8b0000;
    font-weight: bold;
    text-decoration: line-through;
}

.table-link {
    color: #003366;
    font-weight: bold;
}

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

.sale-items-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.sale-items-head {
    font-weight: bold;
    color: #2c1e14;
    margin-top: 8px;
}

@media (max-width: 800px) {
    .sale-items-grid {
        grid-template-columns: 1fr;
    }
}

.form-panel-wide {
    max-width: 1100px;
}

.sale-pro-grid {
    display: grid;
    grid-template-columns: 2fr 100px 1.2fr 1.5fr;
    gap: 10px;
    margin-bottom: 10px;
}

.sale-pro-head {
    font-weight: bold;
    color: #2c1e14;
    margin-top: 8px;
    text-transform: uppercase;
}

@media (max-width: 950px) {
    .sale-pro-grid {
        grid-template-columns: 1fr;
    }
}

.table-link-danger {
    color: #8b0000;
    font-weight: bold;
}

.table-link-danger:hover {
    color: #b22222;
    text-decoration: underline;
}

.sale-top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.sale-total-box {
    background: #f7ecd6;
    border: 2px solid #2c1e14;
    border-radius: 0;
    padding: 18px;
    text-align: center;
    margin: 10px 0 20px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.sale-total-label {
    font-size: 16px;
    color: #5a341d;
    margin-bottom: 8px;
    font-weight: bold;
    text-transform: uppercase;
}

.sale-total-value {
    font-size: 34px;
    font-weight: bold;
    color: #1a120b;
    font-family: 'Special Elite', cursive;
}

.sale-lines-head {
    margin-top: 10px;
    font-family: 'Playfair Display', serif;
}

.sale-line-card {
    background: #f4ece1;
    border: 1px solid #a89178;
    border-radius: 0;
    padding: 16px;
    margin-bottom: 14px;
    border-bottom: 3px solid #3d2b1f;
}

.sale-line-grid {
    display: grid;
    grid-template-columns: 2fr 120px 1.3fr 180px;
    gap: 12px;
    align-items: end;
}

.sale-line-actions {
    display: flex;
    flex-direction: column;
}

.sale-line-preview {
    margin-top: 12px;
    color: #2c1e14;
    font-size: 16px;
    font-family: 'Special Elite', cursive;
}

.line-total-preview {
    font-size: 18px;
    font-weight: bold;
}

@media (max-width: 900px) {
    .sale-top-grid,
    .sale-line-grid {
        grid-template-columns: 1fr;
    }
}

.inline-edit-form {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.inline-edit-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2c1e14;
    background: #f7ecd6;
    color: #1a120b;
    border-radius: 0;
}

.inline-edit-form button {
    padding: 10px 14px;
    background: #3d2b1f;
    color: #f2e7cf;
    border: 1px solid #000;
    border-radius: 0;
    font-weight: bold;
    cursor: pointer;
}

.delta-inline {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    vertical-align: middle;
    font-family: 'Special Elite', cursive;
}

.delta-positive {
    color: #1f5e2f;
}

.delta-negative {
    color: #8b0000;
}

.mini-stack {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.6;
}

.hidden-edit {
    display: none;
}

.mini-action-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 14px;
    background: #3d2b1f;
    color: #f2e7cf;
    border: 1px solid #000;
    border-radius: 0;
    font-weight: bold;
    cursor: pointer;
}

.mini-action-btn:hover {
    background: #5a0000;
}

.inline-edit-form {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.inline-edit-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #2c1e14;
    background: #f7ecd6;
    color: #1a120b;
}

.inline-edit-form button {
    padding: 10px 14px;
    background: #3d2b1f;
    color: #f2e7cf;
    border: 1px solid #000;
}

.delta-inline {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    vertical-align: middle;
}

.delta-positive {
    color: #1f5e2f;
}

.delta-negative {
    color: #8b0000;
}

.mini-stack {
    margin-top: 6px;
    font-size: 16px;
    line-height: 1.8;
}

.clickable-card {
    cursor: pointer;
    transition: transform 0.1s ease;
}

.clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(0,0,0,0.3);
}

.delta-inline {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    vertical-align: middle;
}

.delta-positive {
    color: #1f5e2f;
}

.delta-negative {
    color: #8b0000;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 10, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-overlay.is-open {
    display: flex;
}

.modal-box {
    position: relative;
    width: 100%;
    max-width: 520px;
    background: #ead7b5 url("https://www.transparenttextures.com/patterns/old-map.png");
    color: #2e1f14;
    border: 5px solid #3d2b1f;
    border-radius: 0;
    box-shadow: 0 18px 50px rgba(0,0,0,0.6);
    padding: 24px;
}

.modal-box h3 {
    margin-top: 0;
    margin-bottom: 18px;
    font-family: 'Playfair Display', serif;
    text-transform: uppercase;
    border-bottom: 2px solid #2c1e14;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #5a341d;
}

.modal-close:hover {
    color: #8b0000;
}

.permissions-groups {
    display: grid;
    gap: 18px;
    margin-top: 12px;
}

.permission-group h4 {
    margin: 0 0 10px 0;
    /* Couleur encre brune */
    color: #2c1e14; 
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    border-bottom: 1px solid #2c1e14;
    display: inline-block;
}

.permission-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.permission-badge {
    position: relative;
    cursor: pointer;
}

.permission-badge input {
    display: none;
}

.permission-badge span {
    display: inline-block;
    padding: 10px 14px;
    /* Look étiquette de dossier ancienne */
    border-radius: 0px; 
    border: 1px solid #2c1e14;
    background: #f4ece1;
    color: #2a1c12;
    font-family: 'Special Elite', cursive;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

.permission-badge span:hover {
    background: #e8dcc4;
    transform: translateY(-1px);
}

.permission-badge input:checked + span {
    /* Style Sceau de cire / Tampon validé */
    background: #8b0000; 
    color: #f5e8d0;
    border-color: #2c1e14;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

.permission-badge input:checked + span::before {
    /* Utilisation d'une croix ou d'un check style plume d'oie */
    content: "✕ "; 
    font-weight: bold;
}

.admin-toggle-wrap {
    margin: 10px 0 18px;
}

.admin-toggle-badge {
    display: inline-block;
    cursor: pointer;
    position: relative;
}

.admin-toggle-badge input {
    display: none;
}

.admin-toggle-badge span {
    display: inline-block;
    min-width: 280px;
    padding: 14px 18px;
    /* Look vieux document officiel */
    border-radius: 0px; 
    border: 1px solid #2c1e14;
    background: #f4ece1;
    color: #2a1c12;
    transition: all 0.2s ease;
    line-height: 1.4;
    font-family: 'Playfair Display', serif;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.1);
}

.admin-toggle-badge span strong {
    font-size: 18px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.admin-toggle-badge span small {
    font-size: 13px;
    opacity: 0.85;
    font-family: 'Special Elite', cursive;
    font-style: italic;
}

.admin-toggle-badge span:hover {
    background: #e8dcc4;
    border-color: #8b0000;
}

.admin-toggle-badge input:checked + span {
    /* Couleur de la haute direction (Rouge Sceau) */
    background: #5a0000; 
    color: #f5e8d0;
    border-color: #2c1e14;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.4);
}

.admin-toggle-badge input:checked + span::before {
    /* Marque de validation à la plume */
    content: "✒ "; 
    font-weight: bold;
    font-size: 20px;
    margin-right: 5px;
}

.admin-toggle-badge input:checked + span small {
    color: #d9c3a0;
}