/*
 * Kedr Camp Loyalty — Personal Cabinet
 * 3 tier themes via CSS custom properties
 * Brand: Terracotta #C4956A, Deep Forest #2E4A2E, Cloud White #F1F0EC, Sage #6B8E63, Gold #B8860B
 */

/* ── Base variables ─────────────────────────────────────────────────── */

:root {
    --tg-bg: #1a1a2e;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Theme: Kedr (Гость Кедра 🌲) — Nature, fresh, simple ──────── */

.theme-kedr {
    --bg-primary: #1B2E1B;
    --bg-card: #243524;
    --bg-card-hover: #2D3F2D;
    --text-primary: #E8E5DF;
    --text-secondary: #A8B5A0;
    --accent: #6B8E63;
    --accent-soft: rgba(107, 142, 99, 0.15);
    --tier-gradient: linear-gradient(135deg, #3A5A3A 0%, #2E4A2E 100%);
    --tier-glow: rgba(107, 142, 99, 0.3);
    --progress-fill: #6B8E63;
    --badge-bg: #2E4A2E;
    --badge-border: #6B8E63;
    --positive: #6B8E63;
    --negative: #C45A5A;
}

/* ── Theme: Sosna (Друг Кедра 🤝) — Warm, amber, mid-tier ──────── */

.theme-sosna {
    --bg-primary: #2A2218;
    --bg-card: #362C20;
    --bg-card-hover: #40342A;
    --text-primary: #F1F0EC;
    --text-secondary: #C4B59A;
    --accent: #C4956A;
    --accent-soft: rgba(196, 149, 106, 0.15);
    --tier-gradient: linear-gradient(135deg, #8B6B4A 0%, #C4956A 100%);
    --tier-glow: rgba(196, 149, 106, 0.35);
    --progress-fill: #C4956A;
    --badge-bg: #4A3A28;
    --badge-border: #C4956A;
    --positive: #8BAF6B;
    --negative: #C45A5A;
}

/* ── Theme: Taiga (Семья Кедра ❤️) — Rich gold, premium ─────────── */

.theme-taiga {
    --bg-primary: #1A1520;
    --bg-card: #261E30;
    --bg-card-hover: #302838;
    --text-primary: #F1F0EC;
    --text-secondary: #C9B8D4;
    --accent: #B8860B;
    --accent-soft: rgba(184, 134, 11, 0.15);
    --tier-gradient: linear-gradient(135deg, #B8860B 0%, #DAA520 50%, #B8860B 100%);
    --tier-glow: rgba(218, 165, 32, 0.4);
    --progress-fill: linear-gradient(90deg, #B8860B, #DAA520);
    --badge-bg: #2E2518;
    --badge-border: #DAA520;
    --positive: #8BAF6B;
    --negative: #C45A5A;
}

/* ── Reset & base ───────────────────────────────────────────────── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px;
    padding-bottom: 32px;
    -webkit-font-smoothing: antialiased;
}

/* ── Loading ────────────────────────────────────────────────────── */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-secondary, #999);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent, #6B8E63);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Empty/error states ─────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary, #999);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Tier card (header) ─────────────────────────────────────────── */

.tier-card {
    background: var(--tier-gradient);
    border-radius: var(--radius);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 24px var(--tier-glow);
    margin-bottom: 16px;
}

.tier-badge {
    width: 56px;
    height: 56px;
    background: var(--badge-bg);
    border: 2px solid var(--badge-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tier-emoji {
    font-size: 28px;
}

.member-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

.tier-name {
    font-size: 14px;
    opacity: 0.85;
}

/* ── Points card ────────────────────────────────────────────────── */

.points-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-bottom: 16px;
    border: 1px solid var(--accent-soft);
}

.points-value {
    font-size: 42px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.points-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.points-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    opacity: 0.7;
}

/* ── Sections ───────────────────────────────────────────────────── */

.section {
    margin-bottom: 16px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 0 4px;
}

/* ── Progress bars ──────────────────────────────────────────────── */

.progress-bars {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
}

.progress-item {
    margin-bottom: 12px;
}

.progress-item:last-child {
    margin-bottom: 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.progress-hint {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 10px;
    opacity: 0.7;
}

/* ── Max tier badge ─────────────────────────────────────────────── */

.max-tier-badge {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.max-tier-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 8px;
}

.max-tier-badge p {
    color: var(--accent);
    font-weight: 500;
}

/* ── Benefits grid ──────────────────────────────────────────────── */

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.benefit-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px 8px;
    text-align: center;
}

.benefit-icon {
    font-size: 22px;
    margin-bottom: 6px;
}

.benefit-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.benefit-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Stats grid ─────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.stat-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ── Rewards list ───────────────────────────────────────────────── */

.rewards-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.reward-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.6;
}

.reward-item:last-child {
    border-bottom: none;
}

.reward-item.affordable {
    opacity: 1;
}

.reward-name {
    font-size: 14px;
    font-weight: 500;
}

.reward-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.reward-cost {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    margin-left: 12px;
}

/* ── History list ───────────────────────────────────────────────── */

.history-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-item:last-child {
    border-bottom: none;
}

.history-desc {
    font-size: 13px;
}

.history-date {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.history-amount {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 12px;
}

.history-amount.positive {
    color: var(--positive);
}

.history-amount.negative {
    color: var(--negative);
}

/* ── Referral card ──────────────────────────────────────────────── */

.referral-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.referral-card strong {
    color: var(--accent);
    font-size: 18px;
    letter-spacing: 1px;
}

.referral-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.btn-copy {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition);
    margin-top: 4px;
}

.btn-copy:active {
    opacity: 0.8;
}

/* ── Section link ("Все →") ──────────────────────────────────────── */

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-link {
    font-size: 13px;
    font-weight: 400;
    color: var(--accent);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

/* ── Bottom navigation ──────────────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition);
}

.nav-btn.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 20px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Add bottom padding for nav bar */
body {
    padding-bottom: 80px !important;
}

/* ── Tab header ─────────────────────────────────────────────────── */

.tab-header {
    margin-bottom: 16px;
}

.tab-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.tab-subtitle {
    font-size: 14px;
    color: var(--accent);
    margin-top: 4px;
}

/* ── Filter bar ─────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Rewards catalog (full page) ────────────────────────────────── */

.catalog-section {
    margin-bottom: 20px;
}

.catalog-category {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.reward-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    opacity: 0.55;
    transition: opacity var(--transition);
}

.reward-card.affordable {
    opacity: 1;
    border-left: 3px solid var(--accent);
}

.reward-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.reward-cost-badge {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.reward-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.reward-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
}

.reward-tag.dimmed {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* ── History full page ──────────────────────────────────────────── */

.history-full {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.history-full .history-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 12px;
}

.history-full .history-item:last-child {
    border-bottom: none;
}

.history-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.btn-load-more {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--accent-soft);
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: opacity var(--transition);
}

.btn-load-more:active {
    opacity: 0.7;
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 360px) {
    body { padding: 12px; padding-bottom: 80px !important; }
    .tier-card { padding: 18px 14px; }
    .points-value { font-size: 36px; }
    .benefits-grid { gap: 6px; }
    .benefit-card { padding: 10px 6px; }
    .filter-btn { padding: 6px 12px; }
}
