/* ============================================================
   So-Mobile Portal — Design System
   Bento Box + Apple Palette
   ============================================================ */

/* --- Breadcrumb --- */
.breadcrumb { display:flex; align-items:center; gap:6px; font-size:13px; margin-bottom:12px; flex-wrap:wrap; }
.breadcrumb-link { color:var(--accent, #007AFF); text-decoration:none; transition:opacity .15s; }
.breadcrumb-link:hover { opacity:.7; }
.breadcrumb-sep { color:var(--text-secondary, #86868b); font-size:11px; }
.breadcrumb-current { color:var(--text-secondary, #86868b); }

/* --- Collapsible sidebar sections --- */
.nav-section-title { cursor:pointer; display:flex; justify-content:space-between; align-items:center; user-select:none; }
.nav-chevron { font-size:10px; opacity:.5; transition:transform .2s; margin-left:auto; }
.nav-section.collapsed .nav-chevron { transform:rotate(0deg); }
.nav-section-items { transition:all .2s ease; }

/* --- CSS Variables --- */
:root {
    /* Palette Apple */
    --color-blue: #007AFF;
    --color-violet: #AF52DE;
    --color-red: #FF2D55;
    --color-orange: #FF9500;
    --color-green: #34C759;
    --color-teal: #5AC8FA;
    --color-muted: #8E8E93;

    /* Light theme (default) */
    --color-bg: #FFFFFF;
    --color-surface: #F5F5F7;
    --color-surface-hover: #EBEBED;
    --color-text: #1D1D1F;
    --color-text-secondary: #6E6E73;
    --color-border: #D2D2D7;
    --color-border-light: #E8E8ED;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;

    /* Aliases (compat with new pages) */
    --bg-primary: var(--color-bg);
    --bg-secondary: var(--color-surface);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-secondary);
    --border: var(--color-border);
    --accent: var(--color-blue);
}

/* --- Dark Theme (Apple-style deep black) --- */
[data-theme="dark"] {
    --color-bg: #000000;
    --color-surface: #1C1C1E;
    --color-surface-hover: #2C2C2E;
    --color-text: #F5F5F7;
    --color-text-secondary: #98989D;
    --color-border: #38383A;
    --color-border-light: #2C2C2E;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.7);
}

/* Dark mode specific refinements */
[data-theme="dark"] .bento-tile {
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .card {
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .table-wrap {
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .nav-item.active {
    box-shadow: 0 0 12px rgba(0, 122, 255, 0.3);
}

[data-theme="dark"] .sidebar {
    background: #0D0D0F;
    border-right-color: #1C1C1E;
}

[data-theme="dark"] .phone-preview {
    border-color: #38383A;
}

[data-theme="dark"] .wallet-card {
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.2);
}

[data-theme="dark"] .login-card {
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .toast {
    border: 1px solid rgba(255,255,255,0.1);
}

[data-theme="dark"] code {
    background: #2C2C2E;
}

[data-theme="dark"] .modal {
    background: #1C1C1E;
    border: 1px solid #38383A;
}

/* ═══════════════════════════════════════════════════════════
   PREMIUM APPLE-LIKE ENHANCEMENTS
   Glassmorphism · Gradients · Micro-animations · Deep shadows
   ═══════════════════════════════════════════════════════════ */

/* --- Glassmorphism sidebar --- */
.sidebar {
    background: rgba(255,255,255,0.72) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(0,0,0,0.06) !important;
}
[data-theme="dark"] .sidebar {
    background: rgba(13,13,15,0.82) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(255,255,255,0.06) !important;
}

/* --- Cards with subtle glass effect --- */
.card {
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}
.card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}
[data-theme="dark"] .card {
    background: rgba(28,28,30,0.7);
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
}
[data-theme="dark"] .card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.4), 0 8px 32px rgba(0,0,0,0.3);
}

/* --- Bento tiles with gradient shimmer --- */
.bento-tile {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.6));
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.bento-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-blue), var(--color-violet));
    opacity: 0;
    transition: opacity var(--transition-normal);
}
.bento-tile:hover::before { opacity: 1; }
.bento-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
[data-theme="dark"] .bento-tile {
    background: linear-gradient(135deg, rgba(28,28,30,0.8), rgba(44,44,46,0.6));
    border: 1px solid rgba(255,255,255,0.06);
}

/* --- Premium buttons --- */
.btn-primary {
    background: linear-gradient(135deg, #007AFF, #0055CC) !important;
    box-shadow: 0 2px 8px rgba(0,122,255,0.3);
    transition: all var(--transition-fast);
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(0,122,255,0.4);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0,122,255,0.2);
}

/* --- Nav items micro-animation --- */
.nav-item {
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}
.nav-item:hover {
    background: rgba(0,122,255,0.06);
    transform: translateX(2px);
}
.nav-item.active {
    background: rgba(0,122,255,0.1);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--color-blue);
}

/* --- Modal glassmorphism --- */
.modal-overlay {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl) !important;
    box-shadow: 0 24px 80px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    animation: modalEnter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalEnter {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Page content entrance --- */
#page-content {
    animation: pageEnter 0.25s ease-out;
}
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Badge refinement --- */
.badge, .tag {
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: all var(--transition-fast);
}

