/* ============================================================
   ILYGO Devis - Design System
   Based on ILYGO Atrium visual identity
   Built on Bootstrap 5.3
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */

:root {
    /* Brand */
    --color-primary: #213150;
    --color-primary-hover: #19263e;
    --color-primary-light: rgba(33, 49, 80, 0.08);
    --color-accent: #0ea5e9;
    --color-accent-hover: #0284c7;

    /* Backgrounds */
    --color-bg: #f5f7fa;
    --color-card: #ffffff;
    --color-sidebar: #ffffff;
    --color-navbar: #ffffff;

    /* Text */
    --color-text: #212529;
    --color-text-secondary: #6c757d;
    --color-text-muted: #adb5bd;
    --color-brand-light: #6b7280;

    /* Borders */
    --color-border: #dee2e6;
    --color-border-light: #e9ecef;

    /* Status */
    --color-success: #198754;
    --color-warning: #e8a317;
    --color-danger: #dc3545;
    --color-info: #0d7ea3;

    /* Radii */
    --radius-card: 16px;
    --radius-modal: 10px;
    --radius-btn: 8px;
    --radius-badge: 6px;
    --radius-input: 8px;

    /* Shadows */
    --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

    /* Layout */
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --navbar-height: 56px;

    /* Transitions */
    --transition: all 0.15s ease;
}

/* ── Dark Mode ─────────────────────────────────────────────── */

html.theme-dark {
    --color-primary: #6b9fff;
    --color-primary-hover: #5a8fee;
    --color-primary-light: rgba(107, 159, 255, 0.12);
    --color-accent: #38bdf8;
    --color-accent-hover: #0ea5e9;

    --color-bg: #0f1419;
    --color-card: #1a2332;
    --color-sidebar: #141c28;
    --color-navbar: #141c28;

    --color-text: #e1e5ea;
    --color-text-secondary: #8b95a5;
    --color-text-muted: #5a6577;
    --color-brand-light: #8b95a5;

    --color-border: #2a3545;
    --color-border-light: #1f2937;

    --shadow-sm: 0 1px 6px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html.theme-dark .btn-outline-secondary {
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

html.theme-dark .dropdown-menu {
    background: var(--color-card);
    border-color: var(--color-border);
}

html.theme-dark .dropdown-item {
    color: var(--color-text);
}

html.theme-dark .dropdown-item:hover {
    background: var(--color-primary-light);
}

html.theme-dark .table {
    color: var(--color-text);
    --bs-table-bg: transparent;
    --bs-table-color: var(--color-text);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --bs-table-border-color: var(--color-border);
}

html.theme-dark .table thead th {
    color: var(--color-text-secondary);
    border-bottom-color: var(--color-border);
    background: rgba(255, 255, 255, 0.03);
}

html.theme-dark .table td,
html.theme-dark .table th {
    border-color: var(--color-border);
}

html.theme-dark .table-hover > tbody > tr:hover > * {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
}

html.theme-dark .card {
    background: var(--color-card);
    border-color: var(--color-border);
    color: var(--color-text);
}

html.theme-dark .card-header {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: var(--color-border);
    color: var(--color-text);
}

html.theme-dark .alert {
    border-color: var(--color-border);
}

html.theme-dark .badge.bg-secondary {
    background-color: var(--color-border) !important;
}

html.theme-dark .badge.bg-success {
    background-color: #065f46 !important;
}

html.theme-dark .text-muted {
    color: var(--color-text-secondary) !important;
}

html.theme-dark .border-bottom {
    border-bottom-color: var(--color-border) !important;
}

html.theme-dark .bg-light {
    background-color: var(--color-bg) !important;
}

html.theme-dark .notification-dropdown {
    background: var(--color-card);
    border-color: var(--color-border);
}

html.theme-dark .empty-state {
    color: var(--color-text-muted);
}

html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder {
    color: var(--color-text-muted) !important;
}

html.theme-dark .list-group-item {
    background-color: var(--color-card);
    border-color: var(--color-border);
    color: var(--color-text);
}

html.theme-dark .list-group-item-action:hover,
html.theme-dark .list-group-item-action:focus {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
}

html.theme-dark .page-heading {
    color: var(--color-text);
}

html.theme-dark .input-group-text {
    background-color: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

html.theme-dark .form-control,
html.theme-dark .form-select {
    background: var(--color-bg);
    border-color: var(--color-border);
    color: var(--color-text);
}

html.theme-dark .modal-content {
    background: var(--color-card);
    color: var(--color-text);
}

/* ── Base ──────────────────────────────────────────────────── */

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    line-height: 1.55;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    transition: var(--transition);
}

/* ── HTMX Progress Bar ────────────────────────────────────── */

#htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--color-accent);
    z-index: 9999;
    transition: width 0.3s ease;
    pointer-events: none;
}

#htmx-progress.active {
    animation: htmx-progress-anim 2s ease-in-out infinite;
}

