/**
 * RSNVIP9 Main Stylesheet
 * Mobile-first responsive design for 320px-480px viewport
 *
 * Design System Tokens (Source of Truth):
 * - Warna Utama: Gold (#DCAE49), Blue (#18C7B6)
 * - Background: Dark navy theme
 * - Spacing: 4px base unit
 * - Touch targets: 44px minimum
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
    /* === SHELL & LAYOUT === */
    --shell-max-width: 480px;
    --shell-min-width: 320px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-top: env(safe-area-inset-top, 0px);

    /* === WARNA UTAMA (Gold Theme) === */
    --color-gold: #DCAE49;
    --color-gold-bright: #FFE59A;
    --color-gold-dark: #A66D19;
    --color-gold-glow: rgba(244, 193, 79, 0.18);

    /* === WARNA SEKUNDER (Blue/Teal) === */
    --color-blue: #18C7B6;
    --color-blue-bright: #5DE4D6;
    --color-blue-dark: #0E8E83;
    --color-blue-glow: rgba(29, 107, 255, 0.25);

    /* === WARNA STATUS === */
    --color-success: #32D583;
    --color-warning: #F5B041;
    --color-danger: #E34B5F;
    --color-info: #38BDF8;

    /* === BACKGROUND & SURFACE === */
    --bg-page: #070807;
    --bg-canvas: #0B0D10;
    --bg-canvas-raised: #10151B;
    --bg-surface: #18212B;
    --bg-surface-strong: #202B36;
    --bg-surface-soft: #121820;

    /* === TEXT === */
    --text-primary: #FFF8E6;
    --text-muted: #8FA0B2;
    --text-inverse: #08111F;

    /* === BORDER === */
    --border-default: rgba(245, 199, 92, 0.34);
    --border-soft: rgba(255, 229, 154, 0.15);
    --border-strong: rgba(255, 255, 255, 0.1);

    /* === RADIUS (Updated to match user-ui.css & theme-vars) === */
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 28px;
    --radius-full: 999px;

    /* === GRADIENTS === */
    --gradient-gold: linear-gradient(180deg, #FFF2B8 0%, var(--color-gold) 46%, var(--color-gold-dark) 100%);
    --gradient-gold-hover: linear-gradient(180deg, #FFF5C7 0%, #F2B840 100%);
    --gradient-blue: linear-gradient(135deg, var(--color-blue-bright) 0%, var(--color-blue-dark) 100%);
    --gradient-bg: linear-gradient(180deg, var(--bg-page) 0%, var(--bg-canvas-raised) 52%, #171D25 100%);

    /* === SHADOW === */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.36);
    --shadow-gold: 0 4px 14px rgba(244, 193, 79, 0.25);
    --shadow-blue: 0 4px 14px rgba(29, 107, 255, 0.25);

    /* === SPACING (4px base) === */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* === TYPOGRAPHY === */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;

    /* === TOUCH TARGET === */
    --touch-target-min: 44px;

    /* === Z-INDEX === */
    --z-base: 1;
    --z-header: 100;
    --z-nav: 900;
    --z-overlay: 2000;
    --z-toast: 3000;
    --z-loading: 10000;

    /* === Aliases untuk backward compatibility === */
    --theme-shell-max: var(--shell-max-width);
    --theme-canvas: var(--bg-canvas);
    --theme-canvas-raised: var(--bg-canvas-raised);
    --theme-surface: var(--bg-surface);
    --theme-surface-strong: var(--bg-surface-strong);
    --theme-surface-soft: var(--bg-surface-soft);
    --theme-border: var(--border-default);
    --theme-border-soft: var(--border-soft);
    --theme-text: var(--text-primary);
    --theme-text-muted: var(--text-muted);
    --theme-primary: var(--color-blue);
    --theme-primary-hover: var(--color-blue-bright);
    --theme-primary-dark: var(--color-blue-dark);
    --theme-accent: var(--color-gold);
    --theme-accent-strong: var(--color-gold-bright);
    --theme-accent-dark: var(--color-gold-dark);
    --theme-positive: var(--color-success);
    --theme-warning: var(--color-warning);
    --theme-danger: var(--color-danger);
    --theme-info: var(--color-info);
    --theme-radius-sm: var(--radius-sm);
    --theme-radius: var(--radius-md);
    --theme-radius-lg: var(--radius-lg);
    --theme-focus: #FFFFFF;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    background: var(--bg-page);
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100dvh;
    min-height: 100dvh;
}

/* ============================================
   ACCESSIBILITY - SKIP TO CONTENT
   ============================================ */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: var(--space-3) var(--space-5);
    background: var(--color-gold);
    color: var(--text-inverse);
    font-weight: 700;
    font-size: var(--font-size-base);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: top var(--duration-fast) var(--ease-out);
}

