/**
 * Crouse — Main stylesheet
 * Supports Light/Dark mode via CSS variables
 */

/* ── Theme Variables ── */
:root,
[data-theme="light"] {
    --bs-font-sans-serif: "Vazirmatn", sans-serif;
    --bs-body-font-family: "Vazirmatn", sans-serif;
    --bg-body: #f0f2f5;
    --bg-sidebar: #1a1d23;
    --bg-card: #ffffff;
    --bg-topbar: #ffffff;
    --text-primary: #1a1d23;
    --text-secondary: #6c757d;
    --text-sidebar: #adb5bd;
    --text-sidebar-active: #ffffff;
    --border-color: #dee2e6;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bs-font-sans-serif: "Vazirmatn", sans-serif;
    --bs-body-font-family: "Vazirmatn", sans-serif;
    --bg-body: #0f1117;
    --bg-sidebar: #161822;
    --bg-card: #1a1d27;
    --bg-topbar: #1a1d27;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-sidebar: #868e96;
    --text-sidebar-active: #ffffff;
    --border-color: #2d3142;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ── Base ── */
body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: "Vazirmatn", sans-serif;
    transition: background 0.3s, color 0.3s;
}

input,
textarea,
select,
button,
.btn,
.form-control,
.form-select,
.dropdown-menu,
.table,
.modal,
.navbar,
.sidebar,
.topbar,
.page-content,
h1, h2, h3, h4, h5, h6,
p, span, label, td, th, a {
    font-family: "Vazirmatn", sans-serif;
}

a {
    color: var(--accent);
}

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--accent);
}

.sidebar-nav {
    padding: 0.75rem 0 1rem;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 5.5rem);
}

