/* ============================================
   LAYOUT
   ============================================ */

/* ─── LOGIN ─────────────────────────────────────── */
#login-screen {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(59,130,246,0.08) 0%, transparent 60%), var(--bg-0);
}
.login-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 380px;
    box-shadow: var(--shadow);
    animation: fadeUp 0.5s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.login-card h1 {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}
.login-card .sub { color: var(--text-2); font-size: 14px; margin-bottom: 32px; }
.login-card .logo-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 20px;
    color: white; margin-bottom: 20px;
}

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-2); text-transform: uppercase;
    letter-spacing: 0.8px; margin-bottom: 6px;
}
input, select, textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-0);
    font-family: var(--font-body); font-size: 14px;
    transition: border var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-family: var(--font-body); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all var(--transition); outline: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-1); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-3); border-color: var(--border-light); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }

.login-error {
    background: var(--red-dim); color: var(--red);
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 13px; margin-bottom: 16px; display: none;
}

/* ─── APP SHELL ─────────────────────────────────── */
#app { display: none; min-height: 100vh; }
#app.active { display: flex; flex-direction: row; }

/* ─── LEFT SIDEBAR NAV ─────────────────────────────── */
.app-sidebar {
    width: 200px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    height: 100vh;
    position: sticky; top: 0;
    overflow-y: auto; overflow-x: hidden;
    transition: width 0.2s ease;
    z-index: 110;
    flex-shrink: 0;
}
[data-sidebar="collapsed"] .app-sidebar { width: 56px; }

.sb-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 14px; gap: 8px;
    border-bottom: 1px solid var(--border);
}
.sb-brand { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sb-logo {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent); display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: white;
    flex-shrink: 0;
}
.sb-brand-text {
    font-family: var(--font-mono); font-weight: 700; font-size: 15px;
    letter-spacing: -0.3px; white-space: nowrap;
}
[data-sidebar="collapsed"] .sb-brand-text { display: none; }
.sb-collapse-btn {
    background: none; border: none; color: var(--text-2);
    cursor: pointer; padding: 6px; border-radius: 6px;
    transition: background var(--transition); flex-shrink: 0;
}
.sb-collapse-btn:hover { background: var(--bg-3); }

.sb-new-booking {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 12px 10px 4px; padding: 10px 14px;
    background: var(--accent); color: white; border: none;
    border-radius: var(--radius-sm); font-family: var(--font-body);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background 0.2s; white-space: nowrap; overflow: hidden;
}
.sb-new-booking:hover { background: var(--accent-hover); }
[data-sidebar="collapsed"] .sb-new-booking { padding: 10px; }
[data-sidebar="collapsed"] .sb-new-booking .sb-label { display: none; }

.sb-nav {
    flex: 1; padding: 8px 0; overflow-y: auto;
}
.sb-section {
    padding: 16px 16px 6px;
    font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
    color: var(--text-2); text-transform: uppercase; white-space: nowrap;
}
[data-sidebar="collapsed"] .sb-section {
    text-indent: -999px; padding: 12px 0 4px;
    border-top: 1px solid var(--border); margin: 4px 10px 0;
}

.sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; margin: 1px 8px;
    font-size: 13px; font-weight: 500; color: var(--text-2);
    cursor: pointer; border-radius: 6px;
    transition: all var(--transition); white-space: nowrap;
    position: relative; border-left: 2px solid transparent;
}
.sb-item:hover { background: var(--bg-2); color: var(--text-1); }
.sb-item.active {
    background: var(--accent-glow); color: var(--accent);
    font-weight: 600; border-left-color: var(--accent);
}
.sb-item svg { flex-shrink: 0; }
.sb-item .sb-label { overflow: hidden; text-overflow: ellipsis; }
[data-sidebar="collapsed"] .sb-item { justify-content: center; padding: 10px; margin: 1px 6px; }
[data-sidebar="collapsed"] .sb-item .sb-label { display: none; }
[data-sidebar="collapsed"] .sb-item { border-left: none; }
[data-sidebar="collapsed"] .sb-item.active { border-left: none; }

/* Tooltips in collapsed mode */
[data-sidebar="collapsed"] .sb-item { position: relative; }
[data-sidebar="collapsed"] .sb-item:hover::after {
    content: attr(data-view);
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    margin-left: 8px; padding: 5px 10px;
    background: var(--bg-0); color: var(--text-0);
    border: 1px solid var(--border-light);
    border-radius: 6px; font-size: 12px; font-weight: 600;
    white-space: nowrap; z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-transform: capitalize;
}

/* Request badge */
.sb-badge {
    margin-left: auto; padding: 2px 8px;
    background: var(--red); color: white;
    border-radius: 10px; font-size: 10px; font-weight: 700;
    min-width: 18px; text-align: center; line-height: 1.3;
}
.sb-badge:empty { display: none; }
[data-sidebar="collapsed"] .sb-badge {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; min-width: 8px;
    padding: 0; font-size: 0; border-radius: 50%;
}

.sb-logout { color: var(--red); }
.sb-logout:hover { background: var(--red-dim); color: var(--red); }

.sb-bottom {
    border-top: 1px solid var(--border);
    padding: 8px 0 12px;
}

