/* =====================================================
   MUSI DESIGN SYSTEM — Premium Banking App CSS
   ===================================================== */

/* ---- Custom Properties ---- */
:root {
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --shadow-blue: 0 8px 24px rgba(37,99,235,0.18);

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f8fafc;
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-300); }

/* ---- Safe Area ---- */
.safe-area-bottom { padding-bottom: env(safe-area-inset-bottom, 8px); }

/* =====================================================
   COMPONENTS
   ===================================================== */

/* ---- Cards ---- */
.musi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    transition: var(--transition);
}
.musi-card:hover { box-shadow: var(--shadow); }
.musi-card-elevated {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.05);
}

/* ---- Gradient Hero Card ---- */
.musi-hero-card {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 50%, #1e3a8a 100%);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}
.musi-hero-card::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -15%;
    width: 60%;
    padding-top: 60%;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    pointer-events: none;
}
.musi-hero-card::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 40%;
    padding-top: 40%;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    pointer-events: none;
}

/* ---- Buttons ---- */
.musi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}
.musi-btn:active { transform: scale(0.97); }
.musi-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.musi-btn-primary {
    background: var(--primary-600);
    color: #fff;
    box-shadow: var(--shadow-blue);
}
.musi-btn-primary:hover { background: var(--primary-700); box-shadow: 0 12px 32px rgba(37,99,235,0.28); }

.musi-btn-secondary {
    background: var(--primary-50);
    color: var(--primary-700);
    border: 1px solid var(--primary-100);
}
.musi-btn-secondary:hover { background: var(--primary-100); }

.musi-btn-ghost {
    background: transparent;
    color: var(--gray-700);
}
.musi-btn-ghost:hover { background: var(--gray-100); }

