/* =====================================================
   TWARAGO - Application Passager Mobile-First
   Design System & Styles
   ===================================================== */

:root {
    /* Couleurs principales */
    --primary: #7C3AED;
    --primary-dark: #5B21B6;
    --primary-light: #A78BFA;
    --primary-50: #F5F3FF;
    --primary-100: #EDE9FE;
    
    /* Couleurs secondaires */
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    
    /* Neutres */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    /* Dimensions */
    --header-height: 60px;
    --bottom-nav-height: 70px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 300ms ease;
    --transition-slow: 500ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.app-header.transparent {
    background: transparent;
    border-bottom: none;
}

/* Main Content */
.app-content {
    flex: 1;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
}

.app-content.no-header {
    padding-top: 0;
}

.app-content.no-nav {
    padding-bottom: 0;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: white;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    color: var(--gray-400);
    text-decoration: none;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

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

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

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-50);
}

.btn-success {
    background: var(--success);
    color: white;
}

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

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.card-elevated {
    box-shadow: var(--shadow-md);
    border: none;
}

/* Inputs */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
}

.input-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 0.875rem 1rem;
    padding-left: 2.75rem;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    background: white;
    color: var(--gray-900);
    transition: var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.input-wrapper input::placeholder {
    color: var(--gray-400);
}

.input-wrapper.has-error input {
    border-color: var(--danger);
}

.input-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* Checkbox & Toggle */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-wrapper input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-custom i {
    color: white;
    font-size: 0.75rem;
    opacity: 0;
    transform: scale(0);
    transition: var(--transition-fast);
}

.checkbox-wrapper input:checked + .checkbox-custom i {
    opacity: 1;
    transform: scale(1);
}

.checkbox-label {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--gray-300);
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow);
    transition: var(--transition-fast);
}

.toggle-switch.active::after {
    left: 26px;
}

/* Avatar */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--primary-50);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.avatar-sm { width: 36px; height: 36px; font-size: 1rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 2rem; }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pull to Refresh */
.pull-indicator {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.pull-indicator i {
    color: var(--primary);
    transition: var(--transition);
}

.pull-indicator.refreshing i {
    animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    left: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--gray-800);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
    pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal / Bottom Sheet */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + var(--safe-area-bottom));
    z-index: 201;
    transform: translateY(100%);
    transition: var(--transition);
    max-height: 90vh;
    overflow-y: auto;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0 auto 1.5rem;
}

/* Map Styles */
.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 300px;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 16px;
}

.map-fullscreen #map {
    border-radius: 0;
}

.map-controls {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-700);
    transition: var(--transition-fast);
}

.map-control-btn:hover {
    background: var(--gray-50);
}

.map-control-btn.active {
    background: var(--primary);
    color: white;
}

/* Location Search */
.location-search {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 10;
}

.location-input {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.location-input-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    border-bottom: 1px solid var(--gray-100);
}

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

.location-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.location-dot.pickup {
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-light);
}

.location-dot.dropoff {
    background: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-light);
}

.location-input-item input {
    flex: 1;
    border: none;
    font-size: 1rem;
    background: transparent;
}

.location-input-item input:focus {
    outline: none;
}

.location-input-item input::placeholder {
    color: var(--gray-400);
}

/* Ride Card */
.ride-card {
    background: white;
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
}

.ride-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.ride-status {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ride-status.pending { background: var(--warning-light); color: var(--warning); }
.ride-status.accepted { background: var(--info-light); color: var(--info); }
.ride-status.in_progress { background: var(--primary-50); color: var(--primary); }
.ride-status.completed { background: var(--success-light); color: var(--success); }
.ride-status.cancelled { background: var(--danger-light); color: var(--danger); }

.ride-route {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ride-route-line {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.25rem 0;
}

.ride-route-line .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.ride-route-line .line {
    flex: 1;
    width: 2px;
    background: var(--gray-200);
    margin: 0.25rem 0;
}

.ride-route-details {
    flex: 1;
}

.ride-location {
    margin-bottom: 1rem;
}

.ride-location:last-child {
    margin-bottom: 0;
}

.ride-location-label {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-bottom: 0.25rem;
}

.ride-location-address {
    font-weight: 500;
    color: var(--gray-800);
}

/* Driver Card */
.driver-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: 16px;
}

.driver-info {
    flex: 1;
}

.driver-name {
    font-weight: 600;
    color: var(--gray-800);
}

.driver-vehicle {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.driver-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--warning);
}

.driver-actions {
    display: flex;
    gap: 0.5rem;
}

/* Wallet */
.wallet-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 20px;
    padding: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.wallet-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
}

.wallet-balance-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.wallet-balance {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.wallet-actions {
    display: flex;
    gap: 0.75rem;
}

.wallet-action-btn {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.wallet-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Transaction List */
.transaction-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.transaction-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.transaction-icon.credit {
    background: var(--success-light);
    color: var(--success);
}

.transaction-icon.debit {
    background: var(--danger-light);
    color: var(--danger);
}

.transaction-details {
    flex: 1;
}

.transaction-title {
    font-weight: 500;
    color: var(--gray-800);
}

.transaction-date {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.transaction-amount {
    font-weight: 600;
}

.transaction-amount.credit {
    color: var(--success);
}

.transaction-amount.debit {
    color: var(--gray-800);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
    color: var(--gray-400);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }

.bg-primary { background: var(--primary); }
.bg-success { background: var(--success); }
.bg-danger { background: var(--danger); }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }

.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.5rem; }

.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }

.z-10 { z-index: 10; }
.z-50 { z-index: 50; }
.z-100 { z-index: 100; }

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

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

.pulse {
    animation: pulse 2s infinite;
}

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

/* Safe Areas for iOS */
@supports (padding: env(safe-area-inset-bottom)) {
    .app-content {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }
    
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .bottom-sheet {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #18181B;
        --gray-100: #27272A;
        --gray-200: #3F3F46;
        --gray-300: #52525B;
        --gray-400: #71717A;
        --gray-500: #A1A1AA;
        --gray-600: #D4D4D8;
        --gray-700: #E4E4E7;
        --gray-800: #F4F4F5;
        --gray-900: #FAFAFA;
    }
    
    body {
        background: #09090B;
        color: var(--gray-900);
    }
    
    .card, .bottom-nav, .app-header, .bottom-sheet {
        background: var(--gray-100);
    }
    
    .input-wrapper input,
    .input-wrapper select {
        background: var(--gray-100);
        border-color: var(--gray-200);
        color: var(--gray-900);
    }
}
