/* ============================================
   Rider Dispatch Platform - Stylesheet
   Palette: Deep charcoal base + signal-teal accent (tracking/live theme)
   + amber for busy, red for alerts
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #0d141c;
    --bg-panel: #141d28;
    --bg-elevated: #1a2530;
    --border: #263241;
    --text: #eaf0f6;
    --text-dim: #8b9aab;
    --teal: #2dd4bf;
    --teal-dim: rgba(45, 212, 191, 0.14);
    --amber: #f5a623;
    --amber-dim: rgba(245, 166, 35, 0.14);
    --red: #f0554a;
    --red-dim: rgba(240, 85, 74, 0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.24), 0 8px 24px -12px rgba(0,0,0,0.4);
    --shadow-pop: 0 12px 32px -8px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    background-image: radial-gradient(circle at top right, rgba(45,212,191,0.05), transparent 40%);
    color: var(--text);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.01em;
}

a { color: var(--teal); text-decoration: none; }

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

.sidebar {
    width: 230px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 24px 14px;
    flex-shrink: 0;
}

.sidebar .brand {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}
.brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--teal), #1a9a89);
    display: inline-block;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 14px -4px rgba(45,212,191,0.5);
}
.brand-mark::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #08201c;
    transform: translate(-50%, -50%);
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 14px;
    position: relative;
    transition: background 0.15s, color 0.15s;
}
.sidebar nav a .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--bg-elevated); color: var(--text); }
.sidebar nav a.active { background: var(--teal-dim); color: var(--teal); }
.sidebar nav a.nav-logout { margin-top: 14px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 16px; }
.nav-badge {
    background: var(--amber); color: #2a1a00; font-size: 10px; font-weight: 700;
    border-radius: 10px; padding: 1px 6px; margin-left: auto;
}

.main {
    flex: 1;
    padding: 30px 40px;
    max-width: 1200px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
}

.topbar h1 { font-size: 23px; margin: 0; font-weight: 700; }

/* ---------- Cards / Panels ---------- */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
}
.stat-card .num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 30px;
    font-weight: 700;
    display: block;
}
.stat-card .label {
    color: var(--text-dim);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--bg-elevated); }

/* ---------- Status badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.badge-free { background: var(--teal-dim); color: var(--teal); }
.badge-free::before { background: var(--teal); }

.badge-busy { background: var(--amber-dim); color: var(--amber); }
.badge-busy::before { background: var(--amber); }

.badge-offline { background: rgba(139,154,171,0.15); color: var(--text-dim); }
.badge-offline::before { background: var(--text-dim); }

.badge-pending { background: var(--amber-dim); color: var(--amber); }
.badge-pending::before { background: var(--amber); }

.badge-completed { background: var(--teal-dim); color: var(--teal); }
.badge-completed::before { background: var(--teal); }

.badge-cancelled { background: var(--red-dim); color: var(--red); }
.badge-cancelled::before { background: var(--red); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.08s ease, filter 0.15s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--teal); color: #08201c; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-danger { background: var(--red-dim); color: var(--red); }
.btn-danger:hover { filter: brightness(1.15); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Toggle switch ---------- */
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 20px; transition: 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
    background: var(--text-dim); border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--teal-dim); border-color: var(--teal); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--teal); }

.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal);
}

.auth-wrap {
    max-width: 380px;
    margin: 8vh auto;
    padding: 32px;
}
.auth-wrap .brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 22px; margin-bottom: 24px; }

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

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.7; }
.empty-state p { margin: 0; max-width: 320px; margin-inline: auto; font-size: 14px; }

