/* =============================================================================
   DatingSite — Apple / macOS-inspired Design System
   Dark mode + SVG icons + city autocomplete styles
   ============================================================================= */

/* ── CSS Custom Properties (Light Theme) ────────────────────────────────────── */
:root {
    --bg: #f5f5f7;
    --bg-secondary: #ebebed;
    --white: #ffffff;
    --card: #ffffff;
    --blue: #007AFF;
    --blue-dark: #0062cc;
    --gray: #8e8e93;
    --gray-light: #e5e5ea;
    --text: #1c1c1e;
    --text-secondary: #6c6c70;
    --green: #34c759;
    --red: #ff3b30;
    --shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.12);
    --radius-card: 20px;
    --radius-btn: 50px;
    --radius-input: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI',
            Helvetica, Arial, sans-serif;
    --tab-height: 80px;
    --transition: all 0.3s ease;
    --tab-bg: rgba(255, 255, 255, 0.92);
    --tab-border: #e5e5ea;
    --input-bg: #ffffff;
    --badge-bg: #f5f5f7;
    --divider: #e5e5ea;
}

/* ── Dark Theme ──────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --white: #1c1c1e;
    --card: #1c1c1e;
    --blue: #0A84FF;
    --blue-dark: #0070e0;
    --gray: #8e8e93;
    --gray-light: #38383a;
    --text: #ffffff;
    --text-secondary: #aeaeb2;
    --green: #30d158;
    --red: #ff453a;
    --shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.6);
    --tab-bg: rgba(28, 28, 30, 0.95);
    --tab-border: #38383a;
    --input-bg: #2c2c2e;
    --badge-bg: #2c2c2e;
    --divider: #38383a;
}

/* Also respect system preference if no manual override */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --bg-secondary: #1c1c1e;
        --white: #1c1c1e;
        --card: #1c1c1e;
        --blue: #0A84FF;
        --blue-dark: #0070e0;
        --gray: #8e8e93;
        --gray-light: #38383a;
        --text: #ffffff;
        --text-secondary: #aeaeb2;
        --green: #30d158;
        --red: #ff453a;
        --shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 30px rgba(0, 0, 0, 0.6);
        --tab-bg: rgba(28, 28, 30, 0.95);
        --tab-border: #38383a;
        --input-bg: #2c2c2e;
        --badge-bg: #2c2c2e;
        --divider: #38383a;
    }
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: var(--bg);
    font-family: var(--font);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: var(--tab-height);
    transition: background 0.3s ease, color 0.3s ease;
}

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

/* ── Layout ────────────────────────────────────────────────────────────────── */
.page-wrapper {
    min-height: calc(100vh - var(--tab-height));
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ── Theme Toggle Button ────────────────────────────────────────────────────── */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card);
    border: 1.5px solid var(--gray-light);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-btn);
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

.btn-primary:hover {
    background: var(--blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.35);
}

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

/* INTENTIONAL BUG #1: hover makes the button explode to 150vw width */
.btn-create-profile:hover {
    width: 150vw;
}

.btn-edit {
    margin-top: 16px;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    color: var(--red);
    font-size: 15px;
    font-weight: 500;
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius-btn);
    transition: var(--transition);
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font);
    cursor: pointer;
}

.btn-logout:hover {
    background: rgba(255, 59, 48, 0.08);
}

.btn-go-feed {
    margin-top: 20px;
}

/* ── Form Inputs ───────────────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    display: block;
    width: 100%;
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-input);
    padding: 14px 16px;
    font-size: 16px;
    font-family: var(--font);
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

input[type="file"] {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}

/* INTENTIONAL BUG #3: gender select dropdown is frozen / un-clickable */
.gender-select {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Form Layout ───────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
    position: relative;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-label svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.form-error {
    display: block;
    color: var(--red);
    font-size: 13px;
    margin-top: 4px;
}

/* ── City Autocomplete ─────────────────────────────────────────────────────── */
.city-wrapper {
    position: relative;
}

.city-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card);
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-input);
    box-shadow: var(--shadow-md);
    z-index: 500;
    overflow: hidden;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.city-dropdown.open {
    display: block;
    animation: fadeSlideIn 0.2s ease;
}

.city-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 15px;
    color: var(--text);
    border-bottom: 1px solid var(--divider);
}

.city-option:last-child {
    border-bottom: none;
}

.city-option:hover,
.city-option.highlighted {
    background: var(--bg-secondary);
}

.city-option svg {
    width: 16px;
    height: 16px;
    color: var(--gray);
    flex-shrink: 0;
}

.city-option-name {
    font-weight: 500;
}

.city-option-country {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: auto;
}

.city-loading {
    padding: 12px 16px;
    text-align: center;
    color: var(--gray);
    font-size: 14px;
}

/* ── Auth Pages ────────────────────────────────────────────────────────────── */
.auth-card {
    margin-top: 40px;
    text-align: center;
}

.auth-logo {
    font-size: 52px;
    margin-bottom: 12px;
}

.auth-logo svg {
    width: 56px;
    height: 56px;
    color: var(--red);
}

.auth-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--gray);
    margin-bottom: 28px;
}

.auth-form {
    text-align: left;
}

.auth-footer {
    margin-top: 20px;
    font-size: 15px;
    color: var(--text-secondary);
    text-align: center;
}

.link {
    color: var(--blue);
    font-weight: 500;
}

