/* ============================================================
   Lupe's Garage — Custom Styles
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --sidebar-bg:       #0f0f1a;
    --sidebar-width:    260px;
    --accent:           #e63946;
    --accent-hover:     #c1121f;
    --sidebar-text:     #c8c8d8;
    --sidebar-hover-bg: rgba(230, 57, 70, 0.12);
    --sidebar-active-bg:#e63946;
    --card-shadow:      0 2px 12px rgba(0,0,0,0.08);
    --body-bg:          #f4f5f7;
    --topbar-bg:        #0f0f1a;
}

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

body {
    background-color: var(--body-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 0.925rem;
    color: #333;
}

/* ---------- Sidebar (desktop: fixed) ---------- */
.sidebar-wrapper {
    width: var(--sidebar-width) !important;
    background-color: var(--sidebar-bg) !important;
    border-right: 1px solid rgba(255,255,255,0.05) !important;
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

@media (min-width: 992px) {
    .sidebar-wrapper {
        transform: none !important;
        visibility: visible !important;
    }
    /* Prevent Bootstrap offcanvas backdrop from blocking inputs on desktop */
    .offcanvas-backdrop { display: none !important; }
    body.offcanvas-open { overflow: auto !important; padding-right: 0 !important; }
}

/* ---------- Main Content ---------- */
.main-content {
    min-height: 100vh;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

@media (min-width: 992px) {
    .main-content {
        margin-left: var(--sidebar-width);
        padding-top: 1.5rem;
    }
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        padding-top: 0;
    }
}

/* ---------- Mobile Top Bar ---------- */
.mobile-topbar {
    background-color: var(--topbar-bg) !important;
    padding: 0.6rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* ---------- Brand ---------- */
.sidebar-brand {
    padding: 1.2rem 1.2rem 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ---------- Dividers ---------- */
.sidebar-divider {
    border-color: rgba(255,255,255,0.08);
    margin: 0.5rem 1rem;
}

/* ---------- User Avatar ---------- */
.sidebar-user {
    padding: 0.75rem 1.2rem;
}
.avatar-circle {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

/* ---------- Role Badges ---------- */
.role-badge-admin   { background: #e63946; color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.role-badge-tech    { background: #457b9d; color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.role-badge-viewer  { background: #6c757d; color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }

/* ---------- Nav Section Labels ---------- */
.sidebar-section-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
    padding: 0.4rem 0.5rem 0.25rem;
    margin-bottom: 0.1rem;
}

/* ---------- Sidebar Links ---------- */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.18s, color 0.18s;
    margin-bottom: 2px;
}
.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}
.sidebar-link:hover {
    background: var(--sidebar-hover-bg);
    color: #fff;
}
.sidebar-link.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(230,57,70,0.4);
}
.sidebar-link.active i { color: #fff; }
.text-danger-light { color: #ff8a8a !important; }
.text-danger-light:hover { color: #ff4444 !important; }
.text-accent { color: var(--accent) !important; }

/* ---------- Cards ---------- */
.card {
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: 10px;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
    padding: 0.9rem 1.2rem;
}

/* ---------- Stat Cards ---------- */
.stat-card {
    border-left: 4px solid var(--accent);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-icon-red    { background: rgba(230,57,70,0.12);  color: var(--accent); }
.stat-icon-blue   { background: rgba(30,120,230,0.12); color: #1e78e6; }
.stat-icon-green  { background: rgba(34,197,94,0.12);  color: #16a34a; }
.stat-icon-orange { background: rgba(249,115,22,0.12); color: #ea580c; }
.stat-icon-purple { background: rgba(147,51,234,0.12); color: #9333ea; }

/* ---------- Status Badges ---------- */
.badge-status-open        { background: #1e78e6; color: #fff; }
.badge-status-in_progress { background: #f97316; color: #fff; }
.badge-status-completed   { background: #16a34a; color: #fff; }
.badge-status-cancelled   { background: #9ca3af; color: #fff; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* ---------- Tables ---------- */
.table-hover > tbody > tr:hover {
    background-color: rgba(230, 57, 70, 0.04);
}
.table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    font-weight: 700;
    border-bottom-width: 1px;
}

/* ---------- Buttons ---------- */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}
.btn-primary {
    background: #1e78e6;
    border-color: #1e78e6;
}
.btn-primary:hover {
    background: #1460b8;
    border-color: #1460b8;
}

/* ---------- Page Header ---------- */
.page-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 0.875rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(230,57,70,0.15);
}

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    overflow: hidden;
}
.login-header {
    background: linear-gradient(135deg, var(--accent) 0%, #c1121f 100%);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    color: #fff;
}
.login-header .logo-icon {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    border: 2px solid rgba(255,255,255,0.3);
}
.login-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; }
.login-header p  { opacity: 0.85; margin: 0.25rem 0 0; font-size: 0.9rem; }
.login-body { padding: 2rem; }

/* ---------- Repeating Rows (Parts/Labor) ---------- */
.repeating-row {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    position: relative;
}
.remove-row-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.remove-row-btn:hover { background: #fee2e2; }

/* ---------- Totals Box ---------- */
.totals-box {
    background: #1a1a2e;
    color: #fff;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
}
.totals-box .totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}
.totals-box .totals-row.total-line {
    border-top: 1px solid rgba(255,255,255,0.2);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
}

/* ---------- Setup / Admin Misc ---------- */
.setup-page {
    min-height: 100vh;
    background: var(--body-bg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem;
}
.connection-status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}
.dot-green  { background: #16a34a; box-shadow: 0 0 6px #16a34a; }
.dot-red    { background: #dc3545; box-shadow: 0 0 6px #dc3545; }
.dot-grey   { background: #9ca3af; }

/* ---------- Print Styles ---------- */
@media print {
    .sidebar-wrapper, .mobile-topbar, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ---------- Scrollbar (WebKit) ---------- */
.sidebar-wrapper::-webkit-scrollbar { width: 4px; }
.sidebar-wrapper::-webkit-scrollbar-track { background: transparent; }
.sidebar-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ---------- Tab Filters ---------- */
.filter-tabs .nav-link {
    color: #555;
    border-radius: 20px;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.filter-tabs .nav-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.filter-tabs .nav-link:hover:not(.active) {
    background: rgba(230,57,70,0.08);
    color: var(--accent);
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 575.98px) {
    .page-header h1 { font-size: 1.1rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
}

/* ---------- Language switcher ---------- */
.lang-btn {
    color: rgba(255,255,255,0.5);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.lang-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.lang-btn.lang-active {
    color: #fff;
    background: var(--accent);
}