.musi-btn-danger {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.musi-btn-danger:hover { background: var(--danger); color: #fff; }

.musi-btn-lg { padding: 16px 32px; font-size: 1rem; border-radius: var(--radius-lg); }
.musi-btn-sm { padding: 8px 16px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.musi-btn-full { width: 100%; }

/* ---- Forms ---- */
.musi-input-wrap { position: relative; }
.musi-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.musi-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--primary-50);
    border: 1.5px solid var(--primary-100);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--gray-900);
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}
.musi-input:focus {
    border-color: var(--primary-500);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.08);
}
.musi-input::placeholder { color: #94a3b8; }
.musi-input-icon .musi-input { padding-left: 44px; }
.musi-input-prefix {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.musi-input-prefix svg { width: 18px; height: 18px; }

/* ---- Badges ---- */
.musi-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.musi-badge-success { background: #d1fae5; color: #065f46; }
.musi-badge-warning { background: #fef3c7; color: #92400e; }
.musi-badge-danger  { background: #fee2e2; color: #991b1b; }
.musi-badge-info    { background: var(--primary-50); color: var(--primary-800); }
.musi-badge-gray    { background: var(--gray-100); color: var(--gray-700); }

/* ---- Stats ---- */
.musi-stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.musi-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.musi-stat-icon-blue  { background: var(--primary-50); color: var(--primary-600); }
.musi-stat-icon-green { background: #d1fae5; color: var(--success); }
.musi-stat-icon-amber { background: #fef3c7; color: #d97706; }
.musi-stat-icon-red   { background: #fee2e2; color: var(--danger); }
.musi-stat-value      { font-size: 1.6rem; font-weight: 800; color: var(--gray-900); line-height: 1.1; margin: 6px 0 2px; }
.musi-stat-label      { font-size: 0.78rem; font-weight: 500; color: var(--gray-500); }
.musi-stat-trend      { font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; margin-top: 6px; }
.musi-stat-trend.up   { color: var(--success); }
.musi-stat-trend.down { color: var(--danger); }

/* ---- Table ---- */
.musi-table { width: 100%; border-collapse: collapse; }
.musi-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}
.musi-table td {
    padding: 14px 16px;
    font-size: 0.88rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.musi-table tbody tr { transition: background 0.15s; }
.musi-table tbody tr:hover { background: var(--primary-50); }
.musi-table tbody tr:last-child td { border-bottom: none; }

/* ---- Bottom Nav ---- */
.musi-bottom-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    border-radius: var(--radius);
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 56px;
    transition: var(--transition);
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
}
.musi-bottom-btn svg { width: 22px; height: 22px; transition: var(--transition); }
.musi-bottom-btn.active { color: var(--primary-700); }
.musi-bottom-btn.active svg { transform: translateY(-2px); }
.musi-bottom-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary-600);
    border-radius: 99px;
}

/* ---- Category Chip ---- */
.musi-category {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: 1.5px solid transparent;
}
.musi-category:hover, .musi-category.selected {
    border-color: var(--primary-300);
    box-shadow: 0 4px 16px rgba(37,99,235,0.12);
    transform: translateY(-2px);
}
.musi-category-icon { font-size: 1.8rem; }
.musi-category-label { font-size: 0.75rem; font-weight: 600; text-align: center; }

/* ---- Voucher Card ---- */
.musi-voucher-card {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 60%, #3b82f6 100%);
    border-radius: var(--radius-xl);
    padding: 24px;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(37,99,235,0.28);
}
.musi-voucher-card::before {
    content: '';
    position: absolute;
    top: -20px; right: -20px;
    width: 120px; height: 120px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}
.musi-voucher-card::after {
    content: '';
    position: absolute;
    bottom: -30px; left: -10px;
    width: 100px; height: 100px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}
.musi-voucher-code {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    background: rgba(255,255,255,0.15);
    padding: 8px 16px;
    border-radius: var(--radius);
    display: inline-block;
    backdrop-filter: blur(10px);
}

/* ---- Loading Spinner ---- */
.musi-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
.musi-spinner-blue {
    border-color: var(--primary-100);
    border-top-color: var(--primary-600);
}
.musi-spinner-lg { width: 36px; height: 36px; border-width: 3px; }

/* ---- Skeleton loader ---- */
.musi-skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- Progress bar ---- */
.musi-progress { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.musi-progress-bar { height: 100%; border-radius: 99px; background: var(--primary-600); transition: width 0.4s ease; }
.musi-progress-bar.success { background: var(--success); }
.musi-progress-bar.warning { background: var(--warning); }

/* ---- AI Chat Widget ---- */
.musi-ai-btn {
    position: fixed;
    bottom: 88px;
    right: 20px;
    z-index: 39;
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(37,99,235,0.35);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    color: white;
}
.musi-ai-btn:hover { transform: translateY(-2px) scale(1.05); }

/* ---- Section labels ---- */
.musi-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    margin-bottom: 12px;
}

/* ---- Empty State ---- */
.musi-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    text-align: center;
    color: var(--gray-500);
}
.musi-empty-icon {
    width: 64px;
    height: 64px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.musi-empty-icon svg { width: 28px; height: 28px; color: var(--gray-400); }

/* ---- Divider ---- */
.musi-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 20px 0;
}
.musi-divider-text {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}
.musi-divider-text::before, .musi-divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}
.musi-divider-text span { font-size: 0.78rem; font-weight: 500; color: var(--gray-500); white-space: nowrap; }

/* ---- Auth Page Special ---- */
.auth-wrap {
    min-height: 100vh;
    background: linear-gradient(160deg, #eff6ff 0%, #f8fafc 50%, #e0f2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-card {
    background: #fff;
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.08);
    padding: 36px 32px;
    width: 100%;
    max-width: 420px;
    border: 1px solid rgba(0,0,0,0.04);
}

/* ---- Page Header Strip ---- */
.musi-page-header {
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
    padding: 24px 20px 36px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.musi-page-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0; right: 0;
    height: 24px;
    background: #f8fafc;
    border-radius: 24px 24px 0 0;
}

/* ---- Quick Actions Row ---- */
.musi-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--gray-700);
    transition: var(--transition);
    min-width: 70px;
}
.musi-quick-action-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.musi-quick-action:hover .musi-quick-action-icon { transform: translateY(-3px); box-shadow: var(--shadow); }
.musi-quick-action-label { font-size: 0.72rem; font-weight: 600; text-align: center; color: var(--gray-600); }

/* ---- Toast ---- */
#toast.show { transform: translateX(0); pointer-events: all; }

/* ---- Animations ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes bounceIn { 0% { transform:scale(0.8); opacity:0; } 60% { transform:scale(1.05); } 100% { transform:scale(1); opacity:1; } }

.animate-slide-up { animation: slideUp 0.35s ease-out both; }
.animate-fade-in  { animation: fadeIn 0.4s ease-out both; }
.animate-bounce-in { animation: bounceIn 0.4s ease-out both; }

/* Staggered children */
.stagger > * { animation: slideUp 0.35s ease-out both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }

/* Page transition */
.page-enter { animation: slideUp 0.3s ease-out both; }

/* ---- Number animation ---- */
.musi-counter { font-variant-numeric: tabular-nums; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .auth-card { padding: 28px 20px; border-radius: var(--radius-xl); }
    .musi-stat-value { font-size: 1.3rem; }
    .musi-voucher-code { font-size: 1.1rem; letter-spacing: 0.1em; }
}

/* ---- Print ---- */
@media print {
    #bottom-nav, #main-header, .musi-ai-btn, #page-loader { display: none !important; }
    .musi-voucher-card { box-shadow: none; border: 2px dashed #ccc; }
}