/* ── Profile Page ──────────────────────────────────────────────────────────── */
.profile-container {
    padding-top: 30px;
}

.profile-card {
    text-align: center;
}

.profile-photo-wrapper {
    margin-bottom: 16px;
}

.profile-photo {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gray-light);
}

.profile-photo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #5856d6);
    color: #ffffff;
    font-size: 48px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.profile-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--badge-bg);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.profile-badge svg {
    width: 13px;
    height: 13px;
}

.profile-bio {
    background: var(--badge-bg);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    margin-bottom: 14px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
}

.profile-contact,
.profile-pref {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.profile-contact svg,
.profile-pref svg {
    width: 16px;
    height: 16px;
    color: var(--gray);
}

.contact-label,
.pref-label {
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}

.profile-actions {
    margin-top: 20px;
}

.profile-logout {
    margin-top: 4px;
}

/* ── Photo Preview (Edit Profile) ──────────────────────────────────────────── */
.current-photo-preview {
    margin-bottom: 10px;
    text-align: center;
}

.photo-preview-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-light);
}

.photo-preview-label {
    font-size: 12px;
    color: var(--gray);
    margin-top: 4px;
}

/* ── Feed Page ─────────────────────────────────────────────────────────────── */
.feed-container {
    padding-top: 20px;
}

.feed-header {
    margin-bottom: 12px;
    text-align: center;
}

.feed-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray);
    font-weight: 500;
}

.feed-counter svg {
    width: 14px;
    height: 14px;
}

.feed-card {
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.feed-photo-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.feed-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.feed-card:hover .feed-photo {
    transform: scale(1.02);
}

.feed-photo-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #ffffff;
    font-size: 80px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feed-info {
    padding: 20px 20px 0;
}

.feed-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.feed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.feed-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--badge-bg);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.feed-badge svg {
    width: 12px;
    height: 12px;
}

.feed-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 16px;
}

.feed-hint svg {
    width: 14px;
    height: 14px;
}

.feed-bio {
    padding: 0 20px 20px;
    border-top: 1px solid var(--divider);
    margin-top: 8px;
    padding-top: 16px;
    animation: fadeSlideIn 0.3s ease;
}

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

.bio-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

.bio-empty {
    color: var(--gray);
    font-style: italic;
}

/* ── Feed Action Buttons ───────────────────────────────────────────────────── */
.feed-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-bottom: 8px;
}

.action-form {
    flex: 1;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: none;
    border-radius: var(--radius-btn);
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: -0.01em;
}

.btn-action svg {
    width: 18px;
    height: 18px;
}

.btn-like {
    background: var(--green);
    color: #ffffff;
}

.btn-like:hover {
    background: #2db34a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 199, 89, 0.4);
}

.btn-skip {
    background: var(--badge-bg);
    color: var(--text-secondary);
    border: 1.5px solid var(--gray-light);
}

.btn-skip:hover {
    background: var(--gray-light);
    transform: translateY(-2px);
}

/* ── Empty State ───────────────────────────────────────────────────────────── */
.empty-card {
    text-align: center;
    padding: 48px 24px;
    margin-top: 40px;
}

.empty-icon {
    margin-bottom: 16px;
    color: var(--gray);
}

.empty-icon svg {
    width: 64px;
    height: 64px;
}

.empty-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.empty-subtitle {
    font-size: 15px;
    color: var(--gray);
    line-height: 1.5;
}

/* ── Matches Page ──────────────────────────────────────────────────────────── */
.matches-container {
    padding-top: 20px;
}

.matches-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.matches-title svg {
    width: 28px;
    height: 28px;
    color: var(--red);
}

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.match-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.match-photo-wrapper {
    flex-shrink: 0;
}

.match-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-light);
}

.match-photo-placeholder {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #5856d6);
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.match-info {
    flex: 1;
    min-width: 0;
}

.match-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.match-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--badge-bg);
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.match-badge svg {
    width: 11px;
    height: 11px;
}

.match-bio {
    font-size: 13px;
    color: var(--gray);
    line-height: 1.4;
}

/* Contact wrapper with intentional bug overlay */
.contact-wrapper {
    width: 100%;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-more {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--blue);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-btn);
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.btn-more svg {
    width: 14px;
    height: 14px;
}

.btn-more:hover {
    background: var(--blue-dark);
}

.contact-info {
    font-size: 15px;
    color: var(--blue);
    font-weight: 500;
}

/* ── Toast Notifications ───────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 32px);
    max-width: 448px;
    pointer-events: none;
}

.toast {
    background: rgba(28, 28, 30, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #ffffff;
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-success {
    background: rgba(52, 199, 89, 0.9);
}

.toast-error {
    background: rgba(255, 59, 48, 0.9);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Bottom Tab Bar ────────────────────────────────────────────────────────── */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: var(--tab-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--tab-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 0 env(safe-area-inset-bottom, 0);
    z-index: 100;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 20px;
    border-radius: 14px;
    color: var(--gray);
    transition: var(--transition);
    text-decoration: none;
}

.tab-item:hover {
    background: var(--badge-bg);
    color: var(--blue);
}

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

.tab-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-icon svg {
    width: 24px;
    height: 24px;
}

.tab-item.active .tab-icon svg {
    /* filled look for active tab */
    filter: drop-shadow(0 0 4px rgba(0, 122, 255, 0.4));
}

.tab-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── Responsive tweaks ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
    }

    .card {
        border-radius: 16px;
    }
}
