:root {
    --wood-dark: #2b160b;
    --wood: #5b321c;
    --cream: #fff7ea;
    --paper: #f8efe0;
    --gold: #d9b36c;
    --red: #a61920;
    --text: #2b1b12;
    --muted: #7a685c;
    --line: #e5d5bd;
    --success-bg: #effaf1;
    --success-border: #b7e0bd;
    --success-text: #1f6b2d;
    --danger-bg: #ffe7e7;
    --danger-border: #efb5b5;
    --danger-text: #7b1111;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: #f5ead9;
}

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

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* ===================================
   LOGIN
=================================== */

.admin-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2b160b, #5b321c 55%, #8d5a2c);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,247,234,.96);
    border: 1px solid rgba(217,179,108,.45);
    border-radius: 22px;
    padding: 34px;
    box-shadow: 0 24px 80px rgba(0,0,0,.35);
}

.login-brand {
    text-align: center;
    margin-bottom: 26px;
}

.brand-mark {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--wood-dark);
    color: var(--gold);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.login-brand h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 29px;
}

.login-brand p {
    margin: 6px 0 0;
    color: var(--muted);
}

.login-form label {
    display: block;
    font-weight: 700;
    margin: 14px 0 7px;
}

.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    font-size: 15px;
    background: #fff;
}

