/* ============================================================
   IGNITE — Design System & App CSS (Mobile-first)
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
    --color-primary:       #E94057;
    --color-primary-light: #FF6B85;
    --color-secondary:     #F27121;
    --color-bg:            #0F0F1A;
    --color-surface:       #1A1A2E;
    --color-surface-2:     #22223B;
    --color-border:        rgba(255,255,255,0.08);
    --color-text:          #FFFFFF;
    --color-text-muted:    #8888AA;
    --color-success:       #4CAF82;
    --color-error:         #FF5252;
    --color-muted:         #44445A;

    --gradient-fire:  linear-gradient(135deg, #E94057 0%, #F27121 100%);
    --gradient-dark:  linear-gradient(180deg, #0F0F1A 0%, #1A1A2E 100%);
    --gradient-card:  linear-gradient(180deg, #1E1E35 0%, #16162A 100%);

    --radius-sm:   8px;
    --radius-md:   14px;
    --radius-lg:   20px;
    --radius-xl:   28px;
    --radius-full: 9999px;

    --shadow-sm:   0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:   0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg:   0 16px 48px rgba(0,0,0,0.5);
    --shadow-fire: 0 8px 32px rgba(233, 64, 87, 0.3);

    --font-main:   'Inter', system-ui, -apple-system, sans-serif;

    --nav-height:  68px;
    --header-h:    60px;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-main);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* ---- App Wrapper ---- */
.app-wrapper {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 0 0 calc(var(--nav-height) + 12px);
    overflow-y: auto;
}

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

/* ---- Bottom Nav ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    padding: 8px 0;
    color: var(--color-muted);
    transition: color 0.2s ease;
    cursor: pointer;
}

.bottom-nav__item svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
}

.bottom-nav__item span {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.bottom-nav__item.active {
    color: var(--color-primary);
}

.bottom-nav__item.active svg {
    transform: scale(1.1);
}

/* ---- Auth Pages ---- */
.auth-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 24px 40px;
}

.auth-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 0 32px;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-flame {
    width: 52px;
    height: 68px;
    filter: drop-shadow(0 0 16px rgba(233, 64, 87, 0.5));
}

.logo-text {
    font-size: 2.2rem;
    font-weight: 700;
    background: var(--gradient-fire);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.auth-tagline {
    margin-top: 8px;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    text-align: center;
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
}

.auth-card__title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--color-primary);
    font-weight: 500;
}

/* ---- Form Elements ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    padding: 14px 16px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(233, 64, 87, 0.15);
}

.form-group input::placeholder {
    color: var(--color-muted);
}

.input-with-toggle {
    position: relative;
}

.input-with-toggle input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* ---- Gender Selector ---- */
.gender-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gender-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.gender-option__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--color-surface-2);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.gender-option__label svg {
    width: 24px;
    height: 24px;
}

.gender-option input:checked + .gender-option__label {
    border-color: var(--color-primary);
    background: rgba(233, 64, 87, 0.12);
    color: var(--color-primary);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
}

.btn--primary {
    background: var(--gradient-fire);
    color: #fff;
    box-shadow: var(--shadow-fire);
}

.btn--primary:hover, .btn--primary:active {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 12px 40px rgba(233, 64, 87, 0.4);
}

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

.btn--outline:hover {
    background: rgba(233, 64, 87, 0.1);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn--ghost:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.btn--full {
    width: 100%;
}

.btn--sm {
    padding: 10px 18px;
    font-size: 0.85rem;
}

/* ---- Alerts & Flash ---- */
.alert, .flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.alert--error, .flash--error {
    background: rgba(255, 82, 82, 0.12);
    border: 1px solid rgba(255, 82, 82, 0.3);
    color: #FF8A80;
}

.alert--success, .flash--success {
    background: rgba(76, 175, 130, 0.12);
    border: 1px solid rgba(76, 175, 130, 0.3);
    color: #80CBAA;
}

.alert--info {
    background: rgba(100, 130, 255, 0.12);
    border: 1px solid rgba(100, 130, 255, 0.3);
    color: #A0B4FF;
}

.alert--info a {
    color: var(--color-primary);
    font-weight: 500;
}

/* ---- Badge ---- */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-fire);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: var(--radius-full);
}

/* ---- Page Header ---- */
.page-header {
    padding: 24px 20px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
    flex-basis: 100%;
}

/* ---- Connect Page ---- */
.page-connect {
    padding: 24px 20px;
}

.page-connect .page-header {
    padding: 24px 0 24px;
    display: block;
}

.page-connect .page-header h1 {
    font-size: 1.8rem;
    line-height: 1.2;
    margin-bottom: 8px;
}

