/* PeakLevs Web App — Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
    --bg-primary: #1A0B2E;
    --bg-secondary: #0D0619;
    --bg-card: #120A22;
    --bg-card-hover: #1E0F38;
    --bg-input: #0D0619;
    --border-color: rgba(0, 212, 255, 0.15);
    --border-focus: rgba(0, 212, 255, 0.5);
    --cyan: #00D4FF;
    --cyan-dim: rgba(0, 212, 255, 0.15);
    --cyan-glow: rgba(0, 212, 255, 0.3);
    --magenta: #E040FB;
    --magenta-dim: rgba(224, 64, 251, 0.15);
    --magenta-glow: rgba(224, 64, 251, 0.3);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --success: #00E676;
    --warning: #FFD600;
    --danger: #FF5252;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(224, 64, 251, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--cyan); text-decoration: none; transition: color 0.2s; }
a:hover { color: #33DDFF; }
img { max-width: 100%; height: auto; }

/* Layout */
.app-container { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 24px 20px; min-height: 100vh; }
.app-container.wide { max-width: 960px; }
.app-header { text-align: center; margin-bottom: 32px; }
.app-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 12px; }
.app-logo-large { width: 80px; height: 80px; border-radius: 20px; margin-bottom: 16px; }
.app-title { font-size: 1.5rem; font-weight: 800; background: linear-gradient(135deg, var(--cyan), var(--magenta)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 4px; }
.app-subtitle { color: var(--text-secondary); font-size: 0.875rem; font-weight: 400; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px; transition: border-color 0.2s, transform 0.2s; }
.card:hover { border-color: rgba(0, 212, 255, 0.25); }
.card-highlight { border-color: var(--cyan); box-shadow: 0 0 30px rgba(0, 212, 255, 0.1); }
.card-magenta { border-color: var(--magenta); box-shadow: 0 0 30px rgba(224, 64, 251, 0.1); }
.card-title { font-size: 1.125rem; font-weight: 700; margin-bottom: 8px; }
.card-desc { color: var(--text-secondary); font-size: 0.875rem; line-height: 1.5; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input { width: 100%; padding: 14px 16px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-family: inherit; font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; outline: none; }
.form-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 82, 82, 0.15); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
select.form-input option { background: var(--bg-secondary); color: var(--text-primary); }
textarea.form-input { resize: vertical; min-height: 100px; }
.form-error { color: var(--danger); font-size: 0.8125rem; margin-top: 6px; display: none; }
.form-error.visible { display: block; }
.form-hint { color: var(--text-muted); font-size: 0.75rem; margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 28px; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; outline: none; position: relative; overflow: hidden; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--cyan), #0099CC); color: #000; box-shadow: 0 4px 20px var(--cyan-glow); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(0, 212, 255, 0.4); transform: translateY(-1px); }
.btn-magenta { background: linear-gradient(135deg, var(--magenta), #B030CC); color: #FFF; box-shadow: 0 4px 20px var(--magenta-glow); }
.btn-magenta:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(224, 64, 251, 0.4); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--cyan); border: 1px solid var(--cyan); }
.btn-outline:hover:not(:disabled) { background: var(--cyan-dim); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 10px 16px; }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.btn-danger { background: rgba(255, 82, 82, 0.15); color: var(--danger); border: 1px solid rgba(255, 82, 82, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 82, 82, 0.25); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 16px 32px; font-size: 1.125rem; }

/* Spinner */
.spinner { width: 20px; height: 20px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(13, 6, 25, 0.8); display: flex; align-items: center; justify-content: center; z-index: 999; backdrop-filter: blur(4px); }
.loading-content { text-align: center; }
.loading-content .spinner { width: 40px; height: 40px; border-width: 3px; border-top-color: var(--cyan); margin-bottom: 16px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 100px; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-cyan { background: var(--cyan-dim); color: var(--cyan); }
.badge-magenta { background: var(--magenta-dim); color: var(--magenta); }
.badge-success { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.badge-warning { background: rgba(255, 214, 0, 0.15); color: var(--warning); }
.category-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; font-size: 0.6875rem; font-weight: 600; }
.category-fitness { background: rgba(255, 82, 82, 0.15); color: #FF5252; }
.category-learning { background: rgba(0, 212, 255, 0.15); color: #00D4FF; }
.category-creativity { background: rgba(224, 64, 251, 0.15); color: #E040FB; }
.category-wellness { background: rgba(0, 230, 118, 0.15); color: #00E676; }
.category-productivity { background: rgba(255, 214, 0, 0.15); color: #FFD600; }
.category-social { background: rgba(255, 145, 0, 0.15); color: #FF9100; }

/* Tier colours */
.tier-Newcomer { color: #888; }
.tier-Spark { color: #00D4FF; }
.tier-Flame { color: #FF9100; }
.tier-Blaze { color: #FF5252; }
.tier-Inferno { color: #E040FB; }
.tier-Legend { color: #FFD600; }

/* Stat boxes */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-box { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px 12px; text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 800; background: linear-gradient(135deg, var(--cyan), var(--magenta)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.2; }
.stat-label { font-size: 0.6875rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* Tabs */
.tabs { display: flex; background: var(--bg-secondary); border-radius: var(--radius-md); padding: 4px; margin-bottom: 20px; gap: 4px; }
.tab { flex: 1; padding: 10px 16px; background: transparent; border: none; border-radius: var(--radius-sm); color: var(--text-muted); font-family: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; transition: all 0.2s; text-align: center; }
.tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.tab:hover:not(.active) { color: var(--text-secondary); }

/* Navigation bar */
.nav-bar { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(13, 6, 25, 0.95); border-top: 1px solid var(--border-color); display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 100; backdrop-filter: blur(20px); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 12px; color: var(--text-muted); text-decoration: none; font-size: 0.625rem; font-weight: 600; transition: color 0.2s; border: none; background: none; cursor: pointer; }
.nav-item.active { color: var(--cyan); }
.nav-item:hover { color: var(--text-secondary); }
.nav-icon { font-size: 1.25rem; line-height: 1; }

/* Toast */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: 90%; max-width: 400px; }
.toast { padding: 14px 20px; border-radius: var(--radius-md); font-size: 0.875rem; font-weight: 500; animation: toastIn 0.3s ease; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); }
.toast-success { background: linear-gradient(135deg, rgba(0, 230, 118, 0.15), rgba(0, 230, 118, 0.05)); border: 1px solid rgba(0, 230, 118, 0.3); color: var(--success); }
.toast-error { background: linear-gradient(135deg, rgba(255, 82, 82, 0.15), rgba(255, 82, 82, 0.05)); border: 1px solid rgba(255, 82, 82, 0.3); color: var(--danger); }
.toast-info { background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.05)); border: 1px solid rgba(0, 212, 255, 0.3); color: var(--cyan); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* Leaderboard */
.leaderboard-entry { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-md); transition: background 0.2s; }
.leaderboard-entry:hover { background: rgba(255, 255, 255, 0.03); }
.leaderboard-entry.is-me { background: var(--cyan-dim); border: 1px solid rgba(0, 212, 255, 0.2); border-radius: var(--radius-md); }
.lb-rank { width: 32px; text-align: center; font-weight: 800; font-size: 0.875rem; color: var(--text-muted); }
.lb-rank.top-1 { color: #FFD600; font-size: 1.125rem; }
.lb-rank.top-2 { color: #C0C0C0; font-size: 1rem; }
.lb-rank.top-3 { color: #CD7F32; font-size: 1rem; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan-dim), var(--magenta-dim)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.875rem; color: var(--cyan); flex-shrink: 0; overflow: hidden; }
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-tier { font-size: 0.6875rem; font-weight: 500; }
.lb-score { font-weight: 700; font-size: 0.875rem; color: var(--cyan); text-align: right; }

/* Feed */
.feed-item { display: flex; gap: 12px; padding: 16px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-color); margin-bottom: 12px; }
.feed-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan-dim), var(--magenta-dim)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; color: var(--cyan); flex-shrink: 0; }
.feed-content { flex: 1; min-width: 0; }
.feed-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.feed-username { font-weight: 700; font-size: 0.875rem; }
.feed-time { font-size: 0.6875rem; color: var(--text-muted); }
.feed-desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; }
.feed-footer { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.feed-levs { font-size: 0.75rem; font-weight: 700; color: var(--cyan); }

/* Achievements */
.achievements-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.achievement-item { text-align: center; padding: 16px 8px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border-color); transition: all 0.2s; }
.achievement-item.unlocked { border-color: rgba(0, 230, 118, 0.3); background: rgba(0, 230, 118, 0.05); }
.achievement-item.locked { opacity: 0.4; }
.achievement-icon { font-size: 2rem; margin-bottom: 8px; line-height: 1; }
.achievement-name { font-size: 0.6875rem; font-weight: 700; margin-bottom: 2px; }
.achievement-desc { font-size: 0.5625rem; color: var(--text-muted); line-height: 1.3; }

/* Pricing */
.pricing-grid { display: flex; flex-direction: column; gap: 16px; }
.pricing-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 28px 24px; position: relative; overflow: hidden; }
.pricing-card.featured { border-color: var(--cyan); box-shadow: 0 0 40px rgba(0, 212, 255, 0.15); }
.pricing-card.featured::before { content: 'MOST POPULAR'; position: absolute; top: 16px; right: -28px; background: linear-gradient(135deg, var(--cyan), #0099CC); color: #000; font-size: 0.5625rem; font-weight: 800; padding: 4px 36px; transform: rotate(45deg); letter-spacing: 1px; }
.pricing-name { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.pricing-price { margin-bottom: 20px; }
.pricing-amount { font-size: 2.5rem; font-weight: 900; background: linear-gradient(135deg, var(--cyan), var(--magenta)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.1; }
.pricing-period { font-size: 0.875rem; color: var(--text-muted); }
.pricing-features { list-style: none; margin-bottom: 24px; }
.pricing-features li { padding: 6px 0; font-size: 0.875rem; color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.pricing-features li::before { content: '\2713'; color: var(--success); font-weight: 700; font-size: 0.875rem; flex-shrink: 0; }
.pricing-features li.disabled { color: var(--text-muted); text-decoration: line-through; }
.pricing-features li.disabled::before { content: '\2717'; color: var(--text-muted); }

/* Momentum bar */
.momentum-bar { height: 8px; background: var(--bg-secondary); border-radius: 100px; overflow: hidden; margin: 8px 0; }
.momentum-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); border-radius: 100px; transition: width 0.5s ease; }

/* Section headers */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 1rem; font-weight: 700; }
.section-link { font-size: 0.8125rem; color: var(--cyan); font-weight: 500; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.3; }
.empty-text { color: var(--text-muted); font-size: 0.875rem; }

/* Divider */
.divider { height: 1px; background: var(--border-color); margin: 20px 0; }

/* Alert */
.alert { padding: 16px 20px; border-radius: var(--radius-md); font-size: 0.875rem; margin-bottom: 16px; }
.alert-info { background: var(--cyan-dim); border: 1px solid rgba(0, 212, 255, 0.2); color: var(--cyan); }
.alert-error { background: rgba(255, 82, 82, 0.1); border: 1px solid rgba(255, 82, 82, 0.2); color: var(--danger); }
.alert-success { background: rgba(0, 230, 118, 0.1); border: 1px solid rgba(0, 230, 118, 0.2); color: var(--success); }

/* Profile header */
.profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--magenta)); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.5rem; color: #000; flex-shrink: 0; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { flex: 1; }
.profile-name { font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
.profile-tier { font-size: 0.8125rem; font-weight: 600; }
.profile-premium { display: inline-flex; align-items: center; gap: 4px; font-size: 0.6875rem; font-weight: 700; color: var(--magenta); background: var(--magenta-dim); padding: 2px 8px; border-radius: 100px; margin-left: 8px; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; backdrop-filter: blur(4px); opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; transform: translateY(20px); transition: transform 0.2s; }
.modal-overlay.active .modal { transform: translateY(0); }

/* Responsive */
@media (max-width: 380px) {
    .app-container { padding: 16px 12px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .achievements-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
    .pricing-grid { flex-direction: row; }
    .pricing-card { flex: 1; }
}

.has-nav { padding-bottom: 80px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-card-hover) 50%, var(--bg-card) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.hidden { display: none !important; }
.link-btn { background: none; border: none; color: var(--cyan); font-family: inherit; font-size: 0.875rem; cursor: pointer; padding: 0; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

/* Settings list */
.settings-list { list-style: none; }
.settings-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border-color); cursor: pointer; transition: opacity 0.2s; }
.settings-item:hover { opacity: 0.8; }
.settings-item:last-child { border-bottom: none; }
.settings-item-left { display: flex; align-items: center; gap: 12px; }
.settings-item-icon { font-size: 1.25rem; width: 32px; text-align: center; }
.settings-item-label { font-size: 0.9375rem; font-weight: 500; }
.settings-item-arrow { color: var(--text-muted); font-size: 0.875rem; }

/* Log action form specifics */
.category-select-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.category-option { padding: 12px 8px; text-align: center; border-radius: var(--radius-md); border: 1px solid var(--border-color); background: var(--bg-card); cursor: pointer; transition: all 0.2s; font-size: 0.75rem; font-weight: 600; }
.category-option:hover { border-color: var(--cyan); }
.category-option.selected { border-color: var(--cyan); background: var(--cyan-dim); color: var(--cyan); }
.category-option .cat-emoji { font-size: 1.25rem; display: block; margin-bottom: 4px; }