.skip-to-content:focus {
    top: var(--space-4);
    outline: 2px solid var(--color-gold-bright);
    outline-offset: 2px;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    line-height: 1.2;
}

p { margin: 0; }

a {
    color: var(--color-blue);
    text-decoration: none;
}

a:hover { color: var(--color-blue-bright); }

/* ============================================
   LAYOUT UTILITIES
   ============================================ */
.container {
    width: 100%;
    max-width: var(--shell-max-width);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.mobile-shell {
    width: 100%;
    max-width: var(--shell-max-width);
    min-height: 100dvh;
    margin: 0 auto;
}

/* ============================================
   SPACING UTILITIES
   ============================================ */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-8); }

.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-8); }

/* ============================================
   TOUCH TARGETS (Minimum 44x44px)
   ============================================ */
.touch-target,
button,
a.button,
[role="button"],
[tabindex="0"] {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

button, input, select, textarea {
    font-family: inherit;
}

/* Input font size 16px prevents iOS zoom */
input, select, textarea {
    font-size: var(--font-size-md);
}

/* ============================================
   TEXT UTILITIES
   ============================================ */
.text-gold { color: var(--color-gold-bright); }
.text-blue { color: var(--color-blue); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--text-muted); }

/* ============================================
   BUTTON BASE STYLES
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--gradient-gold);
    color: var(--text-inverse);
    border: none;
    box-shadow: var(--shadow-gold);
}

.btn-primary:hover {
    background: var(--gradient-gold-hover);
}

.btn-primary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.btn-secondary {
    background: var(--gradient-blue);
    color: var(--theme-focus);
    border: none;
    box-shadow: var(--shadow-blue);
}

.btn-secondary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-muted);
}

.form-input {
    min-height: var(--touch-target-min);
    padding: var(--space-2) var(--space-3);
    color: var(--text-primary);
    background: var(--bg-surface-strong);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(61, 140, 255, 0.14);
}

/* ============================================
   CARDS & SURFACES
   ============================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: var(--space-2);
    left: var(--space-2);
    z-index: var(--z-loading);
    padding: var(--space-2) var(--space-3);
    color: var(--text-inverse) !important;
    background: var(--color-gold);
    border-radius: var(--radius-md);
    font-weight: 700;
    transform: translateY(-160%);
    transition: transform 0.15s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Focus visible */
:focus-visible {
    outline: 2px solid var(--color-gold-bright);
    outline-offset: 2px;
}

/* ============================================
   SAFE AREA SUPPORT
   ============================================ */
.safe-area-bottom {
    padding-bottom: calc(78px + var(--safe-area-bottom));
}

.safe-area-top {
    padding-top: var(--safe-area-top);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--color-gold);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-gold-bright);
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */
@keyframes pulse-gold {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 193, 79, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(244, 193, 79, 0); }
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(29, 107, 255, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(29, 107, 255, 0); }
}

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

.animate-pulse-gold { animation: pulse-gold 2s infinite; }
.animate-pulse-blue { animation: pulse-blue 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   RESPONSIVE HELPERS
   ============================================ */
@media (max-width: 340px) {
    .container {
        padding: 0 var(--space-3);
    }
}

@media (max-width: 420px) {
    /* Minimum 16px untuk cegah zoom otomatis di iOS */
    input, select, textarea {
        font-size: var(--font-size-md);
    }
}

/* ============================================
   FONT RENDERING OPTIMIZATION
   ============================================ */
/* Font Awesome already includes -webkit-font-smoothing: antialiased
   Add font-display hint for any web fonts loaded */
.fas, .far, .fal, .fab, .fa {
    font-display: block;
}
