/* ═══════════════════════════════════════════════════════════════
   JR Tuning Booking — Main Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
    --sidebar-width:    230px;
    --topbar-height:    56px;
    --sidebar-bg:       #1a2535;
    --sidebar-text:     #a8b5c5;
    --sidebar-hover:    rgba(255,255,255,0.07);
    --sidebar-active:   rgba(255,255,255,0.12);
    --sidebar-border:   rgba(255,255,255,0.06);
    --accent:           #e63946;
    --accent-hover:     #c1121f;
    --topbar-bg:        #ffffff;
    --content-bg:       #f4f6f9;
    --card-shadow:      0 1px 4px rgba(0,0,0,0.08);
}

/* ─── Base ───────────────────────────────────────────────────── */
body {
    background: var(--content-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9rem;
    color: #333;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    color: #ffffff;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

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

.sidebar-close {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

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

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

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

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

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

.nav-icon {
    width: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--sidebar-text);
    flex-shrink: 0;
}

.nav-divider {
    border-top: 1px solid var(--sidebar-border);
    margin: 0.5rem 0;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
}

.sidebar-logout {
    color: var(--sidebar-text) !important;
    font-size: 1rem;
    padding: 0.35rem;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.sidebar-logout:hover {
    color: var(--accent) !important;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1039;
}

/* ─── Main wrapper / topbar ───────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid #e8eaf0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #555;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a2535;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ─── Accent button ───────────────────────────────────────────── */
.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
    border: 1px solid #e8eaf0;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e8eaf0;
    font-weight: 600;
    padding: 0.85rem 1.25rem;
}

/* ─── Stat cards (dashboard) ──────────────────────────────────── */
.stat-card {
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 2px;
}

.stat-card-today     { background: linear-gradient(135deg, #1e6fc5, #2d8ef5); }
.stat-card-week      { background: linear-gradient(135deg, #6f42c1, #9561e2); }
.stat-card-pending   { background: linear-gradient(135deg, #e67e22, #f39c12); }
.stat-card-completed { background: linear-gradient(135deg, #27ae60, #2ecc71); }

/* ─── Tables ──────────────────────────────────────────────────── */
.table th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
    font-size: 0.875rem;
}

/* ─── VRN badge ───────────────────────────────────────────────── */
.vrn-badge {
    display: inline-block;
    background: #ffdd00;
    color: #000;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    font-family: 'Courier New', monospace;
    border: 1px solid #cca800;
}

/* ─── Page header strip ───────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a2535;
    margin: 0;
}

/* ─── Search bar ──────────────────────────────────────────────── */
.search-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   CALENDAR
   ═══════════════════════════════════════════════════════════════ */
.cal-wrapper {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e8eaf0;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8eaf0;
    background: #fff;
    gap: 1rem;
}

.cal-nav-center {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a2535;
    min-width: 180px;
    text-align: center;
}

.cal-nav-btn {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #495057;
    font-size: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
    text-decoration: none;
}

.cal-nav-btn:hover {
    background: #f0f2f5;
    border-color: #ced4da;
    color: #1a2535;
}

.cal-today-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    color: #495057;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
}

.cal-today-btn:hover {
    background: #f0f2f5;
    color: #1a2535;
}

/* Grid */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-left: 1px solid #e8eaf0;
}

.cal-dow {
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    background: #f8f9fa;
    border-right: 1px solid #e8eaf0;
    border-bottom: 1px solid #e8eaf0;
}

.cal-cell {
    height: 128px;
    overflow: hidden;
    padding: 4px;
    border-right: 1px solid #e8eaf0;
    border-bottom: 1px solid #e8eaf0;
    background: #fff;
    position: relative;
    vertical-align: top;
}

.cal-cell.other-month {
    background: #fafbfc;
}

.cal-cell.today {
    background: #fffbf5;
}

.cal-cell.weekend {
    background: #fdfdfe;
}

.cal-date-link {
    text-decoration: none;
}

.cal-date {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #495057;
    border-radius: 50%;
    margin-bottom: 2px;
    transition: background 0.15s;
}

.cal-date-link:hover .cal-date {
    background: #f0f2f5;
}

.cal-cell.other-month .cal-date {
    color: #bcc4ce;
}

.cal-cell.today .cal-date {
    background: var(--sidebar-bg);
    color: #fff;
    font-weight: 700;
}

/* Event pills */
.cal-event {
    display: block;
    font-size: 0.68rem;
    line-height: 1.4;
    padding: 1px 5px;
    border-radius: 3px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    color: #fff;
    transition: opacity 0.15s;
}

.cal-event:hover {
    opacity: 0.82;
    color: #fff;
}

.cal-event .ev-time {
    font-weight: 600;
    margin-right: 3px;
}

.cal-ev-pending    { background-color: #e0a800; color: #000 !important; }
.cal-ev-confirmed  { background-color: #1e6fc5; }
.cal-ev-completed  { background-color: #27ae60; }
.cal-ev-cancelled  { background-color: #c0392b; }

.cal-more {
    font-size: 0.68rem;
    color: #6c757d;
    padding: 0 5px;
    display: block;
}

/* Mobile calendar — list view toggle */
.cal-list-view {
    display: none;
}

/* ─── Status badges ───────────────────────────────────────────── */
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.3em 0.6em;
}

/* ─── Mobile responsiveness ───────────────────────────────────── */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

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

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

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

    .topbar {
        padding: 0 1rem;
    }

    .page-content {
        padding: 1rem;
    }

    /* Calendar on mobile — show list instead of grid */
    .cal-grid-wrap {
        display: none;
    }

    .cal-list-view {
        display: block;
        padding: 0.5rem 1rem 1rem;
    }

    .cal-list-day {
        margin-bottom: 0.75rem;
    }

    .cal-list-day-header {
        font-weight: 700;
        font-size: 0.8rem;
        color: #1a2535;
        padding: 0.25rem 0;
        border-bottom: 1px solid #e8eaf0;
        margin-bottom: 0.35rem;
    }

    .cal-list-day-header.today {
        color: var(--accent);
    }

    /* Wider table cells on mobile — hide less important columns */
    .d-mob-none {
        display: none !important;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.6rem;
    }
}

@media (min-width: 768px) {
    .cal-nav-mobile-only {
        display: none;
    }
}

/* ─── Booking view page ───────────────────────────────────────── */
.booking-meta dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    font-weight: 600;
}

.booking-meta dd {
    font-size: 0.9rem;
    color: #1a2535;
    margin-bottom: 0.85rem;
}

/* ─── Inline modal / quick-add forms ─────────────────────────── */
.modal-header {
    background: var(--sidebar-bg);
    color: #fff;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* ─── Customer/Vehicle select in bookings ─────────────────────── */
.customer-select-wrap,
.vehicle-select-wrap {
    position: relative;
}

/* ─── Login page ──────────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    background: linear-gradient(145deg, #1a2535 0%, #243447 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border: none;
}

.login-logo {
    font-size: 2.5rem;
    color: var(--accent);
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a2535;
}

/* ─── Customer live search ────────────────────────────────────── */
.customer-search-wrap {
    position: relative;
}

.customer-search-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.csr-item {
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f5;
    font-size: 0.85rem;
    transition: background 0.1s;
}

.csr-item:last-child { border-bottom: none; }
.csr-item:hover,
.csr-item.active    { background: #f0f4f8; }

.csr-item .csr-name { font-weight: 600; color: #1a2535; }
.csr-item .csr-meta { font-size: 0.75rem; color: #6c757d; margin-top: 1px; }
.csr-item.csr-no-results { color: #6c757d; cursor: default; }
.csr-item.csr-no-results:hover { background: none; }

/* ─── Utilities ───────────────────────────────────────────────── */
.text-muted-sm {
    font-size: 0.78rem;
    color: #6c757d;
}

.fw-600 { font-weight: 600; }

.rounded-lg { border-radius: 10px; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