/* ─── MAIN CONTENT AREA ───────────────────────────── */
.app-main { flex: 1; display: flex; overflow: hidden; min-width: 0; }
.content { flex: 1; padding: 24px 28px; overflow-y: auto; }
.cal-sidebar {
    width: 300px; background: var(--bg-1);
    border-left: 1px solid var(--border);
    padding: 24px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 20px;
}

/* Calendar view toggle (Month/Week) */
.cal-view-toggle {
    display: flex; gap: 2px;
    background: var(--bg-2); border-radius: 8px; padding: 3px;
}
.cvt-btn {
    padding: 6px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-2);
    cursor: pointer; transition: all var(--transition); border: none; background: none;
}
.cvt-btn:hover { color: var(--text-1); }
.cvt-btn.active { background: var(--accent); color: white; }

/* Sub-filter tabs (used inside views) */
.nav-tabs {
    display: flex; gap: 4px;
    background: var(--bg-2); border-radius: 8px; padding: 3px;
}
.nav-tab {
    padding: 7px 18px; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-2);
    cursor: pointer; transition: all var(--transition); border: none; background: none;
}
.nav-tab:hover { color: var(--text-1); }
.nav-tab.active { background: var(--accent); color: white; }

/* ─── RESPONSIVE ────────────────────────────────── */
@media (max-width: 1100px) {
    .cal-sidebar { display: none; }
}
@media (max-width: 900px) {
    .content { padding: 16px; }
    .modal .form-row { grid-template-columns: 1fr; }
    .dash-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .task-columns { grid-template-columns: 1fr; }
    .reminder-popup { width: 95%; padding: 24px; }
}

/* Searchable autocomplete dropdown */
.autocomplete-wrap {
    position: relative;
}
.autocomplete-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--bg-1);
    border: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--bg-3); }
.autocomplete-item .ac-name { font-weight: 600; }
.autocomplete-item .ac-sub { font-size: 11px; color: var(--text-2); }
.autocomplete-item .ac-new {
    font-size: 11px; color: var(--accent); font-weight: 600;
}

/* ─── LIST / GRID VIEW TOGGLE ──────────────────────────────
   The same cards, reflowed. Nothing re-renders — a class on the
   container turns the card grid into compact rows. */
.lg-toggle {
    display: flex; gap: 2px;
    background: var(--bg-2); border-radius: 8px; padding: 3px;
    flex-shrink: 0;
}
.lg-btn {
    width: 34px; height: 30px; border-radius: 6px;
    border: none; background: none; color: var(--text-2);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.lg-btn:hover { color: var(--text-1); }
.lg-btn.active { background: var(--accent); color: #fff; }
.lg-btn svg { width: 15px; height: 15px; display: block; }

/* ─── LIST MODE ─────────────────────────────────────────── */
.as-list { grid-template-columns: 1fr !important; gap: 8px !important; }

.as-list .cust-card,
.as-list .qt-card,
.as-list .wo-card {
    display: grid;
    align-items: center; gap: 16px;
    padding: 11px 16px;
}
/* name+price | vehicle | badges | actions — one line, no wrapping */
.as-list .qt-card,
.as-list .wo-card { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto auto; }
/* name | phone | stats */
.as-list .cust-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }

/* The bulky innards are what make a card a card — hide them in a row.
   Customer stats stay: they're the point of the row, just laid out inline. */
.as-list .qt-card-lines,
.as-list .qt-card-notes,
.as-list .wo-card-items,
.as-list .wo-card-notes { display: none; }

.as-list .cust-card-stats {
    display: flex; gap: 20px; margin: 0; padding: 0; border: none;
    justify-content: flex-end; white-space: nowrap;
}
.as-list .cust-card-stat { font-size: 12.5px; }

.as-list .qt-card-top,
.as-list .wo-card-top {
    display: flex; align-items: baseline; gap: 10px; margin: 0; min-width: 0;
}
.as-list .qt-card-name,
.as-list .wo-card-name,
.as-list .cust-card-name {
    font-size: 14px; margin: 0; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.as-list .qt-card-price,
.as-list .wo-card-price { font-size: 14px; margin: 0; white-space: nowrap; }
.as-list .qt-card-top,
.as-list .wo-card-top { justify-content: space-between; }
.as-list .qt-card-vehicle,
.as-list .wo-card-vehicle,
.as-list .cust-card-phone {
    font-size: 12.5px; margin: 0; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.as-list .qt-card-meta,
.as-list .wo-card-meta { margin: 0; gap: 6px; flex-wrap: nowrap; }
.as-list .qt-card-actions,
.as-list .wo-card-actions {
    margin: 0; padding: 0; border: none; gap: 6px; justify-content: flex-end;
}
.as-list .qt-action-btn { padding: 5px 10px; font-size: 11.5px; }

/* Below the two-column breakpoint a row has no room to be a row */
@media (max-width: 860px) {
    .as-list .cust-card,
    .as-list .qt-card,
    .as-list .wo-card { grid-template-columns: 1fr; gap: 6px; }
    .as-list .qt-card-actions,
    .as-list .wo-card-actions { justify-content: flex-start; }
}
