/* ==========================================================================
   Archon RH – Back-office stylesheet
   Stack: vanilla CSS, custom properties, no framework
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. CSS Custom Properties (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
    /* Brand palette */
    --color-primary:        #4f6ef7;
    --color-primary-dark:   #3a57d4;
    --color-primary-light:  #eef1fe;
    --color-secondary:      #6c757d;
    --color-accent:         #22c55e;

    /* Semantic colours */
    --color-success:        #22c55e;
    --color-success-bg:     #f0fdf4;
    --color-error:          #ef4444;
    --color-error-bg:       #fef2f2;
    --color-warning:        #f59e0b;
    --color-warning-bg:     #fffbeb;
    --color-info:           #3b82f6;
    --color-info-bg:        #eff6ff;

    /* Neutrals */
    --color-bg:             #f4f6fb;
    --color-surface:        #ffffff;
    --color-border:         #e2e8f0;
    --color-border-focus:   #4f6ef7;
    --color-text:           #1e293b;
    --color-text-muted:     #64748b;
    --color-text-inverse:   #ffffff;

    /* Sidebar */
    --sidebar-bg:           #1e2a3a;
    --sidebar-text:         #94a3b8;
    --sidebar-text-active:  #ffffff;
    --sidebar-active-bg:    rgba(79, 110, 247, 0.18);
    --sidebar-active-border:#4f6ef7;
    --sidebar-hover-bg:     rgba(255, 255, 255, 0.06);
    --sidebar-width:        260px;

    /* Topbar */
    --topbar-height:        60px;
    --topbar-bg:            #ffffff;
    --topbar-border:        #e2e8f0;

    /* Spacing */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* Radius */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.10);

    /* Typography */
    --font-family-base: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-family-heading: var(--font-family-base);
    --font-family: var(--font-family-base);
    --font-size-xs:   0.75rem;
    --font-size-sm:   0.875rem;
    --font-size-base: 1rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;
    --font-size-3xl:  1.875rem;

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-normal: 250ms ease;
}

/* --------------------------------------------------------------------------
   1. Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family-base, var(--font-family));
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.page-title,
.topbar-page-title,
.card-title {
    font-family: var(--font-family-heading, var(--font-family-base, var(--font-family)));
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--color-primary-dark); }

ul, ol { list-style: none; }

img, svg { display: block; max-width: 100%; }

/* Ne pas laisser la règle globale agrandir le logo sidebar */
.sidebar .brand-mark__logo {
    max-width: var(--brand-logo-max-width, 160px);
    max-height: var(--brand-logo-max-height, 40px);
}

/* --------------------------------------------------------------------------
   2. App Shell Layout
   -------------------------------------------------------------------------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   3. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition-normal);
}

/* Brand */
.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid rgba(255,255,255,.07);
    width: 100%;
    box-sizing: border-box;
}

.sidebar-brand > .brand-mark {
    width: 100%;
}

/* Marque entreprise (logo + nom) */
.brand-mark {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}

.brand-mark__visual {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-mark__logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: left center;
}

.brand-mark__fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary, #4f6ef7);
    border-radius: var(--radius-md);
    color: #fff;
}

.brand-mark__fallback svg {
    width: 55%;
    height: 55%;
}

.brand-mark__name {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark--sidebar {
    width: 100%;
    max-width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-sm);
    box-sizing: border-box;
}

.brand-mark--sidebar .brand-mark__visual {
    width: auto;
    max-width: var(--brand-logo-max-width, 160px);
    height: var(--brand-logo-max-height, 40px);
    max-height: var(--brand-logo-max-height, 40px);
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-mark--sidebar .brand-mark__logo {
    display: block;
    max-width: var(--brand-logo-max-width, 160px);
    max-height: var(--brand-logo-max-height, 40px);
    width: auto;
    height: auto;
    margin-inline: auto;
    object-fit: contain;
    object-position: center center;
}

.brand-mark--sidebar .brand-mark__fallback {
    width: 36px;
    height: 36px;
    margin-inline: auto;
    flex-shrink: 0;
}

.brand-mark--sidebar .brand-mark__name {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding-inline: var(--space-sm);
    box-sizing: border-box;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: #fff;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.brand-mark--auth {
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: var(--space-md);
}

.brand-mark--auth .brand-mark__name {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
    white-space: normal;
    line-height: 1.25;
}

.brand-mark--settings .brand-mark__visual {
    width: 120px;
    height: 48px;
}

.brand-mark--settings .brand-mark__logo {
    max-width: 200px;
    max-height: 48px;
}

/* User pill */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--font-size-xs);
    color: var(--sidebar-text);
}