.connect-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.connect-card {
    background: var(--gradient-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.connect-card__icon {
    width: 48px;
    height: 48px;
    background: rgba(233, 64, 87, 0.12);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.connect-card__icon svg {
    width: 24px;
    height: 24px;
}

.connect-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.connect-card p {
    color: var(--color-text-muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.connect-divider {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    position: relative;
}

.connect-divider::before,
.connect-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--color-border);
}

.connect-divider::before { left: 0; }
.connect-divider::after  { right: 0; }

/* ---- Waiting Page ---- */
.page-waiting {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    gap: 20px;
    text-align: center;
}

.waiting-animation {
    position: relative;
    margin-bottom: 8px;
}

.waiting-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.waiting-pulse .logo-flame {
    width: 72px;
    height: 96px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.08); opacity: 0.85; }
}

.page-waiting h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.code-display {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    box-shadow: var(--shadow-fire);
}

.code-text {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 6px;
    background: var(--gradient-fire);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-copy {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.btn-copy:hover { color: var(--color-text); }
.btn-copy svg { width: 20px; height: 20px; }

.waiting-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.dot-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: dotPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ---- Matches Page ---- */
.page-matches {
    padding: 0 16px 20px;
}

.matches-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.match-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--gradient-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: border-color 0.2s;
}

.match-card:hover {
    border-color: rgba(233, 64, 87, 0.3);
}

.match-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(233, 64, 87, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    flex-shrink: 0;
}

.match-card__icon svg {
    width: 18px;
    height: 18px;
}

.match-card__text {
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--color-text);
}

.match-card__date {
    font-size: 0.75rem;
    color: var(--color-muted);
    flex-shrink: 0;
}

/* ---- Stories Page ---- */
.page-stories {
    padding: 0 16px 20px;
}

.stories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 0 20px;
}

.story-card {
    border-radius: var(--radius-xl);
    aspect-ratio: 3/4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 12px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

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

.story-card--unlocked {
    background: var(--gradient-card);
    border: 1px solid rgba(233, 64, 87, 0.3);
    box-shadow: 0 4px 20px rgba(233, 64, 87, 0.15);
}

.story-card--locked {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    opacity: 0.8;
}

.story-card__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 100%;
    text-align: center;
}

.story-card__number {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
}

.story-card--unlocked .story-card__number {
    color: var(--color-primary);
}

.story-card__thumb svg {
    width: 60px;
    height: 60px;
}

.story-card__label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    background: rgba(233, 64, 87, 0.15);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(233, 64, 87, 0.3);
}

.story-card__label--pending {
    background: rgba(255,255,255,0.05);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.story-card__lock {
    color: var(--color-muted);
}

.story-card__lock svg {
    width: 28px;
    height: 28px;
}

.story-card__progress {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.progress-bar {
    width: 80%;
    height: 4px;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    background: var(--gradient-fire);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

.progress-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.stories-cta {
    text-align: center;
    padding: 8px 0;
}

/* ---- Story Read Page ---- */
.page-story-read {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.story-read-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--color-border);
}

.story-read-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.btn-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: 50%;
    color: var(--color-text);
    flex-shrink: 0;
}

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

.story-read-content {
    flex: 1;
    padding: 28px 24px;
}

.story-text {
    font-size: 1rem;
    line-height: 1.8;
    color: rgba(255,255,255,0.85);
}

.story-reading .main-content {
    padding-bottom: 0;
}

.story-read-footer {
    padding: 20px 24px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--color-border);
    text-align: center;
}

/* ---- Profile Page ---- */
.page-profile {
    padding: 0 20px 24px;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 0 24px;
    gap: 8px;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-fire);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    box-shadow: var(--shadow-fire);
}

.profile-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.profile-gender {
    color: var(--color-text-muted);
    font-size: 0.88rem;
}

.profile-section {
    margin-bottom: 24px;
}

.profile-section h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.couple-info-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.couple-members {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.couple-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.member-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-surface-2);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
}

.couple-member span {
    font-size: 0.88rem;
    font-weight: 500;
}

.profile-section--danger {
    padding-top: 8px;
}

/* ---- Empty States ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px;
    gap: 16px;
}

.empty-state__icon svg,
.empty-state__icon {
    width: 80px;
    height: 80px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.empty-state p {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    max-width: 280px;
}

.empty-state__sub {
    color: var(--color-primary) !important;
    font-weight: 500;
}

.page-empty {
    min-height: calc(100dvh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Error Pages ---- */
.error-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 24px;
    text-align: center;
}

.error-page h1 {
    font-size: 5rem;
    font-weight: 800;
    background: var(--gradient-fire);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-page p {
    color: var(--color-text-muted);
}

/* ---- Hidden utility ---- */
.hidden { display: none !important; }

/* ---- Add proposition form ---- */
.add-proposition-wrap {
    padding: 12px 20px;
    text-align: center;
}

.add-proposition-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 12px;
}

/* ---- Desktop Enhancement ---- */
@media (min-width: 768px) {
    .app-wrapper {
        border-left: 1px solid var(--color-border);
        border-right: 1px solid var(--color-border);
    }

    .bottom-nav {
        left: 50%;
    }
}
