/* ============================================================
   Coffee Loyalty App — Design System
   Mobile-first, dark theme, glassmorphism
   ============================================================ */

/* ── Imports ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
    /* Colors */
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(25, 25, 60, 0.6);
    --bg-card-hover: rgba(35, 35, 80, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(139, 92, 246, 0.3);

    /* Text */
    --text-primary: #f0f0ff;
    --text-secondary: #a0a0c0;
    --text-muted: #606080;
    --text-accent: #c4b5fd;

    /* Accent Colors */
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --accent-dark: #6d28d9;
    --accent-glow: rgba(139, 92, 246, 0.4);

    /* Status Colors */
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.1);

    /* VIP Tier Colors */
    --tier-none: #6b7280;
    --tier-bronze: #cd7f32;
    --tier-silver: #c0c0c0;
    --tier-gold: #ffd700;

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

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

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

/* Background gradient animation */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 50%, rgba(234, 179, 8, 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ──────────────────────────────────────────────── */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

.app-container.wide {
    max-width: 960px;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
    text-align: center;
    padding: 24px 0 16px;
    margin-bottom: 24px;
}

.app-logo {
    font-size: 2rem;
    margin-bottom: 4px;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.app-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 4px;
}

/* ── Navigation ──────────────────────────────────────────── */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
}

.nav-tab {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-glow);
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(20px);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-glow);
    background: var(--bg-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    font-size: 1.2rem;
}

.card-badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── VIP Badges ──────────────────────────────────────────── */
.badge-none { background: rgba(107, 114, 128, 0.2); color: var(--tier-none); }
.badge-bronze { background: rgba(205, 127, 50, 0.2); color: var(--tier-bronze); border: 1px solid rgba(205, 127, 50, 0.3); }
.badge-silver { background: rgba(192, 192, 192, 0.15); color: var(--tier-silver); border: 1px solid rgba(192, 192, 192, 0.3); }
.badge-gold { background: rgba(255, 215, 0, 0.15); color: var(--tier-gold); border: 1px solid rgba(255, 215, 0, 0.3); box-shadow: 0 0 12px rgba(255, 215, 0, 0.15); }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-glow);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--text-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-top: 4px;
}

.stats-grid.three-col {
    grid-template-columns: repeat(3, 1fr);
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress-container {
    margin: 12px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width 1s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3));
    border-radius: var(--radius-full);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-normal);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

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

.form-input.code-input {
    font-size: 2rem;
    text-align: center;
    letter-spacing: 0.5em;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    padding: 16px;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0c0' fill='none' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    box-shadow: 0 6px 24px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-glow);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #10b981, #059669);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
}

/* ── Code Display ────────────────────────────────────────── */
.code-display {
    text-align: center;
    padding: 24px;
    margin: 16px 0;
}

.code-value {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    background: linear-gradient(135deg, var(--accent-light), #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 60px var(--accent-glow);
    margin-bottom: 12px;
    animation: codePulse 2s ease-in-out infinite;
}

@keyframes codePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.code-expiry {
    font-size: 0.85rem;
    color: var(--warning);
    font-weight: 500;
}

.code-expiry.expired {
    color: var(--danger);
}

/* ── List Items ──────────────────────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: all var(--transition-normal);
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-glow);
}

.list-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.list-icon.success { background: var(--success-bg); }
.list-icon.warning { background: var(--warning-bg); }
.list-icon.danger { background: var(--danger-bg); }
.list-icon.info { background: var(--info-bg); }

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.list-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.list-meta {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Toast / Notification ────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: calc(100% - 32px);
    max-width: 420px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(20px);
    animation: toastSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
}

.toast.success { background: rgba(5, 150, 105, 0.9); color: white; }
.toast.error { background: rgba(220, 38, 38, 0.9); color: white; }
.toast.warning { background: rgba(217, 119, 6, 0.9); color: white; }
.toast.info { background: rgba(37, 99, 235, 0.9); color: white; }

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

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Sections ────────────────────────────────────────────── */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ── QR Code ─────────────────────────────────────────────── */
.qr-container {
    text-align: center;
    padding: 24px;
}

.qr-container img {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-glass);
    margin-bottom: 12px;
}

/* ── Reward Cards ────────────────────────────────────────── */
.reward-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.reward-card.claimed {
    opacity: 0.5;
    text-decoration: line-through;
}

.reward-icon {
    font-size: 2rem;
}

.reward-info {
    flex: 1;
}

.reward-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.reward-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Audit Log Table ─────────────────────────────────────── */
.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.audit-table th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
}

.audit-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    vertical-align: top;
}

.audit-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Status Indicators ───────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.expired { background: var(--danger); }
.status-dot.revoked { background: var(--warning); }

/* ── Loading ─────────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Charts (simple bar) ─────────────────────────────────── */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 12px 0;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.5s ease;
    position: relative;
}

.chart-bar:hover {
    background: linear-gradient(180deg, var(--accent-light), var(--accent));
}

.chart-bar:hover::after {
    content: attr(data-value);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-primary);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.chart-labels {
    display: flex;
    gap: 4px;
}

.chart-labels span {
    flex: 1;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 380px) {
    .app-container { padding: 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid.three-col { grid-template-columns: 1fr 1fr; }
    .code-value { font-size: 2.5rem; }
    .nav-tab { font-size: 0.7rem; padding: 8px 4px; }
}

@media (min-width: 768px) {
    .app-container { padding: 24px; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent-light); }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
