/* ============================================
   ADULLAM — css/base.css
   Load this file FIRST.
   Design tokens (CSS variables), reset, app shell,
   splash screen, top bar, side drawer, page
   container, bottom navigation, toasts, modal
   container, bottom sheet, buttons, cards, forms.
   ============================================ */

/* CSS Variables — Design System */
:root {
    /* Primary Colors */
    --primary-deep-olive: #30483A;
    --secondary-sage: #718575;
    --bg-warm-ivory: #F8F6F0;
    --card-white: #FFFFFF;
    --accent-terracotta: #C87552;
    --accent-muted-gold: #C7A65A;
    --text-charcoal: #202522;
    --text-slate: #737A75;
    --dark-bg-deep-charcoal: #111815;
    
    /* Derived Colors */
    --primary-dark: #243629;
    --primary-light: #4a6855;
    --sage-light: #94a89c;
    --gold-light: #d9bc7a;
    --gold-dark: #a8883d;
    --terracotta-light: #d68d6f;
    --terracotta-dark: #a55a3e;
    
    /* Dark Mode Overrides */
    --dark-surface: #1a2420;
    --dark-card: #1f2b26;
    --dark-border: #2c3a33;
    --dark-text: #e8ece9;
    --dark-text-secondary: #a0aba4;
    --dark-bg-accent: #18201c;
    
    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --shadow-xl: 0 24px 64px rgba(0,0,0,0.16), 0 8px 16px rgba(0,0,0,0.08);
    
    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Layout */
    --bottom-nav-height: 68px;
    --top-bar-height: 56px;
    --sidebar-width: 280px;
    --max-content-width: 768px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-warm-ivory: var(--dark-bg-deep-charcoal);
    --card-white: var(--dark-card);
    --text-charcoal: var(--dark-text);
    --text-slate: var(--dark-text-secondary);
    --primary-deep-olive: #3d5c4a;
    --secondary-sage: #8a9d92;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.3);
    --shadow-xl: 0 24px 64px rgba(0,0,0,0.5), 0 8px 16px rgba(0,0,0,0.35);
    --dark-border: #2c3a33;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-warm-ivory);
    color: var(--text-charcoal);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ============================================
   APP SHELL
   ============================================ */
.app-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-warm-ivory);
}

.main-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity var(--transition-base);
}

.main-content.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-deep-olive) 0%, var(--primary-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.splash-screen.hidden {
    opacity: 0;
    transform: scale(1.1);
    pointer-events: none;
}

.splash-logo {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.splash-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    animation: pulse 2s ease-in-out infinite;
}

.splash-icon svg {
    width: 100%;
    height: 100%;
}

.splash-title {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--bg-warm-ivory);
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-sm);
}

.splash-subtitle {
    font-size: var(--text-sm);
    color: var(--sage-light);
    letter-spacing: 0.05em;
}

.splash-loader {
    position: absolute;
    bottom: 80px;
    width: 200px;
    height: 3px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: var(--accent-muted-gold);
    border-radius: var(--radius-full);
    animation: load 2s ease-in-out infinite;
}

@keyframes load {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

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

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

/* ============================================
   TOP BAR
   ============================================ */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-height);
    background: var(--card-white);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background var(--transition-base), border-color var(--transition-base);
}

[data-theme="dark"] .top-bar {
    border-bottom-color: var(--dark-border);
}

.top-bar-left,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.top-bar-title {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-charcoal);
    letter-spacing: -0.02em;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-slate);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
    font-size: var(--text-base);
}

.icon-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-charcoal);
}

.icon-btn:active {
    transform: scale(0.92);
}

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--accent-terracotta);
    border-radius: var(--radius-full);
    border: 2px solid var(--card-white);
    font-size: 0.6rem;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 2px;
}

.profile-nav-btn {
    padding: 0;
}

.profile-nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--secondary-sage);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-nav-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-nav-initial {
    font-weight: 700;
    font-size: 13px;
}

/* ============================================
   SIDE DRAWER
   ============================================ */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    transition: opacity var(--transition-base);
    backdrop-filter: blur(2px);
}

.drawer-overlay.show {
    opacity: 1;
}

.side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--card-white);
    z-index: 201;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.side-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.drawer-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-weight: 800;
    font-size: var(--text-lg);
    color: var(--primary-deep-olive);
    letter-spacing: 0.05em;
}

