/* ===== Variables ===== */
:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #42A5F5;
    --accent: #F5A623;
    --accent-dark: #E09100;
    --secondary: #0A1628;
    --success: #27AE60;
    --warning: #F5A623;
    --danger: #E74C3C;
    --info: #1565C0;
    --bg: #F0F4F8;
    --bg-card: #FFFFFF;
    --text: #1A1A2E;
    --text-light: #5A6A7E;
    --text-muted: #9BAAB8;
    --border: #DAE2EB;
    --shadow: 0 2px 8px rgba(10,22,40,0.08);
    --shadow-lg: 0 4px 16px rgba(10,22,40,0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --nav-height: 64px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; height: auto; }

/* ===== Navigation ===== */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--nav-height);
    background: var(--secondary);
    border-bottom: 1px solid rgba(245,166,35,0.2);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.nav-brand { display: flex; align-items: center; }
.nav-logo-img { height: 44px; width: auto; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a, .nav-links button {
    padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 500; color: rgba(255,255,255,0.7);
    transition: all 0.2s;
}
.nav-links a:hover, .nav-links button:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-links a.active { background: var(--accent); color: var(--secondary); }
.nav-toggle { display: none; flex-direction: column; gap: 5px; padding: 0.5rem; cursor: pointer; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.nav-toggle span { display: block; width: 22px; height: 2.5px; background: #FFFFFF; border-radius: 2px; transition: 0.2s; }

@media (max-width: 768px) {
    .nav-links { display: none; }
    .nav-toggle { display: flex; }
}

/* ===== Mobile Menu ===== */
.mobile-menu {
    position: fixed; top: var(--nav-height); left: 0; right: 0; bottom: 0; z-index: 99;
    background: var(--bg-card);
    padding: 1rem;
    overflow-y: auto;
}
.mobile-menu-links { display: flex; flex-direction: column; gap: 0.25rem; }
.mobile-menu-links a, .mobile-menu-links button {
    display: block; padding: 0.875rem 1rem; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 500; color: var(--text);
    transition: background 0.2s; text-align: left; width: 100%;
}
.mobile-menu {
    background: var(--secondary);
}
.mobile-menu-links a, .mobile-menu-links button {
    color: rgba(255,255,255,0.8);
}
.mobile-menu-links a:hover, .mobile-menu-links button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.mobile-menu-links a.active { background: var(--accent); color: var(--secondary); }

/* ===== Main Content ===== */
.main-content {
    padding-top: var(--nav-height);
    min-height: 100vh;
}
.main-content.no-nav { padding-top: 0; }

/* ===== Container ===== */
.container { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.container-wide { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card-header { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.5rem; border-radius: var(--radius-sm);
    font-size: 0.95rem; font-weight: 600;
    transition: all 0.2s; min-height: 48px;
}
.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-outline:hover { background: var(--primary); color: white; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; min-height: 56px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: 0.875rem; font-weight: 500;
    margin-bottom: 0.375rem; color: var(--text);
}
.form-input {
    width: 100%; padding: 0.75rem 1rem;
    border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: 1rem; background: var(--bg-card); color: var(--text);
    transition: border-color 0.2s; min-height: 48px;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input.error { border-color: var(--danger); }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 0.25rem; }
.form-select { 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 fill='%237F8C8D' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }

/* ===== Auth Pages ===== */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--secondary);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(21,101,192,0.25) 0%, transparent 70%);
    padding: 1rem;
}
.auth-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 2rem; width: 100%; max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.auth-logo {
    text-align: center; margin-bottom: 1.5rem;
}
.auth-logo .logo-main {
    max-width: 220px; height: auto; margin-bottom: 0.5rem;
}
.auth-logo .logo-icon {
    width: 64px; height: 64px; border-radius: 16px;
    background: var(--primary); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.5rem; margin-bottom: 0.5rem;
}
.auth-logo h1 { font-size: 1.5rem; color: var(--text); }
.auth-logo p { color: var(--text-light); font-size: 0.9rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-light); }
.auth-footer a { color: var(--primary); font-weight: 500; }

/* ===== QR Code ===== */
.qr-fullscreen {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: white; z-index: 200;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem;
}
.qr-fullscreen canvas, .qr-fullscreen img { max-width: 300px; max-height: 300px; }
.qr-fullscreen .qr-label {
    margin-top: 1.5rem; font-size: 1.1rem; font-weight: 600; color: var(--text);
    text-align: center;
}
.qr-fullscreen .qr-uuid {
    margin-top: 0.5rem; font-size: 0.75rem; color: var(--text-muted);
    word-break: break-all; text-align: center;
}
.qr-close {
    position: absolute; top: 1rem; right: 1rem;
    width: 48px; height: 48px; border-radius: 50%;
    background: #E8EDF2; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: var(--text);
    z-index: 210; cursor: pointer;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    border: none; outline: none;
}

/* ===== Scanner ===== */
.scanner-container { position: relative; width: 100%; max-width: 400px; margin: 0 auto; }
#scanner-video { width: 100%; min-height: 300px; border-radius: var(--radius); overflow: hidden; background: #000; }
#scanner-video video { width: 100% !important; border-radius: var(--radius); }

/* ===== Loyalty Cards ===== */
.loyalty-card {
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #0A1628 100%);
    border-radius: var(--radius); padding: 1.25rem; color: white;
    margin-bottom: 1rem; cursor: pointer; transition: transform 0.2s;
}
.loyalty-card:hover { transform: translateY(-2px); }
.loyalty-card-shop { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }
.loyalty-card-program { font-size: 0.85rem; opacity: 0.85; margin-bottom: 0.75rem; }
.loyalty-card-points {
    display: flex; align-items: center; justify-content: space-between;
}
.loyalty-card-points .points-count { font-size: 1.75rem; font-weight: 700; }
.loyalty-card-points .points-label { font-size: 0.8rem; opacity: 0.8; }
.loyalty-card-progress {
    margin-top: 0.75rem; background: rgba(255,255,255,0.2);
    border-radius: 100px; height: 8px; overflow: hidden;
}
.loyalty-card-progress-bar {
    height: 100%; background: white; border-radius: 100px;
    transition: width 0.3s ease;
}
.loyalty-card-reward {
    margin-top: 0.5rem; font-size: 0.8rem; opacity: 0.85; text-align: right;
}

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-sm);
    padding: 1rem; text-align: center; box-shadow: var(--shadow);
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 0.25rem; }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.75rem; background: var(--bg); font-weight: 600; color: var(--text-light); border-bottom: 2px solid var(--border); }
td { padding: 0.75rem; border-bottom: 1px solid var(--border); }