.brand-mark-preview-box {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 56px;
    max-height: 80px;
    padding: var(--space-md);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.brand-mark-preview-box .brand-mark__logo {
    max-width: min(100%, 240px);
    max-height: 64px;
}

.form-control-color {
    width: 100%;
    height: 42px;
    padding: 2px;
    cursor: pointer;
}

.settings-branding-layout {
    display: grid;
    grid-template-columns: 1fr min(320px, 36%);
    gap: var(--space-xl);
    align-items: start;
}

.settings-branding-live-preview {
    position: sticky;
    top: calc(var(--topbar-height) + var(--space-md));
}

.settings-preview-label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.settings-preview-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
}

.settings-preview-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 2px solid var(--preview-primary, var(--color-primary));
    background: #fff;
}

.settings-preview-topbar-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.settings-preview-body {
    display: flex;
    min-height: 140px;
}

.settings-preview-sidebar {
    width: 38%;
    background: var(--sidebar-bg);
    padding: var(--space-sm);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.settings-preview-sidebar #settingsPreviewBrand {
    width: 100%;
}

.settings-preview-sidebar .brand-mark--sidebar .brand-mark__name {
    font-size: var(--font-size-xs);
}

.settings-preview-content {
    flex: 1;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
    background: var(--preview-page-bg, var(--color-bg));
}

.settings-font-preview {
    width: 100%;
    margin-bottom: var(--space-xs);
}

.settings-font-preview__heading {
    font-family: var(--preview-font-heading, var(--font-family-heading, inherit));
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.settings-font-preview__body {
    font-family: var(--preview-font-body, var(--font-family-base, inherit));
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: 0;
}

.settings-preview-btn {
    background: var(--preview-primary, var(--color-primary)) !important;
    border-color: var(--preview-primary, var(--color-primary)) !important;
}

.settings-preview-link {
    color: var(--preview-primary, var(--color-primary));
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.settings-preview-badge {
    background: var(--preview-secondary-muted, var(--color-secondary-muted-bg, #f1f5f9));
    color: var(--color-secondary-muted-text, var(--color-text-muted));
}

.settings-contrast-panel {
    margin: var(--space-md) 0;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.settings-contrast-panel--ok {
    background: var(--color-success-bg);
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.settings-contrast-panel--warn {
    background: var(--color-warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

.settings-contrast-panel ul {
    margin: 0;
    padding-left: 1.1rem;
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--space-xl) 0;
}

.topbar-company-name {
    font-weight: 600;
    color: var(--color-text);
}

.topbar-page-sep {
    margin: 0 var(--space-xs);
    color: var(--color-text-muted);
    font-weight: 400;
}

.topbar-page-title {
    font-weight: 500;
    color: var(--color-text-muted);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #4a5568;
    padding: var(--space-md) var(--space-md) var(--space-xs);
    margin-top: var(--space-sm);
}

.nav-list {
    padding: 0 var(--space-sm);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px var(--space-sm);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--sidebar-text);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    border-left: 3px solid transparent;
    margin-bottom: 2px;
}

.nav-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-border);
}

.nav-notification-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: notifPulse 1.8s ease-in-out infinite;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
}

/* Sidebar footer */
.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid rgba(255,255,255,.07);
}

.nav-link-logout {
    color: #f87171;
}

.nav-link-logout:hover {
    background-color: rgba(248,113,113,.1);
    color: #fca5a5;
}

/* --------------------------------------------------------------------------
   4. Main area
   -------------------------------------------------------------------------- */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   5. Topbar
   -------------------------------------------------------------------------- */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-xl);
    gap: var(--space-md);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
}

.topbar-toggle svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

.topbar-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
    flex: 1;
}

/* --------------------------------------------------------------------------
   6. Main content area
   -------------------------------------------------------------------------- */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    max-width: 1280px;
    width: 100%;
}

/* --------------------------------------------------------------------------
   7. Page header
   -------------------------------------------------------------------------- */
.page-header {
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

/* --------------------------------------------------------------------------
   8. Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    padding: var(--space-xl);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   9. Stats grid (dashboard)
   -------------------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card--link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.stat-card--link:hover {
    border-color: var(--color-primary);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.stat-icon--blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon--green  { background: #f0fdf4; color: #22c55e; }
.stat-icon--amber  { background: #fffbeb; color: #f59e0b; }
.stat-icon--purple { background: #faf5ff; color: #a855f7; }
.stat-icon--red    { background: #fef2f2; color: #ef4444; }

.stat-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   10. Quick actions (dashboard)
   -------------------------------------------------------------------------- */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.quick-action-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.quick-action-card svg {
    width: 28px;
    height: 28px;
    stroke: var(--color-primary);
    transition: transform var(--transition-fast);
}

.quick-action-card:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action-card:hover svg {
    transform: scale(1.1);
}

/* --------------------------------------------------------------------------
   11. Section headers
   -------------------------------------------------------------------------- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   12. Tables
   -------------------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    font-size: var(--font-size-sm);
}

thead {
    background: #f8fafc;
}

th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: 12px var(--space-md);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}

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

tbody tr:hover { background-color: #f8fafc; }

/* --------------------------------------------------------------------------
   13. Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 9px var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-family);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Variants */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-hover, var(--color-primary-dark));
    border-color: var(--color-primary-hover, var(--color-primary-dark));
    color: var(--color-on-primary, #fff);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: #f1f5f9;
    color: var(--color-text);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
}
.btn-ghost:hover {
    background: #f1f5f9;
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-error);
    color: #fff;
    border-color: var(--color-error);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color:#fff; }

