/* ============================================
   GrúaYA - Estilos principales
   ============================================ */

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

:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fbbf24;
    --dark: #0f172a;
    --dark-800: #1e293b;
    --dark-700: #334155;
    --dark-600: #475569;
    --light: #f8fafc;
    --light-200: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --info: #3b82f6;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--dark);
    color: var(--light);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* App Container */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Views */
.view {
    display: none;
    flex: 1;
    flex-direction: column;
}
.view.active {
    display: flex;
}

/* Auth Screens */
.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-800) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--dark-800);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--dark-700);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -1px;
}

.auth-logo h1 span {
    color: var(--light);
}

.auth-logo p {
    color: var(--dark-600);
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* Form Styles */
.form-floating > .form-control,
.form-floating > .form-select {
    background: var(--dark-700);
    border: 1px solid var(--dark-600);
    color: var(--light);
    border-radius: 8px;
    height: 3.2rem;
}
.form-floating > .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
    background: var(--dark-700);
    color: var(--light);
}
.form-floating > label {
    color: var(--dark-600);
}
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: var(--primary);
}

.form-select {
    background-color: var(--dark-700) !important;
    border-color: var(--dark-600) !important;
    color: var(--light) !important;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--dark);
    font-weight: 600;
    border-radius: 8px;
    padding: 0.65rem 1.5rem;
    transition: all 0.2s;
}
.btn-primary:hover, .btn-primary:active {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--dark);
    transform: translateY(-1px);
}

.btn-outline-light {
    border-radius: 8px;
    font-weight: 500;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
}

/* Map */
#map, .map-container {
    flex: 1;
    min-height: 300px;
    z-index: 1;
}

.map-fullscreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Bottom Panel */
.bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--dark-800);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.25rem;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    z-index: 1000;
    max-height: 65vh;
    overflow-y: auto;
    border-top: 2px solid var(--primary);
    transition: transform 0.3s ease;
}

.panel-handle {
    width: 40px;
    height: 4px;
    background: var(--dark-600);
    border-radius: 2px;
    margin: 0 auto 1rem;
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--dark-800);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1001;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--dark-700);
}

.top-bar .logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}
.top-bar .logo span {
    color: var(--light);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pendiente { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-aceptado { background: rgba(59,130,246,0.15); color: var(--info); }
.status-en_camino { background: rgba(59,130,246,0.15); color: var(--info); }
.status-en_lugar { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.status-en_servicio { background: rgba(249,115,22,0.15); color: #f97316; }
.status-finalizado { background: rgba(16,185,129,0.15); color: var(--success); }
.status-cancelado { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Pulse Animation */
.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* Request Card */
.request-card {
    background: var(--dark-700);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--dark-600);
    transition: all 0.2s;
}
.request-card:hover {
    border-color: var(--primary);
}

.request-card .distance {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.request-card .problem-type {
    font-size: 0.8rem;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Info Row */
.info-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}
.info-row i {
    color: var(--primary);
    font-size: 1rem;
    margin-top: 2px;
    width: 20px;
    text-align: center;
}
.info-row .label {
    color: var(--dark-600);
    font-size: 0.75rem;
}
.info-row .value {
    font-weight: 500;
}

/* Toggle Switch */
.availability-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--dark-700);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.form-check-input:checked {
    background-color: var(--success);
    border-color: var(--success);
}
.form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

/* Search animation */
.searching-animation {
    text-align: center;
    padding: 2rem 1rem;
}

.searching-animation .spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--dark-600);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Driver Info Card */
.driver-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--dark-700);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.driver-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--dark);
    font-size: 1.2rem;
}

.driver-rating {
    color: var(--primary);
    font-size: 0.85rem;
}

/* Step Progress */
.step-progress {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    position: relative;
}

.step-progress::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: var(--dark-600);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--dark-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--light);
    margin-bottom: 0.4rem;
    transition: all 0.3s;
}
.step.active .step-dot {
    background: var(--primary);
    color: var(--dark);
    box-shadow: 0 0 0 4px rgba(245,158,11,0.2);
}
.step.completed .step-dot {
    background: var(--success);
}

.step-label {
    font-size: 0.65rem;
    color: var(--dark-600);
    text-align: center;
    max-width: 60px;
}
.step.active .step-label,
.step.completed .step-label {
    color: var(--light);
}

/* Document Upload */
.doc-upload-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--dark-700);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--dark-600);
}

.doc-status {
    font-size: 0.75rem;
    font-weight: 600;
}
.doc-status.pendiente { color: var(--warning); }
.doc-status.aprobado { color: var(--success); }
.doc-status.rechazado { color: var(--danger); }

/* Toast */
.toast-container {
    position: fixed;
    top: 70px;
    right: 1rem;
    z-index: 9999;
}

/* Hide scrollbar */
.bottom-panel::-webkit-scrollbar { display: none; }
.bottom-panel { -ms-overflow-style: none; scrollbar-width: none; }

/* Leaflet custom */
.leaflet-container {
    background: var(--dark) !important;
}

/* Mobile adjustments */
@media (max-width: 576px) {
    .auth-card { padding: 1.5rem; }
    .bottom-panel { padding: 1rem; }
}

/* iOS safe areas */
@supports (padding-top: env(safe-area-inset-top)) {
    .top-bar {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }
    .top-spacer {
        height: calc(56px + env(safe-area-inset-top));
    }
    .bottom-panel {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }
    #installBanner {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    }
}

/* Standalone mode (PWA installed) */
@media (display-mode: standalone) {
    .top-bar {
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    }
}

/* Push notification bell */
.push-bell {
    position: relative;
    cursor: pointer;
}
.push-bell .dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* Spacer for fixed top bar */
.top-spacer { height: 56px; }

/* Action Buttons in service view */
.action-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    transition: all 0.2s;
}
.action-btn:active {
    transform: scale(0.98);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}
.loading-overlay.show { display: flex; }

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--dark-600);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
