/* ═══════════════════════════════════════════
   Family Tasker — Mobile-first CSS
   ═══════════════════════════════════════════ */

:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5A4BD1;
    --success: #00B894;
    --success-light: #55EFC4;
    --warning: #FDCB6E;
    --danger: #E17055;
    --danger-light: #FAB1A0;
    --bg: #F8F9FE;
    --bg-card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --text-muted: #B2BEC3;
    --border: #E8E8F0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 2px 12px rgba(108, 92, 231, 0.08);
    --shadow-lg: 0 8px 32px rgba(108, 92, 231, 0.12);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────── */
.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
    background: var(--bg);
}

.app-container {
    display: none;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
}
.app-container.active { display: block; }

.screen {
    display: none;
    padding: 0 1.25rem 6rem;
    animation: fadeIn 0.25s ease;
}
.screen.active { display: block; }

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

/* ── Header ─────────────────────────────── */
.header {
    padding: 2.5rem 1.25rem 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 1.25rem;
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}
.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}
.family-code-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.header .family-code {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}
.invite-btn {
    background: rgba(255,255,255,0.25);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.invite-btn:hover {
    background: rgba(255,255,255,0.4);
}

/* ── Cards ──────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}
.card:active { transform: scale(0.98); }
.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

/* ── Credit Chips ───────────────────────── */
.credits-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.credit-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}
.credit-chip .icon { font-size: 1.1rem; }
.credit-chip .count { color: var(--primary); }

/* ── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-success {
    background: var(--success);
    color: white;
}
.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-ghost {
    background: transparent;
    color: var(--text-light);
    padding: 0.5rem;
}
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    width: auto;
}
.btn-group {
    display: flex;
    gap: 0.5rem;
}
.btn-group .btn { flex: 1; }

/* ── Forms ──────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}
.form-input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color var(--transition);
    font-family: inherit;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
}
.form-input::placeholder { color: var(--text-muted); }

.pin-input {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.pin-input input {
    width: 3.5rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
}
.pin-input input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Validation Buttons ─────────────────── */
.validation-buttons {
    display: flex;
    gap: 0.5rem;
}
.validation-btn {
    flex: 1;
    padding: 1rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
}
.validation-btn:active { transform: scale(0.95); }
.validation-btn .emoji { font-size: 1.5rem; display: block; margin-bottom: 0.25rem; }
.validation-btn .label { font-size: 0.75rem; font-weight: 600; color: var(--text-light); }
.validation-btn.refused:hover, .validation-btn.refused.selected {
    border-color: var(--danger);
    background: var(--danger-light);
}
.validation-btn.half:hover, .validation-btn.half.selected {
    border-color: var(--warning);
    background: #FFF3CD;
}
.validation-btn.full:hover, .validation-btn.full.selected {
    border-color: var(--success);
    background: var(--success-light);
}

/* ── Task List ──────────────────────────── */
.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.task-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}
.task-name { font-weight: 600; }
.task-desc { font-size: 0.8rem; color: var(--text-light); }

/* ── Quantity Stepper ───────────────────── */
.qty-stepper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.qty-stepper button {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: all var(--transition);
}
.qty-stepper button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.qty-stepper .qty {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 1.5rem;
    text-align: center;
}

/* ── Request Status Badges ──────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-pending { background: #FFF3CD; color: #856404; }
.badge-priced { background: #E8DAFF; color: #5A4BD1; }
.badge-accepted { background: #D4EDDA; color: #155724; }
.badge-in_progress { background: #CCE5FF; color: #004085; }
.badge-completed { background: #D4EDDA; color: #155724; }
.badge-refused { background: #F8D7DA; color: #721C24; }
.badge-withdrawn { background: #E2E3E5; color: #383D41; }

/* ── Bottom Nav ─────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    z-index: 100;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.4rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    transition: color var(--transition);
    background: none;
    border: none;
    font-family: inherit;
}
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 1.5rem; }
.nav-item .nav-badge {
    position: absolute;
    top: 0.1rem;
    right: calc(50% - 1.2rem);
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item { position: relative; }

/* ── Empty States ───────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state .emoji { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.95rem; }

/* ── Modal / Overlay ────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 85dvh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* ── Auth Screens ───────────────────────── */
.auth-screen {
    display: none;
    min-height: 100dvh;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.5rem;
    max-width: 480px;
    margin: 0 auto;
}
.auth-screen.active {
    display: flex;
}
.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-logo .emoji { font-size: 4rem; }
.auth-logo h1 {
    font-size: 1.75rem;
    color: var(--primary);
    margin-top: 0.5rem;
}
.auth-logo p {
    color: var(--text-light);
    font-size: 0.9rem;
}
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}
.auth-tab {
    flex: 1;
    padding: 0.65rem;
    text-align: center;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition);
    font-family: inherit;
}
.auth-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 1rem 0;
}

/* ── Toast ──────────────────────────────── */
.toast {
    position: fixed;
    top: env(safe-area-inset-top, 0.5rem);
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    background: var(--text);
    color: white;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 300;
    transition: transform 0.3s ease;
    max-width: 90%;
    text-align: center;
    margin-top: 0.75rem;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ── Icon Picker ────────────────────────── */
.icon-picker-selected {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color var(--transition);
}
.icon-picker-selected:hover {
    border-color: var(--primary-light);
}
.icon-picker-selected .icon-preview {
    font-size: 2.5rem;
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.icon-picker-selected .icon-hint {
    color: var(--text-light);
    font-size: 0.9rem;
}
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.25rem;
}
.icon-category {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0 0.15rem;
}
.icon-category:first-child {
    padding-top: 0;
}
.icon-option {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}
.icon-option:active {
    transform: scale(0.9);
}
.icon-option.selected {
    border-color: var(--primary);
    background: #EDE9FE;
    box-shadow: 0 0 0 2px var(--primary-light);
}

/* ── Utilities ──────────────────────────── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 0.85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }

/* ── Child name in parent view ──────────── */
.child-section {
    margin-bottom: 1.5rem;
}
.child-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* ── Price Summary ──────────────────────── */
.price-summary {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin: 0.75rem 0;
}
.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
}
.price-item .task { font-weight: 500; }
.price-item .qty { font-weight: 700; color: var(--primary); }

/* ── Loading ────────────────────────────── */
.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Logout ─────────────────────────────── */
.logout-btn {
    float: right;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
    margin-top: -0.25rem;
}