@keyframes htmx-progress-anim {
    0%   { width: 0; }
    50%  { width: 70%; }
    100% { width: 90%; }
}

#htmx-progress.done {
    width: 100%;
    opacity: 0;
    transition: width 0.2s ease, opacity 0.3s ease 0.2s;
}

/* ── Navbar ────────────────────────────────────────────────── */

.app-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--color-navbar);
    border-bottom: 1px solid var(--color-border);
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
}

.app-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    margin-right: 1rem;
}

.app-navbar .navbar-brand .brand-icon {
    width: 28px;
    height: 28px;
    color: var(--color-primary);
}

.app-navbar .navbar-brand .brand-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

.app-navbar .navbar-brand .brand-suffix {
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--color-brand-light);
}

.app-navbar .navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-navbar .btn-new-quote {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-btn);
    background: var(--color-primary);
    color: #fff;
    border: none;
    transition: var(--transition);
    letter-spacing: 0.01em;
}

.app-navbar .btn-new-quote:hover {
    background: var(--color-primary-hover);
    color: #fff;
}

.app-navbar .navbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    position: relative;
    transition: var(--transition);
    cursor: pointer;
}

.app-navbar .navbar-icon-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.app-navbar .notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    border: 2px solid var(--color-navbar);
}

.app-navbar .user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-btn);
    border: none;
    background: transparent;
    color: var(--color-text);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.app-navbar .user-dropdown-toggle:hover {
    background: var(--color-primary-light);
}

.app-navbar .user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ── Sidebar ───────────────────────────────────────────────── */

.app-sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, transform 0.25s ease;
}

.app-sidebar::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 2px;
}

.sidebar-section {
    padding: 1.25rem 0 0.25rem;
}

.sidebar-section:first-child {
    padding-top: 0.75rem;
}

.sidebar-section-title {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    padding: 0 1.25rem 0.5rem;
    margin: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 1.25rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 450;
    border-left: 3px solid transparent;
    transition: var(--transition);
}

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

.sidebar-nav .nav-link.active {
    color: var(--color-primary);
    background: var(--color-primary-light);
    border-left-color: var(--color-primary);
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link .nav-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-badge);
    background: var(--color-accent);
    color: #fff;
}

.sidebar-collapse-btn {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    background: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
}

.sidebar-collapse-btn:hover {
    color: var(--color-text-secondary);
    background: var(--color-primary-light);
}

/* Collapsed sidebar */
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.app-sidebar.collapsed .sidebar-section-title,
.app-sidebar.collapsed .nav-link span,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .sidebar-collapse-btn span {
    display: none;
}

.app-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.625rem;
}

.app-sidebar.collapsed .nav-link i {
    font-size: 1.125rem;
}

/* ── Main Content ──────────────────────────────────────────── */

.app-main {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: 1.5rem;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.2s ease;
}

.app-main.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

/* Page heading */
.page-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.25rem;
}

.page-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

/* ── Cards ─────────────────────────────────────────────────── */

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.card-body {
    padding: 1.25rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Static cards (no hover effect) */
.card-static,
.card-static:hover {
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
}

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: var(--radius-btn);
    padding: 0.4rem 0.875rem;
    transition: var(--transition);
}

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

.btn-primary:hover,
.btn-primary:focus {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    color: #fff;
}

.btn-accent {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.btn-accent:hover,
.btn-accent:focus {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: #fff;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.3rem 0.625rem;
}

.btn-lg {
    font-size: 0.9375rem;
    padding: 0.55rem 1.25rem;
}

/* ── Tables ────────────────────────────────────────────────── */

.table {
    font-size: 0.8125rem;
}

.table > thead > tr > th {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    padding: 0.625rem 0.75rem;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 0.625rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border-light);
}

