/* ================================================
   QONTINUITY — ESPACE CLIENT B2B
   Design system hérité de landing.css
   Mobile-first · WCAG AA
   ================================================ */

:root {
    --bg: #FFFFFF;
    --bg-warm: #F8F5F0;
    --bg-dark: #0D0D0D;
    --sidebar-bg: #F5F5F5;
    --sidebar-text: #2D2D2D;
    --sidebar-text-muted: #6B6B6B;
    --sidebar-border: rgba(0,0,0,0.08);
    --text: #111111;
    --text-secondary: #5A5A5A;
    --gold: #B8941F;
    --accent: #B8941F;
    --danger: #DC3545;
    --success: #28A745;
    --border: #E5E5E5;
    --font-display: 'Raleway', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --sidebar-width: 260px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-warm);
}

/* ---- LOGIN PAGE ---- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: 24px;
}

.login-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 48px 40px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-logo {
    display: block;
    margin: 0 auto 32px;
    height: 40px;
}

.login-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin: 0 0 8px;
    color: var(--text);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 32px;
}

/* ---- FORMS ---- */

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

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-body);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(184, 148, 31, 0.15);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    color: #fff;
    background: var(--bg-dark);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: #333; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

.form-error-msg {
    display: none;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--danger);
    background: #fdf0f0;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin-bottom: 16px;
}

.form-success-msg {
    display: none;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--success);
    background: #f0fdf4;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    margin-bottom: 16px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-footer a {
    color: var(--gold);
    text-decoration: none;
}

/* ---- DASHBOARD LAYOUT ---- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar (inspirée chatbot — fond clair, texte sombre, bordures subtiles) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    height: 36px;
    margin-bottom: 14px;
}

.sidebar-company {
    font-size: 14px;
    font-weight: 600;
    color: var(--sidebar-text);
    margin: 0;
}

.sidebar-role {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 8px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
    border-radius: 0;
}

.sidebar-nav a:hover {
    color: var(--gold);
    background: rgba(0, 0, 0, 0.04);
}

.sidebar-nav a.active {
    color: var(--gold);
    background: rgba(184, 148, 31, 0.08);
    border-left: 3px solid var(--gold);
    padding-left: 21px;
}

.sidebar-nav a.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer button {
    background: none;
    border: none;
    color: var(--sidebar-text-muted);
    font-size: 13px;
    font-family: var(--font-body);
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.2s;
}

.sidebar-footer button:hover { color: var(--gold); }

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    min-height: 100vh;
}

.main-header {
    margin-bottom: 32px;
}

.main-header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.main-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 24px;
    border: 1px solid var(--border);
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 8px;
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* Section cards */
.section-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 28px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.section-card h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text);
}

/* Tables (admin) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.data-table tr:hover td { background: var(--bg-warm); }

/* Role badges */
.badge-role {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
}

.badge-role.admin_entreprise { background: #fef3cd; color: #856404; }
.badge-role.rh { background: #d1ecf1; color: #0c5460; }
.badge-role.membre { background: #e2e3e5; color: #383d41; }

/* Tabs (admin) */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--gold); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Mobile sidebar */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--sidebar-bg);
    border: none;
    color: var(--sidebar-text);
    width: 44px;
    height: 44px;
    border-radius: 0;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.08);
    transition: background 0.3s;
}

.sidebar-toggle:hover { background: var(--gold); color: #fff; }

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 24px 20px;
        padding-top: 64px;
    }

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

    .login-card {
        padding: 32px 24px;
    }
}

/* Anti-flash pour pages protégées */
body.auth-checking {
    visibility: hidden;
}

/* Admin form inline */
.admin-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 24px;
}

.admin-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 180px;
}

.admin-form .btn-primary {
    width: auto;
    padding: 10px 20px;
    flex-shrink: 0;
}

/* Statut badges */
.badge-statut {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.badge-statut.demandee { background: #fff3cd; color: #856404; }
.badge-statut.devis_envoye { background: #d1ecf1; color: #0c5460; }
.badge-statut.confirmee { background: #d4edda; color: #155724; }
.badge-statut.en_cours { background: #cce5ff; color: #004085; }
.badge-statut.terminee { background: #e2e3e5; color: #383d41; }
.badge-statut.annulee { background: #f8d7da; color: #721c24; }

/* Catalogue cards grid */
.catalogue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.catalogue-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    transition: box-shadow 0.2s;
}

.catalogue-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.catalogue-card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text);
}

.catalogue-card-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.catalogue-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}