.nav-divider {
    height: 1px;
    margin: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-nav .nav-sublink {
    padding-right: 2.35rem;
    font-size: 0.84rem;
    opacity: 0.92;
}

.sidebar-nav .nav-sublink i {
    font-size: 0.95rem;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-sidebar);
    font-size: 0.88rem;
    text-align: right;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.nav-group-toggle:hover,
.nav-group-toggle.active {
    color: var(--text-sidebar-active);
    background: rgba(255, 255, 255, 0.05);
}

.nav-group-toggle.active {
    border-right-color: rgba(79, 70, 229, 0.5);
}

.nav-group-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-group-toggle .nav-chevron {
    font-size: 0.75rem;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.nav-group-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    padding-bottom: 0.15rem;
}

.sidebar-nav-footer {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link:hover {
    color: var(--text-sidebar-active);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav .nav-link.active {
    color: var(--text-sidebar-active);
    background: rgba(79, 70, 229, 0.15);
    border-right-color: var(--accent);
}

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

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow);
}

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

.theme-toggle,
.sidebar-toggle {
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
}

.theme-toggle:hover,
.sidebar-toggle:hover {
    color: var(--accent);
}

.user-menu {
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Page Content ── */
.page-content {
    padding: 1.5rem;
    flex: 1;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header h2 i {
    color: var(--accent);
    margin-left: 0.5rem;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-primary .stat-icon   { background: rgba(79, 70, 229, 0.12); color: #4f46e5; }
.stat-success .stat-icon   { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.stat-warning .stat-icon   { background: rgba(234, 179, 8, 0.12); color: #eab308; }
.stat-info .stat-icon      { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.stat-danger .stat-icon    { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.stat-secondary .stat-icon { background: rgba(108, 117, 125, 0.12); color: #6c757d; }

.stat-value-sm {
    font-size: 1.1rem;
}

/* ── Repair Status Badges ── */
.badge.status-pending       { background: #6c757d; }
.badge.status-in_progress   { background: #0d6efd; }
.badge.status-waiting_parts { background: #fd7e14; }
.badge.status-ready         { background: #198754; }
.badge.status-delivered     { background: #20c997; }
.badge.status-cancelled     { background: #dc3545; }

/* ── Repair timeline ── */
.repair-timeline {
    position: relative;
    padding-right: 1.5rem;
    margin: 0;
    list-style: none;
}

.repair-timeline::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    bottom: 0.5rem;
    right: 0.45rem;
    width: 2px;
    background: var(--border-color);
}

.repair-timeline-item {
    position: relative;
    padding: 0 0 1.25rem 0;
}

.repair-timeline-item:last-child {
    padding-bottom: 0;
}

.repair-timeline-dot {
    position: absolute;
    right: -1.5rem;
    top: 0.35rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--accent);
}

.repair-timeline-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 0.65rem;
    padding: 0.85rem 1rem;
}

.repair-summary-grid,
.panel-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
}

.panel-summary-item {
    min-height: 88px;
}

.panel-summary-item .stat-info {
    flex: 1;
    min-width: 0;
}

.panel-summary-item .stat-value {
    font-size: 1.35rem;
    line-height: 1.3;
    word-break: break-word;
}

.repair-summary-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 88px;
}

.repair-summary-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.repair-summary-item .label,
.repair-summary-item .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.repair-summary-item .value,
.repair-summary-item .stat-value {
    display: block;
    font-weight: 700;
    font-size: 1.35rem;
    line-height: 1.3;
}

.intake-section,
.panel-section {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    background: var(--bg-card);
}

.intake-section-title,
.panel-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.intake-section-title i,
.panel-section-title i {
    color: var(--accent);
}

.panel-report-card {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    height: 100%;
}

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

.panel-report-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-report-card h5 {
    margin-bottom: 0;
    font-size: 1rem;
}

.panel-report-card .actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.status-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.status-filter-pill:hover,
.status-filter-pill.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(79, 70, 229, 0.08);
}

.status-filter-pill .count {
    background: var(--bg-body);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

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

/* ── Card Header ── */
.card-header h5 i {
    margin-left: 0.5rem;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

/* ── Tables ── */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Auth Pages ── */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
}

.auth-theme-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 10;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: rgba(79, 70, 229, 0.12);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 2rem;
    color: var(--accent);
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

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

/* ── Form Controls (Dark mode) ── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #252836;
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: #252836;
    color: var(--text-primary);
}

[data-theme="dark"] .input-group-text {
    background: #252836;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ── Section Select Page ── */
.section-select-card {
    max-width: 480px;
}

.section-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--bg-body);
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    color: var(--text-primary);
}

.section-card:hover {
    border-color: var(--accent);
    background: rgba(79, 70, 229, 0.06);
    transform: translateX(-4px);
}

.section-card-mechanic:hover { border-color: #eab308; background: rgba(234, 179, 8, 0.08); }
.section-card-parts_store:hover { border-color: #22c55e; background: rgba(34, 197, 94, 0.08); }

.section-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.section-card-mechanic .section-card-icon { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.section-card-parts_store .section-card-icon { background: rgba(34, 197, 94, 0.15); color: #22c55e; }

.section-card-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.section-card-text strong { font-size: 1.05rem; }
.section-card-text small { color: var(--text-secondary); font-size: 0.8rem; }

.section-card-arrow {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ── Compact Intake Form ── */
.intake-form-wrap {
    max-width: 520px;
    margin: 0 auto;
}

.intake-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.intake-form-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.intake-form-head-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(79, 70, 229, 0.12);
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}

.intake-form-head-text h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.intake-form-head-text p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
}

.intake-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.75rem;
}

.intake-form-grid .span-2 {
    grid-column: 1 / -1;
}

.compact-field {
    margin-bottom: 0;
}

.compact-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.compact-label i {
    color: var(--accent);
    font-size: 0.85rem;
}

.intake-vehicle-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.35rem 0.6rem;
    background: var(--bg-body);
    border-radius: 0.4rem;
    margin-top: 0.35rem;
    min-height: 1.75rem;
}

.intake-vehicle-chip i {
    color: var(--accent);
}

.intake-vehicle-chip.empty {
    opacity: 0.7;
}

.intake-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.intake-form-actions .btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
}

#intake_estimated_delivery {
    cursor: pointer;
}

@media (max-width: 575.98px) {
    .intake-form-grid {
        grid-template-columns: 1fr;
    }

    .intake-form-grid .span-2 {
        grid-column: auto;
    }
}

/* ── Workspace Badge in Sidebar ── */
.sidebar-workspace-badge {
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(79, 70, 229, 0.2);
    color: #a5b4fc;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.topbar-workspace {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

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

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

    .main-content {
        margin-right: 0;
    }
}