.login-form button {
    width: 100%;
    margin-top: 22px;
    border: 0;
    border-radius: 999px;
    padding: 14px 18px;
    background: var(--red);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

/* ===================================
   STRUCTURE ADMIN DESKTOP
=================================== */

.admin-body {
    background: #f5ead9;
}

.admin-page {
    min-height: 100vh;
    display: flex;
    background: #f5ead9;
}

.sidebar {
    width: 290px;
    background: linear-gradient(180deg, #2b160b 0%, #1d0e06 100%);
    color: #fff;
    padding: 18px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    box-shadow: 4px 0 18px rgba(0,0,0,.18);
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(217,179,108,.45);
    border-radius: 999px;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-brand .brand-mark {
    width: 46px;
    height: 46px;
    margin: 0;
    background: #fff7ea;
    color: var(--wood-dark);
    font-size: 15px;
}

.sidebar-brand strong {
    display: block;
    font-family: Georgia, serif;
    font-size: 19px;
    line-height: 1.15;
    color: #fff;
}

.sidebar-brand span {
    display: block;
    color: #d9c6ad;
    font-size: 12px;
    margin-top: 3px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #f8efe0;
    transition: .2s;
    white-space: normal;
    line-height: 1.25;
    font-size: 14px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(217,179,108,.18);
    color: #fff;
}

.sidebar-nav a.active {
    box-shadow: inset 3px 0 0 var(--gold);
}

.admin-main {
    margin-left: 290px;
    width: calc(100% - 290px);
    padding: 24px;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: #fff7ea;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px 22px;
    margin-bottom: 22px;
    box-shadow: 0 10px 30px rgba(43,22,11,.05);
}

.topbar h1 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: 34px;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
}

.logout {
    background: var(--wood-dark);
    color: #fff;
    border-radius: 999px;
    padding: 11px 17px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* ===================================
   ALERTES
=================================== */

.alert {
    padding: 13px 15px;
    border-radius: 13px;
    margin-bottom: 18px;
    font-weight: 700;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

/* ===================================
   DASHBOARD / PANELS
=================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff7ea;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(43,22,11,.05);
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 34px;
    font-family: Georgia, serif;
}

.stat-card.warning strong {
    color: var(--red);
}

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

.panel {
    background: #fff7ea;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(43,22,11,.04);
}

.panel h2 {
    margin: 0 0 16px;
    font-family: Georgia, serif;
}

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

.panel-head h2 {
    margin: 0;
}

.panel-head span {
    color: var(--muted);
    font-weight: 700;
}

.panel-head-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.empty {
    color: var(--muted);
}

.todo-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.todo-list li {
    margin-bottom: 9px;
}

/* ===================================
   TABLES
=================================== */

.table-wrapper,
.admin-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.admin-table th {
    background: #f8efe0;
    font-weight: 700;
}

.admin-table th,
.admin-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.admin-table tr:hover {
    background: rgba(217,179,108,.08);
}

.badge {
    background: #ead8bc;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge.off {
    background: #eee;
    color: #666;
}

.table-action {
    color: var(--wood-dark);
    font-weight: 700;
}

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

.table-action.danger,
.text-danger {
    color: var(--red);
    font-weight: 700;
}

small,
.muted {
    color: var(--muted);
}

/* ===================================
   BOUTONS
=================================== */

.btn,
.btn-primary,
.btn-secondary,
.logout {
    cursor: pointer;
    transition: .2s;
    border: none;
}

.btn,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 17px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.btn:hover,
.btn-primary:hover,
.logout:hover {
    opacity: .9;
    transform: translateY(-1px);
}

.btn.small,
.btn-primary.small,
.btn-secondary.small {
    padding: 8px 12px;
    font-size: 13px;
}

.btn.secondary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 17px;
    border-radius: 999px;
    background: var(--wood-dark);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border: none;
}

.btn-danger {
    background: #8d1f1f !important;
    color: #fff !important;
}

.inline-form,
.inline-delete-form {
    display: inline;
    margin: 0;
}

.inline-delete-form button {
    font: inherit;
    cursor: pointer;
}

/* ===================================
   FORMULAIRES
=================================== */

.admin-form {
    display: grid;
    gap: 28px;
}

.form-section {
    border-bottom: 1px solid var(--line);
    padding-bottom: 24px;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-field label,
.form-check label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    background: #fff;
    font-size: 15px;
}

.form-field textarea {
    resize: vertical;
    min-height: 105px;
}

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

.form-check {
    display: flex;
    align-items: center;
    padding-top: 28px;
}

.form-check input {
    margin-right: 8px;
}

.form-actions,
.actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.help-text {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* ===================================
   IMAGE UPLOAD
=================================== */

.image-upload-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-upload-box input[type="file"] {
    display: none;
}

.image-preview {
    width: 220px;
    aspect-ratio: 1 / 1;
    border-radius: 20px;
    border: 2px dashed var(--gold);
    background: #fff;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
    transition: .2s;
}

.image-preview:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ===================================
   MODULE LIVRAISON / CARTES
=================================== */

.tournee-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.tournee-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    margin: 12px 0;
}

.tournee-card strong {
    display: block;
}

.tournee-meta {
    display: grid;
    grid-template-columns: 1.1fr 1.5fr 1fr;
    gap: 14px;
    margin-top: 10px;
}

.items-box {
    margin-top: 14px;
    padding: 12px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: #fffaf1;
}

.items-box h4 {
    margin: 0 0 8px 0;
}

.items-list {
    margin: 0;
    padding-left: 18px;
}

.items-list li {
    margin: 5px 0;
}

.loading-summary {
    border: 2px solid #6b3d22;
    background: #fff7ea;
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
}

.loading-summary h3 {
    margin-top: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

.summary-grid div {
    padding: 4px 0;
    border-bottom: 1px solid #ead8c0;
}

.client-comment {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fff3d8;
    border-radius: 12px;
}

/* ===================================
   RESPONSIVE ADMIN TABLETTE
=================================== */

@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
        padding: 16px 12px;
    }

    .admin-main {
        margin-left: 250px;
        width: calc(100% - 250px);
        padding: 20px;
    }

    .sidebar-brand strong {
        font-size: 17px;
    }

    .sidebar-nav a {
        font-size: 13px;
        padding: 9px 10px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .tournee-meta {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   RESPONSIVE ADMIN MOBILE
=================================== */

@media (max-width: 900px) {
    body {
        background: #f5ead9;
    }

    .admin-page {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        max-height: none;
        padding: 14px;
        box-shadow: none;
        border-bottom: 2px solid rgba(217,179,108,.35);
    }

    .sidebar-brand {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .sidebar-brand .brand-mark {
        width: 42px;
        height: 42px;
    }

    .sidebar-brand strong {
        font-size: 18px;
    }

    .sidebar-brand span {
        font-size: 12px;
    }

    .sidebar-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .sidebar-nav a {
        justify-content: center;
        text-align: center;
        min-height: 40px;
        padding: 9px 8px;
        background: rgba(255,255,255,.06);
        font-size: 12px;
        border-radius: 11px;
    }

    .sidebar-nav a.active {
        box-shadow: none;
        background: rgba(217,179,108,.28);
    }

    .admin-main {
        margin-left: 0;
        width: 100%;
        padding: 14px;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
        flex-direction: column;
        padding: 18px;
        border-radius: 16px;
    }

    .topbar h1 {
        font-size: 28px;
    }

    .logout {
        width: 100%;
    }

    .stats-grid,
    .panel-grid,
    .form-grid,
    .tournee-meta,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 16px;
        border-radius: 16px;
    }

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

    .panel-head-right {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .panel-head-right a,
    .panel-head-right button,
    .form-actions .btn,
    .form-actions .btn-primary,
    .form-actions .btn-secondary,
    .actions .btn,
    .actions .btn-primary,
    .actions .btn-secondary {
        width: 100%;
    }

    .form-actions,
    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-table {
        min-width: 700px;
    }

    .table-wrapper,
    .admin-table-wrapper,
    .panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .image-preview {
        width: 100%;
        max-width: 260px;
    }
}

@media (max-width: 520px) {
    .sidebar-nav {
        grid-template-columns: 1fr;
    }

    .sidebar-nav a {
        justify-content: flex-start;
        text-align: left;
    }

    .topbar h1 {
        font-size: 25px;
    }

    .stat-card strong {
        font-size: 28px;
    }

    .btn,
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }

    th,
    td {
        padding: 10px 8px;
    }
}

/* ===================================
   IMPRESSION
=================================== */

@media print {
    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .admin-main {
        margin: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .panel {
        box-shadow: none !important;
        border: none !important;
    }

    body {
        background: #fff !important;
    }

    .tournee-card {
        page-break-inside: avoid;
    }
}

/* ===================================
   MODULE SEO
=================================== */
.seo-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    padding: 7px 10px;
    border-radius: 999px;
    font-weight: 800;
}

.seo-good {
    background: #effaf1;
    color: #1f6b2d;
}

.seo-medium {
    background: #fff3d8;
    color: #8a5a00;
}

.seo-low {
    background: #ffe7e7;
    color: #7b1111;
}
