/* =============================================================
   DécorBudget — Feuille de style mobile-first (usage "terrain")
   ============================================================= */

:root {
    --green:  #16a34a;
    --orange: #d97706;
    --red:    #dc2626;
    --gray:   #6b7280;
    --bg:     #f3f4f6;
    --card:   #ffffff;
    --ink:    #111827;
    --line:   #e5e7eb;
    --topbar: #1e293b;
    --accent: #f59e0b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.45;
}

a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Barre supérieure / navigation ---------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    background: var(--topbar);
    color: #fff;
    padding: 10px 14px;
    gap: 8px;
}

.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    margin-right: auto;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.navtoggle { display: none; }

.burger {
    display: block;
    font-size: 1.5rem;
    color: #fff;
    cursor: pointer;
    padding: 2px 10px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 8px;
    user-select: none;
}

.mainnav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding-top: 8px;
}
.navtoggle:checked ~ .mainnav { display: flex; }

.mainnav a {
    color: #cbd5e1;
    padding: 10px 8px;
    border-radius: 8px;
    font-size: 1rem;
}
.mainnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.mainnav a.active { background: var(--accent); color: #1e293b; font-weight: 700; }
.mainnav .nav-logout { margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, .15); color: #fca5a5; }

@media (min-width: 900px) {
    .burger { display: none; }
    .mainnav { display: flex; flex-direction: row; width: auto; padding-top: 0; align-items: center; }
    .mainnav a { padding: 6px 10px; font-size: .95rem; }
    .mainnav .nav-logout { margin-top: 0; margin-left: 10px; border-top: 0; }
}

/* ---------------- Conteneur & cartes ---------------- */

.container { max-width: 1100px; margin: 0 auto; padding: 16px 12px 60px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}

.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 14px; }
@media (min-width: 700px)  { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px)  { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* ---------------- Indicateurs (KPI) ---------------- */

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 800px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
}
.kpi .kpi-label { font-size: .78rem; color: var(--gray); text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-value { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.kpi .kpi-sub   { font-size: .8rem; color: var(--gray); }
.kpi.danger  { border-color: #fecaca; background: #fef2f2; }
.kpi.warning { border-color: #fde68a; background: #fffbeb; }

/* ---------------- Jauges circulaires ---------------- */

.gauges { display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-around; text-align: center; }

.gauge {
    --p: 0deg;
    --c: var(--green);
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: conic-gradient(var(--c) var(--p), #e5e7eb 0deg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}
.gauge-inner {
    width: 92px;
    height: 92px;
    background: var(--card);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
}
.gauge-inner strong { font-size: 1.2rem; }
.gauge-inner span   { font-size: .68rem; color: var(--gray); line-height: 1.15; }
.gauge-sub { font-size: .8rem; color: var(--gray); margin: 8px 0 0; max-width: 170px; }

/* ---------------- Badges (code couleur statuts) ---------------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #e5e7eb; color: #374151; }

/* ---------------- Formulaires (mobile-first, grosses zones tactiles) ---------------- */

label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }

.input, select.input, textarea.input {
    width: 100%;
    padding: 11px 12px;
    font-size: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea.input { min-height: 90px; resize: vertical; }
.input-inline { width: auto; display: inline-block; padding: 7px 10px; }

.form-row { display: grid; gap: 0 12px; }
@media (min-width: 700px) { .form-row-2 { grid-template-columns: 1fr 1fr; } .form-row-3 { grid-template-columns: 1fr 1fr 1fr; } }

.checkline { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 600; }
.checkline input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--green); }

.hint { font-size: .78rem; color: var(--gray); margin-top: 3px; }
.required-star { color: var(--red); }

.btn {
    display: inline-block;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 700;
    border: 0;
    border-radius: 10px;
    background: var(--topbar);
    color: #fff;
    cursor: pointer;
    text-align: center;
}
.btn:hover { opacity: .9; text-decoration: none; color: #fff; }
.btn-block { display: block; width: 100%; margin-top: 14px; }
.btn-sm    { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-accent { background: var(--accent); color: #1e293b; }
.btn-green  { background: var(--green); }
.btn-red    { background: var(--red); }
.btn-ghost  { background: #e5e7eb; color: var(--ink); }

/* ---------------- Tableaux (défilement horizontal sur mobile) ---------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; background: var(--card); }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #475569; white-space: nowrap; }
.table tr:hover td { background: #f8fafc; }
.table .num, td.num, th.num { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: #f8fafc; }

/* ---------------- Messages flash & alertes ---------------- */

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; transition: opacity .5s; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash.hide { opacity: 0; }

.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { padding: 9px 12px; border-radius: 10px; margin-bottom: 8px; font-size: .92rem; }
.alert-red    { background: #fee2e2; color: #991b1b; }
.alert-orange { background: #fef3c7; color: #92400e; }
.alert-green  { background: #dcfce7; color: #166534; }

/* ---------------- Pointage (checklist) ---------------- */

.att-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.att-row .att-name { flex: 1; font-weight: 600; }
.att-row .att-role { font-size: .78rem; color: var(--gray); display: block; }
.att-row input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--green); }
.att-row input[type="number"] { width: 74px; }

/* ---------------- Rapports imprimables ---------------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }

.report-sheet {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    max-width: 850px;
    margin: 0 auto;
}
.report-sheet h1 { font-size: 1.35rem; margin: 0 0 4px; }
.report-sheet h2 { font-size: 1.05rem; margin: 18px 0 8px; border-bottom: 2px solid var(--topbar); padding-bottom: 4px; }
.report-meta { color: var(--gray); font-size: .85rem; margin-bottom: 10px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%) translateY(120px);
    background: var(--topbar);
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    transition: transform .3s;
    z-index: 100;
    max-width: 92vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

.footer { text-align: center; color: var(--gray); padding: 18px 10px 30px; }

.muted { color: var(--gray); }
.text-red { color: var(--red); font-weight: 700; }
.text-green { color: var(--green); font-weight: 700; }
.mt { margin-top: 14px; }
.img-thumb { max-width: 52px; max-height: 52px; border-radius: 6px; border: 1px solid var(--line); }
.receipt-preview { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 8px; display: none; border: 1px solid var(--line); }

/* ---------------- Impression / export PDF navigateur ---------------- */

@media print {
    .no-print, .topbar, .footer, .toolbar, .flash, .toast { display: none !important; }
    body { background: #fff; }
    .container { padding: 0; max-width: 100%; }
    .report-sheet { border: 0; border-radius: 0; max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: 0; }
    a { color: #000; }
}