/* --- Form inputs premium --- */
.form-input, .form-control, input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid var(--color-border-light);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: var(--color-bg);
}
.form-input:focus, .form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
    outline: none;
}
[data-theme="dark"] .form-input:focus, [data-theme="dark"] input:focus {
    box-shadow: 0 0 0 3px rgba(0,122,255,0.25);
}

/* --- Toast refinement --- */
.toast {
    border-radius: var(--radius-md) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    animation: toastSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastSlide {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Breadcrumb refinement --- */
.breadcrumb {
    padding: 6px 12px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    display: inline-flex;
}

/* --- Scrollbar premium --- */
::-webkit-scrollbar-thumb {
    border-radius: 10px;
}

/* --- Page header gradient text (h1) --- */
.page-header h1 {
    background: linear-gradient(135deg, var(--color-text), var(--color-text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Spinner refined --- */
.spinner {
    border: 3px solid var(--color-border-light);
    border-top-color: var(--color-blue);
    border-radius: 50%;
    width: 28px; height: 28px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   END PREMIUM ENHANCEMENTS
   ═══════════════════════════════════════════════════════════ */

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

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

a:hover {
    text-decoration: underline;
}

/* --- Typography --- */
h1 {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.15;
}

h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

h3 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}

h4 {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
}

.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }
.text-muted { color: var(--color-text-secondary); }
.text-blue { color: var(--color-blue); }
.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }
.text-orange { color: var(--color-orange); }
.text-violet { color: var(--color-violet); }
.text-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* --- Utility --- */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-in {
    animation: fadeIn 0.4s ease forwards;
}

.animate-slide-up {
    animation: slideInUp 0.4s ease forwards;
}

/* Staggered animations for bento tiles */
.bento-tile:nth-child(1) { animation-delay: 0ms; }
.bento-tile:nth-child(2) { animation-delay: 60ms; }
.bento-tile:nth-child(3) { animation-delay: 120ms; }
.bento-tile:nth-child(4) { animation-delay: 180ms; }
.bento-tile:nth-child(5) { animation-delay: 240ms; }
.bento-tile:nth-child(6) { animation-delay: 300ms; }
.bento-tile:nth-child(7) { animation-delay: 360ms; }
.bento-tile:nth-child(8) { animation-delay: 420ms; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-hover) 50%, var(--color-surface) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Logo text gradient (works in both modes) --- */

/* --- Focus visible for accessibility --- */
:focus-visible {
    outline: 2px solid var(--color-blue);
    outline-offset: 2px;
}

/* --- Selection color --- */
::selection {
    background: rgba(0, 122, 255, 0.2);
    color: inherit;
}

/* --- Smooth page transitions --- */
.page-content {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* --- Code blocks --- */
code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.9em;
    background: var(--color-surface);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Hover lift effect for interactive tiles --- */
.bento-tile[onclick]:hover,
.bento-tile[style*="cursor:pointer"]:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* --- Gradient text utility --- */
.text-gradient {
    background: linear-gradient(135deg, var(--color-blue), var(--color-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Micro-interactions --- */

/* Button press feedback */
.btn:not(:disabled):active {
    transform: scale(0.96);
    transition-duration: 0.05s;
}

/* Nav item smooth transition */
.nav-item {
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.nav-item:hover {
    transform: translateX(4px);
}

.nav-item.active:hover {
    transform: none;
}

/* Table row hover highlight */
.table tbody tr {
    transition: background-color 0.15s ease;
}

/* Card hover subtle lift */
.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Tag hover glow */
.tag {
    transition: transform 0.15s ease;
}

.tag:hover {
    transform: scale(1.05);
}

/* Input focus ring animation */
.input:focus, .select:focus, .textarea:focus {
    transition: border-color 0.2s ease, box-shadow 0.3s ease;
}

/* Smooth page transitions */
#page-content {
    transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Sidebar section title subtle animation */
.nav-section-title {
    transition: color 0.2s ease;
}

.nav-section:hover .nav-section-title {
    color: var(--color-text);
}

/* Bento tile value counter animation */
.bento-tile-value {
    transition: color 0.3s ease;
}

/* Theme toggle spin */
.btn-icon:active span {
    display: inline-block;
    animation: spin 0.3s ease;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(180deg); }
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Staggered list items */
.table tbody tr {
    animation: fadeIn 0.3s ease backwards;
}

.table tbody tr:nth-child(1) { animation-delay: 0ms; }
.table tbody tr:nth-child(2) { animation-delay: 30ms; }
.table tbody tr:nth-child(3) { animation-delay: 60ms; }
.table tbody tr:nth-child(4) { animation-delay: 90ms; }
.table tbody tr:nth-child(5) { animation-delay: 120ms; }
.table tbody tr:nth-child(6) { animation-delay: 150ms; }
.table tbody tr:nth-child(7) { animation-delay: 180ms; }
.table tbody tr:nth-child(8) { animation-delay: 210ms; }

/* Modal backdrop blur enhancement */
.modal-overlay.visible {
    animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(8px); }
}

/* Search bar focus expand */
.search-bar input:focus {
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

/* Progress bar shimmer */
.progress-bar-fill {
    background: linear-gradient(90deg, var(--color-blue), #5AC8FA, var(--color-blue));
    background-size: 200% 100%;
    animation: progressShimmer 2s infinite linear;
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Notification badge pulse */
.nav-badge {
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
