/* ThaiGlai Design System — Warm & Bright Theme */

/* === Fonts — system stack, zero load time === */

/* === CSS Variables === */
:root {
    /* Warm Colors */
    --color-primary: #FF6B6B;
    --color-primary-dark: #E85555;
    --color-primary-light: #FFE0E0;
    --color-secondary: #4ECDC4;
    --color-secondary-light: #D4F5F2;
    --color-accent: #FFB830;
    --color-accent-light: #FFF3D6;

    /* Light backgrounds */
    --color-bg: #FAFAFA;
    --color-bg-warm: #FFF9F5;
    --color-surface: #FFFFFF;
    --color-surface-2: #F5F3F0;
    --color-surface-3: #EDE9E4;
    --color-border: #E8E4DF;

    /* Text */
    --color-text: #2D2A26;
    --color-text-secondary: #7A7570;
    --color-text-muted: #B0AAA3;

    /* Marker colors */
    --color-unmatched: #D4D0CC;
    --color-matched: #4ECDC4;
    --color-online: #4ECDC4;
    --color-danger: #FF6B6B;
    --color-success: #4ECDC4;
    --color-warning: #FFB830;

    /* Typography — system font stack for speed + readability */
    --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Spacing */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);

    /* Tab bar */
    --tab-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

a { color: inherit; text-decoration: none; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    outline: none;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* === Desktop Landing Layout === */
.desktop-landing {
    display: none;
}

@media (min-width: 768px) {
    body {
        background: linear-gradient(135deg, #FFF9F5 0%, #FFF0E8 50%, #F0F9F8 100%);
    }

    .desktop-landing {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        gap: 80px;
        padding: 40px;
        max-width: 1200px;
        margin: 0 auto;
    }

    .landing-left {
        flex: 1;
        max-width: 480px;
    }

    .landing-left .logo {
        font-family: var(--font-heading);
        font-size: 48px;
        font-weight: 800;
        color: var(--color-text);
        margin-bottom: 8px;
    }

    .landing-left .logo span {
        color: var(--color-primary);
    }

    .landing-left .tagline {
        font-size: 20px;
        color: var(--color-text-secondary);
        margin-bottom: 40px;
    }

    .landing-features {
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    .landing-features li {
        display: flex;
        gap: 16px;
        align-items: flex-start;
    }

    .landing-features .feat-icon {
        width: 48px;
        height: 48px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        flex-shrink: 0;
    }

    .landing-features .feat-text h3 {
        font-family: var(--font-heading);
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 4px;
        color: var(--color-text);
    }

    .landing-features .feat-text p {
        font-size: 14px;
        color: var(--color-text-secondary);
        line-height: 1.5;
    }

    /* Phone mockup */
    .phone-mockup {
        width: 375px;
        height: 812px;
        border-radius: 44px;
        border: 8px solid #2D2A26;
        background: var(--color-bg);
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 2px rgba(0,0,0,0.05);
        position: relative;
        flex-shrink: 0;
    }

    /* no notch */

    .phone-mockup .app-container {
        height: 100%;
        max-width: 100%;
        border-radius: 0;
    }

    /* Hide app outside of phone on desktop */
    body > #app {
        display: none;
    }
}

@media (max-width: 767px) {
    .desktop-landing {
        display: none !important;
    }
}

/* === App Container === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    background: var(--color-bg);
}

.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.app-content::-webkit-scrollbar { display: none; }

/* === Tab Bar === */
.tab-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--tab-height);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: var(--safe-bottom);
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
    transition: color 0.2s;
    position: relative;
}

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

.tab-item .tab-icon { font-size: 22px; }

.tab-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
}

/* === Headings === */
h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-text);
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

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

.btn-primary:active {
    background: var(--color-primary-dark);
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-border);
    color: var(--color-text);
    box-shadow: none;
}

.btn-full { width: 100%; }

.btn-round {
    width: 56px; height: 56px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
}

.btn-round-lg {
    width: 72px; height: 72px;
    border-radius: 50%;
    padding: 0;
    font-size: 30px;
    box-shadow: var(--shadow-md);
}

/* === Cards === */
.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* === Avatar === */
.avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-surface-2);
}

.avatar-sm { width: 36px; height: 36px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 96px; height: 96px; }

.online-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--color-online);
    border: 2px solid var(--color-surface);
    position: absolute;
    bottom: 0; right: 0;
}

/* === Badge === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-secondary { background: var(--color-secondary-light); color: var(--color-secondary); }
.badge-accent { background: var(--color-accent-light); color: #C28B00; }

/* === Utilities === */
.text-center { text-align: center; }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.px-2 { padding-left: 16px; padding-right: 16px; }

.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-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }

.hidden { display: none !important; }

/* === Pages === */
.page { display: none; height: 100%; }
.page.active { display: flex; flex-direction: column; }

/* === Auth Page === */
.auth-header {
    text-align: center;
    padding-top: 60px;
    margin-bottom: 40px;
}

.auth-header .logo-text {
    font-family: var(--font-heading);
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
}

.auth-header .logo-text span { color: var(--color-primary); }

.auth-header .subtitle {
    color: var(--color-text-secondary);
    font-size: 16px;
    margin-top: 6px;
}

.auth-tabs {
    display: flex;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    color: var(--color-text-secondary);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* === Swipe Card === */
.swipe-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
}