.drawer-logo svg {
    width: 32px;
    height: 32px;
}

.drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    color: var(--text-slate);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    position: relative;
}

.drawer-link i {
    width: 20px;
    text-align: center;
    font-size: var(--text-base);
}

.drawer-link:hover {
    background: rgba(48,72,58,0.08);
    color: var(--primary-deep-olive);
}

.drawer-link.active {
    background: rgba(48,72,58,0.12);
    color: var(--primary-deep-olive);
    font-weight: 600;
}

.drawer-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary-deep-olive);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.drawer-footer {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(0,0,0,0.06);
}

/* ============================================
   PAGE CONTAINER
   ============================================ */
.page-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: var(--top-bar-height);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--spacing-lg));
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.page-container::-webkit-scrollbar {
    width: 4px;
}

.page-container::-webkit-scrollbar-track {
    background: transparent;
}

.page-container::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-full);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--card-white);
    border-top: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background var(--transition-base), border-color var(--transition-base);
}

[data-theme="dark"] .bottom-nav {
    border-top-color: var(--dark-border);
}

.bottom-nav-3 {
    justify-content: space-evenly;
    padding-left: var(--spacing-lg);
    padding-right: var(--spacing-lg);
}

.bottom-nav-3 .nav-item {
    font-size: 0.75rem;
}

.bottom-nav-3 .nav-item i {
    font-size: 1.4rem;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-slate);
    font-size: 0.65rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    padding: 4px 8px;
    position: relative;
}

.nav-item i {
    font-size: 1.25rem;
    transition: transform var(--transition-bounce);
}

.nav-item:hover {
    color: var(--primary-deep-olive);
}

.nav-item:active i {
    transform: scale(0.85);
}

.nav-item.active {
    color: var(--primary-deep-olive);
    font-weight: 600;
}

.nav-item.nav-center {
    position: relative;
    margin-top: -16px;
}

.nav-center-circle {
    width: 48px;
    height: 48px;
    background: var(--primary-deep-olive);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(48,72,58,0.35);
    border: 3px solid var(--card-white);
    transition: all var(--transition-base);
}

.nav-center-circle i {
    color: var(--bg-warm-ivory);
    font-size: 1.25rem;
}

.nav-item.nav-center:active .nav-center-circle {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(48,72,58,0.3);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: var(--top-bar-height);
    right: var(--spacing-md);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

.toast {
    background: var(--card-white);
    color: var(--text-charcoal);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    border-left: 3px solid var(--primary-deep-olive);
}

.toast.success {
    border-left-color: #4caf50;
}

.toast.error {
    border-left-color: #f44336;
}

.toast.warning {
    border-left-color: #ff9800;
}

.toast.hide {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--card-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   BOTTOM SHEET
   ============================================ */
.sheet-container {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.sheet-content {
    position: relative;
    background: var(--card-white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease-out;
    max-height: 80vh;
    overflow-y: auto;
    width: 100%;
    max-width: var(--max-content-width);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-full);
    margin: 0 auto var(--spacing-md);
}

[data-theme="dark"] .sheet-handle {
    background: rgba(255,255,255,0.2);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

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

.btn-primary {
    background: var(--primary-deep-olive);
    color: var(--bg-warm-ivory);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-sage);
    color: white;
}

.btn-secondary:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background: var(--accent-terracotta);
    color: white;
}

.btn-accent:hover {
    background: var(--terracotta-dark);
    box-shadow: var(--shadow-md);
}

.btn-gold {
    background: var(--accent-muted-gold);
    color: var(--text-charcoal);
}

.btn-gold:hover {
    background: var(--gold-dark);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: transparent;
    color: var(--primary-deep-olive);
    border: 2px solid var(--primary-deep-olive);
}

.btn-outline:hover {
    background: rgba(48,72,58,0.08);
}

.btn-sm {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--text-base);
}

.btn-block {
    width: 100%;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--card-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    border: 1px solid rgba(0,0,0,0.04);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-charcoal);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--spacing-md);
    border: 2px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    background: var(--card-white);
    color: var(--text-charcoal);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--primary-deep-olive);
    box-shadow: 0 0 0 3px rgba(48,72,58,0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

