/* Design system - Compta association */

:root {
    color-scheme: light;
    --surface: #fcfcfb;
    --page: #f5f6f8;
    --text-primary: #16181d;
    --text-secondary: #52565e;
    --text-muted: #898791;
    --border: #e5e7eb;
    --border-strong: #d6d9de;

    --brand: #2a78d6;
    --brand-hover: #1c5cab;
    --brand-soft: #eaf2fc;

    --success: #0ca30c;
    --success-soft: #e7f7e7;
    --warning: #eda100;
    --warning-soft: #fdf3e0;
    --danger: #d03b3b;
    --danger-soft: #fbeaea;
    --info: #4a3aa7;
    --info-soft: #edeafa;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html, body {
    background: var(--page);
    color: var(--text-primary);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
h1 { font-size: 1.5rem; }
.h4 { font-size: 1.15rem; font-weight: 600; }
.h5 { font-size: 1rem; font-weight: 600; }

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

/* Layout: sidebar + main */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: #14171f;
    color: #cdd1db;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-sidebar .brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1.25rem 0.5rem;
}
.app-sidebar .brand-logo img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: var(--radius);
}

.app-sidebar .brand {
    padding: 1.15rem 1.25rem;
    font-weight: 700;
    font-size: 1.02rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    line-height: 1.3;
    text-align: center;
}

.app-sidebar nav { flex: 1; padding: 0.75rem 0.6rem; overflow-y: auto; }

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: #b7bcc8;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.app-sidebar .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

.app-sidebar .nav-link.active {
    background: var(--brand);
    color: #fff;
}

.app-sidebar .nav-icon { width: 18px; text-align: center; opacity: 0.9; font-size: 0.95em; }

.app-sidebar .user-box {
    padding: 0.9rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.85rem;
}

.app-sidebar .user-box .name { color: #fff; font-weight: 600; display: block; }
.app-sidebar .user-box .role { color: #8a8f9c; display: block; margin-bottom: 0.6rem; }

.app-main { flex: 1; min-width: 0; }

.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-content { padding: 1.5rem; max-width: 1400px; }

.sidebar-toggle { border-radius: var(--radius-sm); }

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
}
.user-menu:hover { background: var(--page); color: var(--text-primary); }
.user-menu::after { margin-left: 0.35rem; }
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.user-menu-name { font-weight: 600; font-size: 0.9rem; }
.role-badge { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-title { font-size: 0.95rem; font-weight: 600; }

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.4rem 0.85rem;
}
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-danger, .btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }

/* Tables */
.table {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
.table thead th {
    background: #fafafa;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
}
.table td { padding: 0.65rem 0.9rem; vertical-align: middle; border-color: var(--border); font-size: 0.9rem; }
.table-bordered { border: 1px solid var(--border); }
.table-bordered td, .table-bordered th { border-color: var(--border); }

/* Badges */
.badge { font-weight: 600; font-size: 0.72rem; padding: 0.32em 0.6em; border-radius: 6px; }
.bg-success { background: var(--success) !important; }
.bg-warning { background: var(--warning) !important; color: #fff !important; }
.bg-danger { background: var(--danger) !important; }
.bg-primary { background: var(--brand) !important; }
.bg-secondary { background: #8a8f9c !important; }
.bg-info { background: var(--info) !important; }

/* Forms */
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.3rem; }
.form-control, .form-select {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    padding: 0.45rem 0.7rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Alerts */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: 0.9rem; }
.alert-success { background: var(--success-soft); color: #0a6b0a; border-color: #c6ecc6; }
.alert-danger { background: var(--danger-soft); color: #9c2b2b; border-color: #f3caca; }
.alert-warning { background: var(--warning-soft); color: #8a6100; border-color: #f5dfae; }
.alert-info { background: var(--info-soft); color: #362a7d; border-color: #d4cdf3; }

/* Login page */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #14171f 0%, #232735 55%, var(--brand) 160%);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2rem;
}

@media (max-width: 900px) {
    .app-sidebar { position: fixed; left: -260px; z-index: 1000; transition: left 0.2s; }
    .app-sidebar.open { left: 0; }
    .app-content { padding: 1rem; }
    .sidebar-toggle { display: inline-flex !important; }
}

/* Print */
@media print {
    .no-print { display: none !important; }
    .app-content { padding: 0 !important; max-width: none; }
    html, body { background: #fff !important; }
    .app-shell { display: block; }
}

/* "@" mention autocomplete (email templates) */
.mention-dropdown {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    margin-top: 2px;
    width: 100%;
    max-width: 320px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.mention-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.7rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    cursor: pointer;
}
.mention-item:hover, .mention-item:focus {
    background: var(--brand-soft);
}
.mention-item strong { color: var(--brand); }
.mention-item span { color: var(--text-muted); font-size: 0.78rem; }

/* Devis: drag-and-drop line reordering */
tr.ligne-draggable.dragging {
    opacity: 0.5;
}
tr.ligne-draggable .drag-handle {
    cursor: grab;
}
