/* 
 * Bukamalu - Simple Mobile App Styles
 * Clean, minimal, mobile-first design
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --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-900: #111827;
    --white: #ffffff;
    --radius: 12px;
    --radius-lg: 16px;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-50);
    min-height: 100vh;
    min-height: 100dvh;
}

/* ============================================
   Container
   ============================================ */
.container {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 48px; /* space for fixed language switcher */
}

/* ============================================
   Language switcher
   ============================================ */
.lang-switcher {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 16px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.lang-link {
    color: var(--gray-600);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
}

.lang-link:hover {
    color: var(--primary);
    background: var(--gray-100);
}

.lang-link.active {
    color: var(--primary);
    font-weight: 600;
}

.lang-sep {
    color: var(--gray-300);
    margin: 0 2px;
    user-select: none;
}

/* ============================================
   Home Page
   ============================================ */
.home-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 20px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: var(--white);
}

.hero {
    text-align: center;
    margin-bottom: 32px;
}

.icon-container {
    margin-bottom: 16px;
}

.main-icon {
    font-size: 56px;
}

.hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    color: var(--gray-500);
}

/* ============================================
   Action Options
   ============================================ */
.action-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 8px 0;
    color: var(--gray-400);
    font-size: 14px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

.hint {
    text-align: center;
    margin-top: 16px;
    color: var(--gray-400);
    font-size: 14px;
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    padding: 10px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    -webkit-appearance: none;
}

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

.btn-primary:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.btn-large {
    padding: 18px 24px;
    font-size: 17px;
}

.btn-medium {
    padding: 14px 20px;
    font-size: 15px;
    width: auto;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--primary);
    color: var(--white);
}

.btn-large-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-large-outline:hover,
.btn-large-outline:active {
    border-color: var(--primary);
}

.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-danger:hover,
.btn-danger:active {
    opacity: 0.9;
}

.btn-text {
    background: none;
    border: none;
    font-size: 15px;
    cursor: pointer;
    padding: 12px;
}

.btn-text:hover {
    color: var(--gray-400);
}

.btn-icon {
    font-size: 1.2em;
}

.btn-text-back {
    padding: 10px 18px;
    cursor: pointer;
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
}

/* ============================================
   State Containers
   ============================================ */
.state-container {
    text-align: center;
    padding: 32px 24px;
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    margin: auto;
}

.state-container h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.state-container p {
    color: var(--gray-500);
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* Loading spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* Success/Error icons */
.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    color: var(--white);
    font-size: 28px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.error-icon {
    width: 64px;
    height: 64px;
    background: var(--danger);
    color: var(--white);
    font-size: 28px;
    font-weight: bold;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

/* ============================================
   Share Link
   ============================================ */
.link-container {
    display: flex;
    gap: 8px;
    margin: 20px 0;
}

.share-link-input {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
    color: var(--gray-700);
    min-width: 0;
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 16px 0;
}

.btn-share {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    flex: 1;
    max-width: 140px;
}

.btn-whatsapp {
    background: #25D366;
    color: var(--white);
}

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

.privacy-note {
    margin-top: 20px;
    color: var(--gray-400);
    font-size: 13px;
}

/* ============================================
   Map Pages
   ============================================ */
.map-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--gray-100);
}

.map-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map style toggle: Map | Satellite */
.map-style-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    background: var(--white);
    border-radius: 999px;
    overflow: hidden;
    border: 2px solid var(--gray-500);
}

.location-info-bar .map-style-btn {
    padding: 8px 14px;
    font-size: 13px;
}

.map-style-btn {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.map-style-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

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

/* Info bar */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-top: 1px solid var(--gray-100);
}

.legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gray-700);
}

.distance-info {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* Bottom bar */
.bottom-bar {
    display: flex;
    gap: 10px;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--white);
    border-top: 1px solid var(--gray-100);
}

.bottom-bar .btn-secondary {
    flex: 1;
}

.bottom-bar .btn-danger {
    min-width: 80px;
}

/* Waiting banner */
.waiting-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--primary);
    color: var(--white);
    font-size: 14px;
}

/* ============================================
   Permission Overlay
   ============================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.overlay-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    width: 100%;
    max-width: 340px;
}

.permission-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.overlay-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.overlay-content p {
    color: var(--gray-500);
    font-size: 15px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.overlay-content .btn-primary {
    margin-bottom: 12px;
}

/* ============================================
   Map Selection Page
   ============================================ */
.map-selection-page {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    z-index: 100;
}

.selection-map-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.selection-map {
    width: 100%;
    height: 100%;
}

.location-info-bar {
    position: absolute;
    right: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
}

.location-info-bar .map-style-toggle {
    position: static;
    box-shadow: none;
}

.location-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-700);
    min-width: 0;
    flex: 1;
}

.location-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon-only.spinning {
    animation: spin 0.8s linear infinite;
}

.map-hint {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: var(--white);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 6px;
}

.map-action-bar {
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 16px;
    z-index: 1000;
}

.btn-confirm {
    flex: 1;
}

/* ============================================
   Map Markers
   ============================================ */
.custom-marker {
    background: none;
    border: none;
}

.marker-pin {
    font-size: 32px;
    text-align: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.marker-pin.selection {
    font-size: 40px;
}

.marker-pulse {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 6px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 50%;
}

.marker-bounce {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* ============================================
   Status Messages
   ============================================ */
.status-message {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: 16px;
    right: 16px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    z-index: 2000;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.status-message.warning {
    background: var(--warning);
    color: var(--white);
}

.status-message.error {
    background: var(--danger);
    color: var(--white);
}

.status-message.info {
    background: var(--primary);
    color: var(--white);
}

/* ============================================
   Expired Page
   ============================================ */
.expired-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    text-align: center;
    background: var(--white);
}

.expired-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.expired-page h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.expired-page p {
    color: var(--gray-500);
    margin-bottom: 24px;
    max-width: 280px;
}

.expired-page .btn-primary {
    width: auto;
    padding: 14px 32px;
}

/* ============================================
   Leaflet Overrides
   ============================================ */
.leaflet-control-layers {
    border-radius: 8px;
    font-size: 14px;
}

.leaflet-control-attribution {
    font-size: 10px;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================
   Safe Area (Notch/Home indicator)
   ============================================ */
@supports (padding: env(safe-area-inset-top)) {
    .home-page {
        padding-top: max(24px, env(safe-area-inset-top));
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
}