/* ===== Badges ===== */
.badge {
    display: inline-flex; padding: 0.25rem 0.625rem; border-radius: 100px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: #D5F5E3; color: #1E8449; }
.badge-warning { background: #FEF9E7; color: #B7950B; }
.badge-danger { background: #FADBD8; color: #C0392B; }
.badge-info { background: #D6EAF8; color: #2471A3; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; top: calc(var(--nav-height) + 0.5rem); right: 0.5rem; z-index: 300;
    display: flex; flex-direction: column; gap: 0.5rem; max-width: 350px;
}
.toast {
    padding: 0.875rem 1.25rem; border-radius: var(--radius-sm);
    color: white; font-size: 0.9rem; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease-out;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8); z-index: 400;
    display: flex; align-items: center; justify-content: center;
}
.spinner {
    width: 40px; height: 40px; border: 4px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--text-light);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0.25rem; margin-bottom: 1.5rem; background: var(--bg); border-radius: var(--radius-sm); padding: 0.25rem; }
.tab {
    flex: 1; padding: 0.625rem; text-align: center; border-radius: 6px;
    font-size: 0.875rem; font-weight: 500; color: var(--text-light); transition: all 0.2s;
}
.tab.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow); }

/* ===== Scan result ===== */
.scan-result {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 1.5rem; text-align: center; box-shadow: var(--shadow-lg);
}
.scan-result-avatar {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary-light); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem;
}
.scan-result-name { font-size: 1.2rem; font-weight: 600; }
.scan-result-info { color: var(--text-light); font-size: 0.9rem; margin-top: 0.25rem; }

/* ===== Utility ===== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ===== Subscription Plans ===== */
.plans-grid { display: grid; gap: 1rem; }
@media (min-width: 600px) { .plans-grid { grid-template-columns: repeat(2, 1fr); } }
.plan-card {
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; text-align: center;
    transition: border-color 0.2s;
}
.plan-card.featured { border-color: var(--primary); }
.plan-card-name { font-size: 1.1rem; font-weight: 700; }
.plan-card-price { font-size: 2rem; font-weight: 700; color: var(--primary); margin: 0.5rem 0; }
.plan-card-price span { font-size: 0.9rem; font-weight: 400; color: var(--text-light); }
.plan-card-features { list-style: none; text-align: left; margin: 1rem 0; }
.plan-card-features li { padding: 0.375rem 0; font-size: 0.9rem; color: var(--text-light); }
.plan-card-features li::before { content: "✓ "; color: var(--success); font-weight: 700; }

/* ===== iOS Install Banner ===== */
.ios-install-banner {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    padding: 1rem 1rem 1.5rem;
    animation: ios-slide-up 0.4s ease-out;
    border-radius: 16px 16px 0 0;
}
.ios-install-banner.hidden { display: none !important; }
@keyframes ios-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.ios-install-content {
    display: flex; align-items: center; gap: 0.875rem;
}
.ios-install-icon {
    width: 48px; height: 48px; border-radius: 12px;
    flex-shrink: 0;
}
.ios-install-text strong { display: block; font-size: 1rem; color: var(--text); }
.ios-install-text p {
    font-size: 0.85rem; color: var(--text-light);
    margin-top: 0.25rem; display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap;
}
.ios-share-icon {
    display: inline-flex; align-items: center; color: var(--primary);
    vertical-align: middle;
}
.ios-install-close {
    position: absolute; top: 0.5rem; right: 0.75rem;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg); display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: var(--text-light); cursor: pointer;
    border: none; line-height: 1;
}