.table > tbody > tr:hover {
    background: var(--color-primary-light);
}

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

/* ── Forms ─────────────────────────────────────────────────── */

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

.form-control,
.form-select {
    font-size: 0.8125rem;
    border-radius: var(--radius-input);
    border-color: var(--color-border);
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.form-text {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ── Badges ────────────────────────────────────────────────── */

.badge {
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: var(--radius-badge);
    padding: 0.3em 0.6em;
    letter-spacing: 0.01em;
}

/* Status badges */
.badge-status-draft {
    background-color: #6c757d;
    color: #fff;
}

.badge-status-sent {
    background-color: #213150;
    color: #fff;
}

.badge-status-opened {
    background-color: #e8a317;
    color: #fff;
}

.badge-status-accepted {
    background-color: #198754;
    color: #fff;
}

.badge-status-refused {
    background-color: #dc3545;
    color: #fff;
}

.badge-status-expired {
    background-color: #343a40;
    color: #fff;
}

/* ── Quote Editor ──────────────────────────────────────────── */

.quote-editor {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.quote-lines-table {
    width: 100%;
    border-collapse: collapse;
}

.quote-lines-table th {
    background: var(--color-bg);
    padding: 0.5rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
}

.quote-lines-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
    font-size: 0.8125rem;
}

.quote-lines-table tr:hover {
    background: var(--color-primary-light);
}

.quote-lines-table .drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    width: 2rem;
    text-align: center;
}

.quote-lines-table .drag-handle:active {
    cursor: grabbing;
}

.quote-lines-table .line-actions {
    width: 3rem;
    text-align: center;
}

.section-header {
    background: var(--color-primary-light);
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
}

.quote-totals {
    background: var(--color-bg);
    border-top: 2px solid var(--color-border);
    padding: 1rem 1.5rem;
}

.quote-totals .total-row {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.quote-totals .total-row.grand-total {
    font-size: 1.1rem;
    font-weight: 700;
    border-top: 2px solid var(--color-primary);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.quote-totals .total-label {
    min-width: 140px;
    text-align: right;
    color: var(--color-text-secondary);
}

.quote-totals .total-value {
    min-width: 120px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.quote-action-bar {
    padding: 1rem 1.5rem;
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    z-index: 1010;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

/* ── Client search dropdown constraint ────────────────────── */

#client-results,
.search-dropdown {
    max-height: 240px;
    overflow-y: auto;
}

/* ── Save indicator ───────────────────────────────────────── */

.save-indicator {
    color: var(--color-success);
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-left: 1rem;
    white-space: nowrap;
}

.save-indicator.visible {
    opacity: 1;
}

/* ── Pipeline Kanban ───────────────────────────────────────── */

.pipeline-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.pipeline-column {
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    background: var(--color-bg);
    border-radius: var(--radius-card);
    border: 1px solid var(--color-border);
}

.pipeline-column-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pipeline-column-body {
    padding: 0.5rem;
    min-height: 100px;
}

.pipeline-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-btn);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.pipeline-card .card-client {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

.pipeline-card .card-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── KPI Cards ─────────────────────────────────────────────── */

.kpi-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    text-align: center;
    transition: var(--transition);
}

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

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    color: var(--color-primary);
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.kpi-card .kpi-trend {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

.kpi-card .kpi-trend.up {
    color: var(--color-success);
}

.kpi-card .kpi-trend.down {
    color: var(--color-danger);
}

/* ── Timeline ──────────────────────────────────────────────── */

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

.timeline-event {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-event::before {
    content: "";
    position: absolute;
    left: -1.625rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-card);
    box-shadow: 0 0 0 2px var(--color-primary);
}

.timeline-event.event-sent::before {
    background: var(--color-info);
    box-shadow: 0 0 0 2px var(--color-info);
}

.timeline-event.event-opened::before {
    background: var(--color-warning);
    box-shadow: 0 0 0 2px var(--color-warning);
}

.timeline-event.event-accepted::before {
    background: var(--color-success);
    box-shadow: 0 0 0 2px var(--color-success);
}

.timeline-event.event-refused::before {
    background: var(--color-danger);
    box-shadow: 0 0 0 2px var(--color-danger);
}

.timeline-event .event-time {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.timeline-event .event-text {
    font-size: 0.8125rem;
}

/* ── Toast Container ───────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: calc(var(--navbar-height) + 0.75rem);
    right: 1rem;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    border-radius: var(--radius-btn);
    box-shadow: var(--shadow-md);
}

/* ── Notification Dropdown ─────────────────────────────────── */

.notification-dropdown {
    width: 360px;
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-btn);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}

.notification-dropdown .notification-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.notification-dropdown .notification-item:hover {
    background: var(--color-primary-light);
}

.notification-dropdown .notification-item.unread {
    background: rgba(14, 165, 233, 0.06);
}

.notification-dropdown .notif-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.notification-dropdown .notif-body {
    flex: 1;
    min-width: 0;
}

.notification-dropdown .notif-title {
    font-size: 0.8125rem;
    font-weight: 500;
}

.notification-dropdown .notif-time {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

/* ── Search Overlay (Cmd+K) ───────────────────────────────── */

.search-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1050;
    backdrop-filter: blur(2px);
}

.search-overlay {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, 90vw);
    max-height: 70vh;
    background: var(--color-card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    z-index: 1051;
    overflow: hidden;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    margin: 0 0.75rem;
    background: transparent;
    color: var(--color-text);
}

.search-input-wrapper kbd {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.search-results {
    max-height: 50vh;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-light);
    text-decoration: none;
    color: var(--color-text);
    transition: var(--transition);
}

.search-result-item:hover {
    background: var(--color-primary-light);
}

.search-result-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
}

/* ── FAB: New Quote (mobile) ──────────────────────────────── */

.fab-new-quote {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 1040;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab-new-quote:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    color: white;
}

/* ── Bulk Action Bar ──────────────────────────────────────── */

.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 0.75rem 1.5rem;
    background: var(--color-card);
    border-top: 2px solid var(--color-primary);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1030;
    display: flex;
    align-items: center;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ── HTMX Loading Indicators ──────────────────────────────── */

.htmx-indicator {
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
    opacity: 1;
}

/* Fade content while loading */
.htmx-swapping {
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

/* Spinner */
.htmx-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: htmx-spin 0.6s linear infinite;
}

.htmx-request .htmx-spinner {
    display: inline-block;
}

@keyframes htmx-spin {
    to { transform: rotate(360deg); }
}

/* ── Modals ────────────────────────────────────────────────── */

.modal-content {
    border-radius: var(--radius-card);
    border: none;
    box-shadow: var(--shadow-lg);
}

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

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

.modal-body {
    padding: 1.25rem;
}

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

/* ── Empty States ──────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-secondary);
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    display: block;
}

.empty-state .empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.empty-state .empty-description {
    font-size: 0.8125rem;
    max-width: 360px;
    margin: 0 auto 1rem;
}

/* ── Swiss Formatting Helpers ──────────────────────────────── */

.text-chf {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.text-percent {
    font-variant-numeric: tabular-nums;
}

/* ── Mobile Sidebar Toggle ─────────────────────────────────── */

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-btn);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1015;
}

/* ── Print Styles ──────────────────────────────────────────── */

@media print {
    .app-navbar,
    .app-sidebar,
    .toast-container,
    .quote-action-bar,
    .sidebar-toggle,
    .no-print {
        display: none !important;
    }

    .app-main {
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .quote-lines-table th,
    .quote-lines-table td {
        border: 1px solid #ccc !important;
    }

    a[href]::after {
        content: none !important;
    }

    body {
        font-size: 11pt;
        color: #000;
    }
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 991.98px) {
    .sidebar-toggle {
        display: flex;
    }

    .app-sidebar {
        transform: translateX(-100%);
        z-index: 1025;
        box-shadow: none;
    }

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

    .sidebar-overlay.active {
        display: block;
    }

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

    .quote-action-bar {
        left: 0;
    }

    .pipeline-board {
        flex-direction: column;
    }

    .pipeline-column {
        max-width: none;
        min-width: auto;
    }

    .page-heading-row {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .kpi-card {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 767.98px) {
    .table-quotes { font-size: 0.75rem; }
    .table-quotes .badge { font-size: 0.6rem; }
}

@media (max-width: 575.98px) {
    .app-main {
        padding: 1rem;
    }

    .app-navbar {
        padding: 0 0.75rem;
    }

    .notification-dropdown {
        width: calc(100vw - 2rem);
    }

    .search-overlay {
        width: calc(100vw - 2rem);
    }
}
