/* ==========================================================
   QCM APS v2.0 — style.css
   Dark theme, accent orange, mobile-first
   ========================================================== */

:root {
    --bg: #0f1115;
    --bg-elevated: #171a21;
    --bg-card: #1c2028;
    --border: #2a2f3a;
    --text: #e8e9ec;
    --text-muted: #9aa0ab;
    --accent: #e8a020;
    --accent-hover: #f5b23e;
    --accent-dim: rgba(232, 160, 32, 0.15);
    --success: #3ecf8e;
    --danger: #e8544a;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3 {
    margin: 0 0 0.5em;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------- Layout ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.app-header .brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.app-header .logout {
    font-size: 0.85rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius);
}

.app-header .logout:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.app-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 16px 90px;
}

/* ---------- Bottom nav (mobile-first) ---------- */

.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 20;
}

.app-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    color: var(--text-muted);
    font-size: 0.68rem;
    border-radius: var(--radius);
    text-align: center;
}

.app-nav a .icon {
    font-size: 1.15rem;
    line-height: 1;
}

.app-nav a.active {
    color: var(--accent);
    background: var(--accent-dim);
}

@media (min-width: 720px) {
    .app-nav {
        position: static;
        justify-content: flex-start;
        gap: 4px;
        background: transparent;
        border-top: none;
        padding: 0;
        margin: -6px 0 24px;
    }

    .app-nav a {
        flex: none;
        flex-direction: row;
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .app-main {
        padding-bottom: 40px;
    }
}

/* ---------- Cards / grid ---------- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 600px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    font-size: 1.4rem;
    margin-bottom: 8px;
    display: block;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Forms ---------- */

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    background: var(--accent);
    color: #16130a;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

button:hover,
.btn:hover {
    background: var(--accent-hover);
    color: #ffffff;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: #ffffff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(232, 84, 74, 0.12);
    border: 1px solid var(--danger);
    color: #ff9f97;
}

.alert-success {
    background: rgba(62, 207, 142, 0.12);
    border: 1px solid var(--success);
    color: #8ff0c4;
}

/* ---------- Login page ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-box .dot-big {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent);
    margin: 0 auto 16px;
}

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

@media print {
    .app-header, .app-nav, .btn, .form-actions, form, .actions-cell { display: none !important; }
    body { background: #fff; color: #111; }
    .card, .table-wrap { background: #fff; border-color: #ccc; box-shadow: none; }
    th { background: #eee !important; color: #111 !important; }
    td, th { color: #111 !important; }
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.9rem;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-elevated);
}

tr:last-child td {
    border-bottom: none;
}

.swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid var(--border);
    vertical-align: middle;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

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

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-row input[type="color"] {
    width: 48px;
    height: 44px;
    padding: 2px;
    flex-shrink: 0;
}

.color-row input[type="text"] {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.type-fields {
    display: none;
}

code {
    background: var(--bg-elevated);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ---------- Tuiles thème (repliables) ---------- */

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}

.theme-tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    padding: 10px;
    text-align: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.theme-tile:hover {
    transform: translateY(-2px);
}

.theme-tile.open {
    background: var(--bg-elevated);
}

.theme-tile-swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-tile-code {
    font-weight: 700;
    font-size: 0.85rem;
    word-break: break-word;
}

.theme-tile-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.theme-panel {
    margin-top: 14px;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
}