.btn-success {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}
.btn-success:hover { background: #16a34a; color:#fff; }

.btn-sm {
    padding: 5px var(--space-md);
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: 12px var(--space-xl);
    font-size: var(--font-size-base);
}

/* --------------------------------------------------------------------------
   14. Forms
   -------------------------------------------------------------------------- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

.form-label .required {
    color: var(--color-error);
    margin-left: 2px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.5;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

.form-control::placeholder { color: #a0aec0; }

.form-control:disabled, .form-control[readonly] {
    background: #f8fafc;
    cursor: not-allowed;
    color: var(--color-text-muted);
}

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-error);
    margin-top: var(--space-xs);
}

.form-control.is-invalid {
    border-color: var(--color-error);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0 var(--space-lg);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--space-lg);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

/* --------------------------------------------------------------------------
   15. Alerts & Flash messages
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    border: 1px solid transparent;
    margin: var(--space-md) var(--space-xl);
}

.alert-success  { background: var(--color-success-bg); color: #15803d; border-color: #bbf7d0; }
.alert-error    { background: var(--color-error-bg);   color: #b91c1c; border-color: #fecaca; }
.alert-warning  { background: var(--color-warning-bg); color: #92400e; border-color: #fed7aa; }
.alert-info     { background: var(--color-info-bg);    color: #1d4ed8; border-color: #bfdbfe; }

/* --------------------------------------------------------------------------
   16. Badges / Status pills
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-success  { background: #dcfce7; color: #15803d; }
.badge-error    { background: #fee2e2; color: #b91c1c; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }
.badge-neutral  { background: #f1f5f9; color: var(--color-text-muted); }
.badge-accent   { background: var(--color-secondary-muted-bg, #f1f5f9); color: var(--color-secondary-muted-text, var(--color-text-muted)); }
.badge-active   { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-suspended { background: #fee2e2; color: #b91c1c; }

/* --------------------------------------------------------------------------
   17. Pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    margin-top: var(--space-xl);
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pagination .current {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* --------------------------------------------------------------------------
   18. Empty state
   -------------------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    stroke: #cbd5e1;
    margin-bottom: var(--space-md);
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-xs);
}

/* --------------------------------------------------------------------------
   19. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-area {
        margin-left: 0;
    }

    .topbar-toggle {
        display: flex;
    }

    .settings-branding-layout {
        grid-template-columns: 1fr;
    }

    .settings-branding-live-preview {
        position: static;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: var(--space-md);
    }

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

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .brand-mark--sidebar .brand-mark__visual {
        max-width: min(100%, var(--brand-logo-max-width, 160px));
        height: var(--brand-logo-max-height, 40px);
        max-height: var(--brand-logo-max-height, 40px);
    }

    .brand-mark--sidebar .brand-mark__logo {
        max-width: min(100%, var(--brand-logo-max-width, 160px));
        max-height: var(--brand-logo-max-height, 40px);
    }

    .brand-mark--auth .brand-mark__logo {
        max-width: min(100%, 140px);
    }

    .topbar-company-name {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* --------------------------------------------------------------------------
   20. Utilities
   -------------------------------------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-sm      { font-size: var(--font-size-sm); }
.text-xs      { font-size: var(--font-size-xs); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-600       { font-weight: 600; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-sm       { gap: var(--space-sm); }
.gap-md       { gap: var(--space-md); }
.mt-md        { margin-top: var(--space-md); }
.mt-lg        { margin-top: var(--space-lg); }
.mb-md        { margin-bottom: var(--space-md); }
.mb-lg        { margin-bottom: var(--space-lg); }
.w-100        { width: 100%; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   21. Guest layout (login, pages publiques)
   -------------------------------------------------------------------------- */
.guest-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-bg) 100%);
}

.guest-main {
    width: 100%;
    max-width: 420px;
    padding: var(--space-xl);
}

.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    width: 100%;
}

.auth-card-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}


.auth-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin: 0 0 var(--space-xs);
}

.auth-subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0;
}

.auth-form .form-group:last-of-type {
    margin-bottom: var(--space-lg);
}

.btn-block {
    width: 100%;
    justify-content: center;
}