/* ============================================================================
   EasyTrack Client App - Styles
   ============================================================================ */

/* Variables CSS */
:root {
    --primary: #3b82f6;
    --primary-dark: #1e40af;
    --secondary: #F3F4F6;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
}

/* Safe areas */
html {
    height: 100%;
}

body {
    min-height: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Loading screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#loading-screen .logo {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

#loading-screen .loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover { 
    background-color: var(--primary-dark); 
}

.btn-primary:disabled { 
    background-color: #D1D5DB; 
    cursor: not-allowed; 
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover { 
    background-color: #E5E7EB; 
}

/* Cards */
.card {
    background-color: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* Code Inputs */
.code-inputs {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    margin: 1rem 0;
}

.code-digit {
    width: 2.5rem;
    height: 3rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    transition: all 0.15s ease;
    caret-color: var(--primary);
}

.code-digit:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    transform: scale(1.05);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    width: calc(100% - 40px);
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 1100;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
}

.notification.success { 
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9) 0%, rgba(22, 163, 74, 0.85) 100%);
    color: white;
}

.notification.error { 
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.85) 100%);
    color: white;
}

.notification.info { 
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(37, 99, 235, 0.85) 100%);
    color: white;
}

@keyframes toastSlideIn {
    0% { 
        transform: translateY(-100%); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* Navigation */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    cursor: pointer;
    flex: 1;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item svg {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Inputs */
.input-field {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.input-field:focus {
    border-color: var(--primary);
    outline: none;
}

/* Vehicle cards */
.vehicle-card {
    background: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
}

.vehicle-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.vehicle-card.online {
    border-left: 4px solid var(--success);
}

.vehicle-card.offline {
    border-left: 4px solid var(--text-secondary);
}

.vehicle-icon {
    width: 3rem;
    height: 3rem;
    background: var(--secondary);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.vehicle-info {
    flex: 1;
}

.vehicle-name {
    font-weight: 600;
    color: var(--text-primary);
}

.vehicle-plate {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.vehicle-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.75rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 500;
    gap: 0.25rem;
}

.status-badge.online {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

.status-badge.moving {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* Map container */
.map-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#map {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Fix Leaflet container */
.leaflet-container {
    width: 100% !important;
    height: 100% !important;
}

/* Map overlay cards */
.map-vehicle-info {
    position: absolute;
    bottom: 6rem;
    left: 1rem;
    right: 1rem;
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem;
}

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Bottom nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    z-index: 900;
}

/* Spinner */
.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Pull to refresh indicator */
.pull-indicator {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Leaflet custom markers */
.vehicle-marker {
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.vehicle-marker.moving {
    background: var(--success);
}

.vehicle-marker.offline {
    background: var(--text-secondary);
}

/* Profile section */
.profile-section {
    padding: 1.5rem;
}

.profile-avatar {
    width: 5rem;
    height: 5rem;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    margin: 0 auto 1rem;
}

.profile-name {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.profile-email {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.settings-list {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

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

.settings-item:hover {
    background: var(--secondary);
}

.settings-item svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-secondary);
    margin-right: 1rem;
}

.settings-item span {
    flex: 1;
}

.settings-item .arrow {
    color: var(--text-secondary);
}

/* Logout button */
.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem;
    margin-top: 1.5rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}
