/* EMGLOW — Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: rgba(37, 99, 235, 0.1);
    --accent-muted: rgba(37, 99, 235, 0.06);
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s ease;
}

[data-bs-theme="dark"] {
    --bg-body: #0b1120;
    --bg-sidebar: #0f172a;
    --bg-surface: #131c2e;
    --bg-elevated: #1a2540;
    --bg-input: #0f172a;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #1e293b;
    --border-light: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --topbar-bg: rgba(11, 17, 32, 0.85);
    --bs-body-bg: #0b1120;
    --bs-body-color: #f1f5f9;
    --bs-border-color: #1e293b;
    --bs-secondary-bg: #131c2e;
    --bs-tertiary-bg: #1a2540;
}

[data-bs-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: rgba(15, 23, 42, 0.04);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --topbar-bg: rgba(255, 255, 255, 0.9);
    --bs-body-bg: #f1f5f9;
    --bs-body-color: #0f172a;
    --bs-border-color: #e2e8f0;
    --bs-secondary-bg: #f8fafc;
    --bs-tertiary-bg: #f1f5f9;
}

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

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition), color var(--transition);
}

/* ── Sidebar ── */

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity var(--transition);
}

#sidebar-overlay.show {
    display: block;
    opacity: 1;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.sidebar-brand-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand-sub {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

.sidebar-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.5rem 0.75rem 0.375rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-secondary);
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.sidebar-nav .nav-link i {
    font-size: 1.0625rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.75;
}

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

.sidebar-nav .nav-link.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-secondary);
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

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

/* ── App wrapper ── */

#app-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
}

#sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

#sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-datetime {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.topbar-datetime .divider {
    width: 1px;
    height: 16px;
    background: var(--border);
}

#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

#theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#main-content {
    flex: 1;
    padding: 1.75rem 1.5rem 2rem;
}

#notification-area {
    position: fixed;
    top: calc(var(--topbar-height) + 0.75rem);
    right: 1rem;
    z-index: 1060;
    max-width: 380px;
    width: calc(100% - 2rem);
}

#notification-area .alert {
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    font-size: 0.875rem;
}

/* ── Page header ── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Cards ── */

.card {
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 1rem 1.25rem !important;
}

.card-header h5,
.card-header h6 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem !important;
}

.card-footer {
    background: transparent !important;
    border-top: 1px solid var(--border) !important;
    padding: 1rem 1.25rem !important;
}

/* ── Dashboard cards ── */

.dash-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: border-color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    color: inherit;
}

.dash-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    color: inherit;
}

.dash-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.dash-card-icon.blue { background: rgba(37, 99, 235, 0.12); color: var(--accent); }
.dash-card-icon.green { background: rgba(5, 150, 105, 0.12); color: var(--success); }
.dash-card-icon.amber { background: rgba(217, 119, 6, 0.12); color: var(--warning); }
.dash-card-icon.cyan { background: rgba(2, 132, 199, 0.12); color: var(--info); }
.dash-card-icon.slate { background: var(--bg-hover); color: var(--text-secondary); }

.dash-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.375rem;
}

.dash-card-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0 0 1.25rem;
    flex: 1;
}

.dash-card-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* ── Stat cards ── */

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    height: 100%;
}

.stat-card-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-card.success { border-left: 3px solid var(--success); }
.stat-card.warning { border-left: 3px solid var(--warning); }
.stat-card.danger { border-left: 3px solid var(--danger); }
.stat-card.info { border-left: 3px solid var(--info); }

/* ── Buttons ── */

.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

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

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
}

.btn-outline-primary {
    color: var(--accent) !important;
    border-color: var(--accent) !important;
}

.btn-outline-primary:hover {
    background-color: var(--accent-subtle) !important;
    color: var(--accent-hover) !important;
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 0.3125rem 0.625rem;
}

/* ── Forms ── */

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.input-group-text {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-muted);
}

/* ── Tables ── */

.table {
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--bg-hover);
    --bs-table-striped-bg: var(--accent-muted);
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    white-space: nowrap;
}

.table tbody td {
    border-color: var(--border);
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: var(--bg-hover);
}

/* ── Tabs ── */

.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.625rem 1rem;
    transition: color var(--transition), border-color var(--transition);
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--accent);
    background: transparent;
    border-color: transparent transparent var(--accent);
}

/* ── List group ── */

.list-group-item {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* ── Badges ── */

.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* ── Modals ── */

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
}

/* ── Panier / zones de contenu ── */

.content-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 80px;
}

.content-panel-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem 1rem;
}

.total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

.total-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.total-amount span {
    color: var(--accent);
}

/* ── Empty state ── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.35;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.9375rem;
    margin: 0;
}

/* ── Inventaire specifics ── */

.price-cell {
    font-weight: 600;
    color: var(--info);
    font-variant-numeric: tabular-nums;
}

.stock-cell {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stock-input {
    width: 80px;
    text-align: center;
}

/* ── Settings ── */

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-row-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* ── Offline page ── */

.offline-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1.5rem;
}

/* ── Responsive ── */

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

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

    #app-wrapper {
        margin-left: 0;
    }

    #sidebar-toggle {
        display: flex;
    }

    #main-content {
        padding: 1.25rem 1rem 1.75rem;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .total-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .total-bar .btn-group-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .total-bar .btn-group-actions .btn {
        width: 100%;
    }

    .topbar-datetime {
        display: none;
    }
}
