/* ============================================================
   DriveLive – style.css
   Dark Mobile-First Design
   ============================================================ */

/* === RESET & BASE ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0d0d14;
    --bg2:          #13131e;
    --card:         #1a1a2b;
    --card-dark:    #111120;
    --border:       #2a2a40;
    --accent:       #e8ff00;
    --accent2:      #00e0ff;
    --danger:       #ff4455;
    --success:      #00e87a;
    --warn:         #ff9900;
    --text:         #f0f0ff;
    --text-muted:   #6b6b90;
    --text-dim:     #9090b8;
    --shadow:       0 4px 24px rgba(0,0,0,.6);
    --radius:       14px;
    --radius-sm:    8px;
    --nav-h:        68px;
    --header-h:     54px;
    --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* === AUTH PAGES =========================================== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 20%, #1a1a3a 0%, var(--bg) 70%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo .logo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 20px rgba(232,255,0,.4));
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    color: var(--text-muted);
    font-size: .9rem;
    margin-top: 4px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
}

.auth-card h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: .9rem;
}

/* === FORM ELEMENTS ======================================= */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    padding: 12px 14px;
    outline: none;
    transition: border-color .2s;
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* === BUTTONS ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
    -webkit-appearance: none;
}

.btn:active { transform: scale(.97); opacity: .85; }

.btn-primary {
    background: var(--accent);
    color: #111;
}

.btn-secondary {
    background: var(--card-dark);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-full { width: 100%; }

/* === ALERTS ============================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-error   { background: #ff445522; border: 1px solid #ff444566; color: #ff6677; }
.alert-success { background: #00e87a22; border: 1px solid #00e87a66; color: #00e87a; }

/* === APP LAYOUT ========================================== */
.app-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: rgba(13,13,20,.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-sm { font-size: 1.5rem; }

.header-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-back {
    font-size: 1.3rem;
    color: var(--text);
    padding: 4px 8px;
}

.points-badge {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--accent);
}

.header-user {
    font-size: .85rem;
    color: var(--text-dim);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === MAP ================================================= */
#map {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: var(--nav-h);
    z-index: 1;
}

/* Leaflet dark override */
.leaflet-tile-pane { filter: brightness(.85) saturate(.8) hue-rotate(10deg); }
.leaflet-popup-content-wrapper {
    background: var(--card) !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-popup-tip { background: var(--card) !important; }
.leaflet-popup-close-button { color: var(--text-muted) !important; }

/* === FLOATING ACTION BUTTON ============================== */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    color: #111;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(232,255,0,.4), 0 2px 8px rgba(0,0,0,.5);
    z-index: 500;
    transition: transform .2s, box-shadow .2s;
}

.fab:active, .fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(232,255,0,.6), 0 2px 8px rgba(0,0,0,.5);
}

.fab.recording {
    background: var(--danger);
    animation: fab-pulse 1.2s infinite;
}

@keyframes fab-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(255,68,85,.4); }
    50%       { box-shadow: 0 4px 32px rgba(255,68,85,.8), 0 0 0 8px rgba(255,68,85,.15); }
}

/* === MODALS ============================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 500px;
    padding: 20px;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal.modal-sm {
    max-height: 70vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: var(--bg2);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { background: var(--border); color: var(--text); }

/* === REPORT TYPE GRID ==================================== */
.report-types {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.type-btn {
    background: var(--bg2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 16px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    font-weight: 600;
    transition: border-color .15s, background .15s;
    -webkit-appearance: none;
}

.type-btn:active,
.type-btn:hover,
.type-btn.selected {
    border-color: var(--accent);
    background: rgba(232,255,0,.08);
}

.type-icon { font-size: 1.8rem; }

#reportForm {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

#reportDesc {
    width: 100%;
    background: var(--bg2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .95rem;
    padding: 12px 14px;
    resize: none;
    min-height: 80px;
    font-family: inherit;
    margin-bottom: 14px;
}

#reportDesc:focus { outline: none; border-color: var(--accent); }

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions .btn { flex: 1; }

/* === DETAIL MODAL ======================================== */
.detail-type {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-type-icon { font-size: 2.5rem; }

.detail-meta { font-size: .85rem; color: var(--text-dim); margin-bottom: 6px; }
.detail-desc { color: var(--text); margin-bottom: 14px; }

.vote-counts {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    font-size: .9rem;
}

.vote-confirm { color: var(--success); font-weight: 700; }
.vote-deny    { color: var(--danger); font-weight: 700; }

.vote-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

.vote-bar-fill { height: 100%; background: var(--success); border-radius: 2px; transition: width .3s; }

.expires-hint {
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* === CUSTOM MAP MARKERS ================================== */
.dl-marker {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    border: 2px solid rgba(255,255,255,.15);
    box-shadow: 0 2px 8px rgba(0,0,0,.5);
    cursor: pointer;
    transform: rotate(-45deg);
}

.dl-marker span { transform: rotate(45deg); display: block; }

/* === BOTTOM NAVIGATION =================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: rgba(13,13,20,.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .3px;
    transition: color .15s;
}

.nav-item:hover,
.nav-item.active {
    color: var(--accent);
    text-decoration: none;
}

.nav-item svg { transition: stroke .15s; }
.nav-item.active svg { stroke: var(--accent); }

/* === TOAST =============================================== */
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 12px 24px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
    box-shadow: var(--shadow);
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    z-index: 9999;
    white-space: nowrap;
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger); color: var(--danger); }

/* === FEED PAGE =========================================== */
.feed-page {
    margin-top: var(--header-h);
    margin-bottom: var(--nav-h);
    overflow-y: auto;
    height: calc(100vh - var(--header-h) - var(--nav-h));
    padding: 16px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 10px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--accent);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
}

.feed-section { margin-bottom: 24px; }

.section-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.top-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.top-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.top-item:last-child { border-bottom: none; }

.top-rank {
    width: 24px;
    height: 24px;
    background: var(--bg2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 800;
    color: var(--accent);
    flex-shrink: 0;
}

.top-name { flex: 1; font-weight: 600; font-size: .95rem; }
.top-pts  { color: var(--accent); font-weight: 700; font-size: .9rem; }

.event-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.event-msg  { font-size: .9rem; color: var(--text); flex: 1; }
.event-time { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

.empty-hint { color: var(--text-muted); padding: 16px; text-align: center; font-size: .9rem; }

.loading-pulse {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
    font-size: .9rem;
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

/* === LOCATE BUTTON ======================================= */
.locate-btn {
    position: fixed;
    bottom: calc(var(--nav-h) + 90px);
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--accent2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 400;
    transition: transform .2s;
}

.locate-btn:active { transform: scale(.9); }

/* === RESPONSIVE ========================================== */
@media (min-width: 600px) {
    .report-types { grid-template-columns: repeat(3, 1fr); }
    .modal { border-radius: var(--radius) var(--radius) 0 0; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 360px) {
    .report-types { grid-template-columns: repeat(3, 1fr); }
    .type-icon { font-size: 1.4rem; }
}