/* ---------- Skeleton loading ---------- */
.skeleton { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%); background-size: 200% 100%; animation: skeleton-sweep 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-sweep { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-card { height: 90px; border-radius: var(--radius); margin-bottom: 14px; }

/* ---------- Order progress timeline ---------- */
.order-timeline { display: flex; align-items: center; margin: 6px 0 18px; }
.tl-step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.tl-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-elevated); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; z-index: 1; transition: all 0.2s; }
.tl-dot svg { width: 12px; height: 12px; }
.tl-label { font-size: 10.5px; color: var(--text-dim); margin-top: 6px; text-align: center; text-transform: uppercase; letter-spacing: 0.03em; }
.tl-line { position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.tl-step:first-child .tl-line { display: none; }
.tl-step.done .tl-dot { background: var(--teal); border-color: var(--teal); color: #08201c; }
.tl-step.done .tl-label { color: var(--text); }
.tl-step.done .tl-line { background: var(--teal); }
.tl-step.current .tl-dot { background: var(--bg); border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-dim); }
.tl-step.current .tl-label { color: var(--teal); font-weight: 600; }
.tl-step.cancelled .tl-dot { background: var(--red-dim); border-color: var(--red); }
.tl-step.cancelled .tl-label { color: var(--red); }

/* ---------- Map ---------- */
#map { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }

.eta-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}
.eta-banner .eta-num { font-family: 'Space Grotesk'; font-size: 26px; font-weight: 700; color: var(--teal); }

/* ---------- Chat widget ---------- */
.chat-box {
    display: flex;
    flex-direction: column;
    height: 340px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.chat-bubble.mine {
    align-self: flex-end;
    background: var(--teal);
    color: #08201c;
    border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
    align-self: flex-start;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-bubble img { max-width: 180px; border-radius: 8px; display: block; }
.chat-bubble audio { width: 200px; height: 32px; }
.chat-bubble .chat-time { font-size: 10px; opacity: 0.6; margin-top: 3px; }

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}
.chat-input-row input[type="text"] {
    flex: 1;
    margin: 0;
}
.chat-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    color: var(--text-dim);
    flex-shrink: 0;
    display: flex;
    transition: background 0.15s, color 0.15s;
}
.chat-icon-btn svg { width: 19px; height: 19px; }
.chat-icon-btn:hover { background: var(--bg-elevated); color: var(--text); }
.chat-icon-btn.recording { color: var(--red); animation: pulse-rec 1s infinite; }
@keyframes pulse-rec { 50% { opacity: 0.4; } }

/* Star rating */
.star-input { display: flex; gap: 6px; font-size: 28px; cursor: pointer; }
.star-input span { color: var(--border); transition: color 0.15s, transform 0.1s; }
.star-input span:hover { transform: scale(1.15); }
.star-input span.active { color: var(--amber); }

/* ---------- Rider directory card ---------- */
.meta-icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 1px; color: var(--text-dim); }
.rider-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.rider-avatar-placeholder { width: 64px; height: 64px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-dim); }
.rider-avatar-placeholder svg { width: 28px; height: 28px; }

@media (max-width: 800px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: 100%;
        display: flex; flex-direction: row; align-items: stretch;
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
        border-right: none; border-top: 1px solid var(--border);
        z-index: 100;
    }
    .sidebar .brand { display: none; }
    .sidebar nav {
        flex-direction: row; width: 100%; justify-content: space-around;
        overflow-x: auto; gap: 0;
    }
    .sidebar nav a {
        flex-direction: column; gap: 3px; font-size: 10px; padding: 7px 8px;
        white-space: nowrap; min-width: 58px; text-align: center;
    }
    .sidebar nav a span:not(.nav-badge) { font-size: 10px; }
    .sidebar nav a .nav-icon { width: 20px; height: 20px; }
    .sidebar nav a.nav-logout { border-top: none; padding-top: 7px; margin-top: 0; }
    .nav-badge { position: absolute; top: 2px; right: 6px; margin-left: 0; }

    .main { padding: 16px 14px 88px; }
    .topbar { flex-wrap: wrap; gap: 10px; }
    .topbar h1 { font-size: 19px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .num { font-size: 22px; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    #map { height: 280px; }
    .chat-box { height: 280px; }
    .chat-bubble { max-width: 85%; }
    .eta-banner { flex-direction: column; align-items: flex-start; gap: 6px; }
    .rider-verify-card { flex-direction: column; }
    .tl-label { font-size: 9px; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .auth-wrap { margin: 4vh 12px; padding: 22px 18px; }
}
