:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* HEADER */
header {
    background: var(--primary);
    color: white;
    padding: 1.2rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
header h1 { font-size: 1.5rem; font-weight: 700; }
header p { font-size: 0.9rem; opacity: 0.85; }

/* MAIN */
main { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }

/* PAGE TITRE */
.page-title { text-align: center; margin-bottom: 2.5rem; }
.page-title h2 { font-size: 1.8rem; color: var(--text); }
.page-title p { color: var(--text-light); margin-top: 0.5rem; }

/* GRILLE CATÉGORIES */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: var(--text);
    display: block;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.category-card img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    padding: 0.5rem;
    background: #f8fafc;
}
.category-card .card-img-placeholder {
    width: 100%;
    height: 150px;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}
.category-card .card-body { padding: 1rem; text-align: center; }
.category-card .card-body h3 { font-size: 1rem; font-weight: 600; }

/* LOADING */
.loading { text-align: center; padding: 3rem; color: var(--text-light); }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* FORMULAIRE CALCUL */
.calcul-container { max-width: 600px; margin: 0 auto; }
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
}
.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.4rem; font-size: 0.9rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: white;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }

/* BOUTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-full { width: 100%; justify-content: center; }

/* RÉSULTAT */
.result-box {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
}
.result-box h3 { font-size: 1.2rem; color: var(--success); margin-bottom: 1rem; }
.result-range {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.result-price {
    background: white;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.result-price .label { font-size: 0.8rem; color: var(--text-light); text-transform: uppercase; }
.result-price .amount { font-size: 2rem; font-weight: 700; color: var(--success); }
.result-separator { font-size: 1.5rem; color: var(--text-light); }

/* BACK OFFICE */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 220px;
    background: #1e293b;
    color: white;
    padding: 1.5rem 0;
    flex-shrink: 0;
}
.admin-sidebar h2 { padding: 0 1.2rem 1rem; font-size: 1rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-sidebar a { display: block; padding: 0.7rem 1.2rem; color: #cbd5e1; text-decoration: none; transition: background 0.2s, color 0.2s; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(255,255,255,0.1); color: white; }
.admin-content { flex: 1; padding: 2rem; }

/* TABLE */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.85rem; text-transform: uppercase; color: var(--text-light); background: #f8fafc; }
tr:hover td { background: #f8fafc; }

/* BADGE */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-information { background: #dbeafe; color: #1d4ed8; }
.badge-valeur { background: #fef3c7; color: #b45309; }
.badge-liste { background: #f3e8ff; color: #7c3aed; }

/* BACK LINK */
.back-link { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--primary); text-decoration: none; margin-bottom: 1.5rem; font-size: 0.9rem; }
.back-link:hover { text-decoration: underline; }

/* ALERT */
.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* FORMULE */
.formule-help { font-size: 0.8rem; color: var(--text-light); margin-top: 0.3rem; }
.alias-tag { display: inline-block; background: #e0e7ff; color: #3730a3; padding: 0.1rem 0.4rem; border-radius: 4px; font-family: monospace; font-size: 0.85rem; margin: 0.1rem; }

/* RESPONSIVE */
@media (max-width: 640px) {
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; }
    .result-range { flex-direction: column; }
}