.swipe-card {
    position: absolute;
    width: calc(100% - 32px);
    height: calc(100% - 32px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    touch-action: pan-y;
}

.swipe-card img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.swipe-card-info {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
}

.swipe-card-info h2 { font-size: 26px; margin-bottom: 4px; color: white; }

.swipe-card-info .distance {
    color: #4ECDC4;
    font-size: 14px;
    font-weight: 500;
}

.swipe-actions {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px;
    flex-shrink: 0;
}

/* === Chat === */
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-surface-2);
    transition: background 0.15s;
}

.chat-list-item:active {
    background: var(--color-surface-2);
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.4;
}

.chat-bubble.sent {
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.chat-bubble.received {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.translate-badge {
    font-size: 11px;
    color: var(--color-secondary);
    cursor: pointer;
    margin-top: 2px;
}

.translate-toggle {
    font-size: 11px;
    color: var(--color-secondary);
    cursor: pointer;
    margin-top: 4px;
    opacity: 0.8;
}

.translate-toggle:hover {
    opacity: 1;
}

.chat-bubble.received .translate-toggle {
    color: var(--color-secondary);
}

/* === Pulse animation === */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(255, 107, 107, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}

.pulse { animation: pulse 2s infinite; }

/* === Match popup === */
.match-popup {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.97);
    z-index: 100;
    gap: 24px;
}

.match-popup h1 {
    font-size: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* === Progress bar (onboarding) === */
.progress-bar {
    height: 4px;
    background: var(--color-surface-2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* === Language chip === */
.lang-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.lang-chip.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.lang-chip.primary {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

/* === Range slider === */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--color-surface-3);
    border-radius: 3px;
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
}

/* === Stats card === */
.stats-card {
    display: flex;
    justify-content: space-between;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-item .stat-number {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
}

.stat-item .stat-label {
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* === Profile header === */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px 16px 20px;
    background: linear-gradient(180deg, var(--color-bg-warm), var(--color-bg));
}

.profile-avatar-wrapper {
    position: relative;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--color-accent);
    box-shadow: 0 4px 16px rgba(255, 184, 48, 0.2);
    background: var(--color-surface-2);
}

/* === Page header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

/* === Empty state === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    gap: 12px;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

/* === Chat menu button === */
.chat-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    width: 100%;
    font-size: 15px;
    color: var(--color-text);
    transition: background 0.15s;
    border: none;
    background: none;
    cursor: pointer;
}

.chat-menu-btn:hover {
    background: var(--color-surface-2);
}

.chat-menu-btn + .chat-menu-btn {
    border-top: 1px solid var(--color-border);
}

/* === Edit Photo Grid === */
.edit-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.edit-photo-slot {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-surface-2);
}

.edit-photo-add {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--color-border);
    cursor: pointer;
    transition: border-color 0.2s;
}

.edit-photo-add:hover {
    border-color: var(--color-primary);
}

/* === Form label spacing === */
label + input,
label + textarea,
label + select,
label + .dual-range-wrapper,
label + .flex,
label + .otp-inputs {
    margin-top: 6px;
}

/* === Country Code Select === */
.country-select {
    width: 108px;
    flex-shrink: 0;
    font-size: 14px;
    padding: 14px 24px 14px 10px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237A7570' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
}

/* === OTP Input Boxes === */
.otp-inputs {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.otp-box {
    width: 44px !important;
    height: 52px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    caret-color: var(--color-primary);
    transition: border-color 0.2s;
}

.otp-box:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* === Dual Range Slider === */
.dual-range-wrapper {
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
}

.dual-range-track {
    position: absolute;
    left: 0; right: 0;
    height: 6px;
    background: var(--color-surface-3);
    border-radius: 3px;
}

.dual-range-fill {
    position: absolute;
    height: 6px;
    background: var(--color-primary);
    border-radius: 3px;
    pointer-events: none;
}

.dual-range-wrapper input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 6px;
    margin: 0;
    border: none;
    padding: 0;
}

.dual-range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
    position: relative;
    z-index: 2;
}

/* === Toggle Switch === */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--color-surface-3);
    border-radius: 14px;
    transition: background 0.25s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* === Settings row === */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
}

/* === Leaflet Map Markers === */
.leaflet-my-marker {
    background: none !important;
    border: none !important;
}

.my-marker-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2.5px solid white;
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5);
    animation: mapPulse 2s infinite;
}

@keyframes mapPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
    70% { box-shadow: 0 0 0 18px rgba(255, 107, 107, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}

.leaflet-marker-custom {
    background: none !important;
    border: none !important;
}

.map-marker {
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-marker.matched {
    width: 44px;
    height: 44px;
    border: 3px solid var(--color-secondary);
    background: var(--color-surface-2);
    box-shadow: 0 2px 8px rgba(78, 205, 196, 0.3);
}

.map-marker.matched img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-marker.matched span {
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--color-secondary);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-marker.unmatched {
    width: 24px;
    height: 24px;
    background: var(--color-unmatched);
    border: 2px solid var(--color-border);
    opacity: 0.7;
}

/* Leaflet overrides for clean look */
.leaflet-control-zoom a {
    background: var(--color-surface) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border) !important;
}

/* === Floating gradient decorations === */
.gradient-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    pointer-events: none;
}
