/**
 * MywayD - Main Stylesheet
 * Mobile-First Design with Modern Aesthetics
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */
:root {
    /* Primary Colors - Teal/Emerald Theme */
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #14b8a6;
    --primary-gradient: linear-gradient(135deg, #0d9488 0%, #059669 50%, #047857 100%);
    
    /* Accent Colors */
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    
    /* Semantic Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    /* Finance Colors */
    --income: #10b981;
    --expense: #ef4444;
    --profit: #0d9488;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Background */
    --bg-body: #f0fdf4;
    --bg-card: #ffffff;
    --bg-header: var(--primary-gradient);
    
    /* Text */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-light: #ffffff;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-Index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-toast: 600;
    
    /* Layout */
    --header-height: 60px;
    --bottom-nav-height: 70px;
    --fab-size: 56px;
    --max-width: 1200px;
    --sidebar-width: 280px;
}

/* Dark Mode (optional) */
[data-theme="dark"] {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-income { color: var(--income); }
.text-expense { color: var(--expense); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ============================================================================
   HEADER
   ============================================================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    color: var(--text-light);
    z-index: var(--z-sticky);
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.header-brand .logo {
    font-size: 1.5rem;
}

.header-date {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-left: auto;
    margin-right: var(--spacing-md);
    position: relative;
    z-index: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    position: relative;
    z-index: 1;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--text-light);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
    position: relative;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-btn .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */
.app-main {
    padding-top: var(--header-height);
    min-height: 100vh;
    min-height: 100dvh;
}

.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ============================================================================
   GREETING SECTION
   ============================================================================ */
.greeting-section {
    background: var(--bg-header);
    color: var(--text-light);
    padding: var(--spacing-lg) var(--spacing-md);
    margin-top: -1px;
    position: relative;
    overflow: hidden;
}

.greeting-section::after {
    content: '';
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    height: 100px;
    background: var(--bg-body);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.greeting-content {
    position: relative;
    z-index: 1;
}

.greeting-text {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
}

.greeting-text .icon {
    font-size: 1.5rem;
}

.greeting-text .name {
    font-weight: 600;
}

/* Voice Input Bar */
.voice-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-xl);
    padding: var(--spacing-sm) var(--spacing-md);
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-lg);
}

.voice-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

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

.voice-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
}

.voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4);
}

.voice-btn.recording {
    animation: pulse 1.5s infinite;
    background: var(--danger);
}

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

/* ============================================================================
   SUMMARY CARDS
   ============================================================================ */
.summary-section {
    padding: var(--spacing-md);
    margin-top: -40px;
    position: relative;
    z-index: 2;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

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

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.summary-card.income::before { background: var(--income); }
.summary-card.expense::before { background: var(--expense); }
.summary-card.balance::before { background: var(--primary); }
.summary-card.mood::before { background: var(--accent); }

.summary-card .label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.summary-card .value {
    font-size: 1.25rem;
    font-weight: 700;
}

.summary-card .change {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    margin-top: var(--spacing-xs);
}

.summary-card .change.up { color: var(--success); }
.summary-card .change.down { color: var(--danger); }

/* ============================================================================
   QUICK ACTIONS
   ============================================================================ */
.quick-actions {
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.quick-actions-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-sm);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

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

.quick-action-btn:active {
    transform: scale(0.95);
}

.quick-action-btn .icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.quick-action-btn .label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

/* Action button colors */
.quick-action-btn[data-action="expense"] .icon { background: rgba(239, 68, 68, 0.1); }
.quick-action-btn[data-action="food"] .icon { background: rgba(249, 115, 22, 0.1); }
.quick-action-btn[data-action="travel"] .icon { background: rgba(59, 130, 246, 0.1); }
.quick-action-btn[data-action="note"] .icon { background: rgba(245, 158, 11, 0.1); }
.quick-action-btn[data-action="sleep"] .icon { background: rgba(139, 92, 246, 0.1); }
.quick-action-btn[data-action="exercise"] .icon { background: rgba(16, 185, 129, 0.1); }
.quick-action-btn[data-action="medicine"] .icon { background: rgba(236, 72, 153, 0.1); }
.quick-action-btn[data-action="shopping"] .icon { background: rgba(6, 182, 212, 0.1); }
.quick-action-btn[data-action="social"] .icon { background: rgba(99, 102, 241, 0.1); }
.quick-action-btn[data-action="event"] .icon { background: rgba(168, 85, 247, 0.1); }

/* ============================================================================
   SECTION CARDS
   ============================================================================ */
.section {
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.section-link {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow);
}

/* ============================================================================
   TODO LIST
   ============================================================================ */
.todo-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.todo-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--gray-50);
    border-radius: var(--radius);
    transition: background var(--transition);
}

.todo-item:hover {
    background: var(--gray-100);
}

.todo-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.todo-item.completed .todo-checkbox {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.todo-content {
    flex: 1;
    min-width: 0;
}

.todo-title {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.todo-item.completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.todo-badge {
    font-size: 0.625rem;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.todo-badge.urgent {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.todo-badge.today {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* ============================================================================
   ACTIVITY TIMELINE
   ============================================================================ */
.activity-list {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--gray-100);
    position: relative;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 40px;
    flex-shrink: 0;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.activity-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-amount {
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.activity-amount.income { color: var(--income); }
.activity-amount.expense { color: var(--expense); }

/* ============================================================================
   GOALS PROGRESS
   ============================================================================ */
.goal-item {
    margin-bottom: var(--spacing-md);
}

.goal-item:last-child {
    margin-bottom: 0;
}

.goal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
}

.goal-title {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.goal-value {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    transition: width 0.5s ease;
}

.goal-meta {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-xs);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================================================
   BOTTOM NAVIGATION
   ============================================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-card);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: var(--z-fixed);
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
    position: relative;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .icon {
    font-size: 1.5rem;
}

.nav-item .label {
    font-size: 0.625rem;
    font-weight: 500;
}

/* FAB (Floating Action Button) */
.fab-container {
    position: relative;
    margin-top: -20px;
}

.fab {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-size: 1.75rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(13, 148, 136, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

.fab.active {
    transform: rotate(45deg);
}

/* FAB Menu */
.fab-menu {
    position: absolute;
    bottom: calc(100% + var(--spacing-sm));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.fab-menu.show {
    opacity: 1;
    visibility: visible;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    cursor: pointer;
    transition: transform var(--transition);
    animation: fabItemIn 0.3s ease backwards;
}

.fab-menu-item:nth-child(1) { animation-delay: 0ms; }
.fab-menu-item:nth-child(2) { animation-delay: 50ms; }
.fab-menu-item:nth-child(3) { animation-delay: 100ms; }

.fab-menu-item:hover {
    transform: scale(1.05);
}

.fab-menu-item .icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.fab-menu-item .label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

@keyframes fabItemIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* FAB Overlay */
.fab-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: calc(var(--z-fixed) - 1);
}

.fab-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   MODAL
   ============================================================================ */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    transform: translateY(100%);
    transition: transform var(--transition-slow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal.show {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    margin: var(--spacing-sm) auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--gray-100);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-secondary);
}

.modal-body {
    padding: var(--spacing-md);
}

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

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

.input-with-icon {
    position: relative;
}

.input-with-icon .form-control {
    padding-right: 44px;
}

.input-with-icon .input-icon {
    position: absolute;
    right: var(--spacing-sm);
    top: 50%;
    transform: translateY(-50%);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-block {
    display: flex;
    width: 100%;
}

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

/* ============================================================================
   UTILITIES
   ============================================================================ */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fadeIn { animation: fadeIn 0.3s ease; }
.animate-slideUp { animation: slideUp 0.3s ease; }

/* Stagger animations for lists */
.stagger-item {
    opacity: 0;
    animation: slideUp 0.4s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }

/* ============================================================================
   RESPONSIVE - TABLET & DESKTOP
   ============================================================================ */
@media (min-width: 768px) {
    :root {
        --bottom-nav-height: 0px;
    }
    
    body {
        padding-bottom: 0;
    }
    
    /* Hide bottom nav on desktop */
    .bottom-nav {
        display: none;
    }
    
    /* Desktop Header */
    .app-header {
        padding: 0 var(--spacing-xl);
    }
    
    .header-date {
        font-size: 0.875rem;
    }
    
    /* Desktop Layout */
    .desktop-container {
        display: flex;
        max-width: 1400px;
        margin: 0 auto;
        gap: var(--spacing-lg);
        padding: var(--spacing-lg);
    }
    
    /* Sidebar */
    .desktop-sidebar {
        width: var(--sidebar-width);
        flex-shrink: 0;
        position: sticky;
        top: calc(var(--header-height) + var(--spacing-lg));
        height: fit-content;
    }
    
    .sidebar-menu {
        background: var(--bg-card);
        border-radius: var(--radius-lg);
        padding: var(--spacing-md);
        box-shadow: var(--shadow);
    }
    
    .sidebar-item {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm) var(--spacing-md);
        border-radius: var(--radius);
        color: var(--text-secondary);
        text-decoration: none;
        transition: all var(--transition);
        margin-bottom: 2px;
    }
    
    .sidebar-item:hover {
        background: var(--gray-100);
        color: var(--text-primary);
    }
    
    .sidebar-item.active {
        background: rgba(13, 148, 136, 0.1);
        color: var(--primary);
    }
    
    .sidebar-item .icon {
        font-size: 1.25rem;
        width: 24px;
        text-align: center;
    }
    
    .sidebar-item .label {
        font-size: 0.875rem;
        font-weight: 500;
    }
    
    /* Main Content */
    .desktop-main {
        flex: 1;
        min-width: 0;
    }
    
    /* Greeting - Desktop */
    .greeting-section {
        border-radius: var(--radius-xl);
        margin-bottom: var(--spacing-lg);
    }
    
    .greeting-section::after {
        display: none;
    }
    
    /* Summary Grid - Desktop */
    .summary-section {
        margin-top: 0;
        padding: 0;
        margin-bottom: var(--spacing-lg);
    }
    
    .summary-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--spacing-md);
    }
    
    .summary-card {
        padding: var(--spacing-lg);
    }
    
    .summary-card .value {
        font-size: 1.5rem;
    }
    
    /* Quick Actions - Desktop */
    .quick-actions {
        padding: 0;
        margin-bottom: var(--spacing-lg);
    }
    
    .quick-actions-grid {
        grid-template-columns: repeat(10, 1fr);
    }
    
    /* Content Grid */
    .content-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-lg);
    }
    
    .section {
        padding: 0;
        margin-bottom: var(--spacing-lg);
    }
    
    /* Right Panel */
    .desktop-right-panel {
        width: 300px;
        flex-shrink: 0;
    }
    
    /* Modal - Desktop */
    .modal {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%) scale(0.9);
        border-radius: var(--radius-xl);
        max-width: 500px;
        width: 90%;
        max-height: 80vh;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
    
    .modal.show {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    
    .modal-handle {
        display: none;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .summary-card .value {
        font-size: 1.75rem;
    }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-md));
    right: var(--spacing-md);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: var(--spacing-xs);
}

/* ============================================
   SIDEBAR STYLES
   ============================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.3);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.sidebar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-item:hover {
    background: var(--gray-100);
    transform: translateY(-2px);
}

.sidebar-item .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-item .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
}

.sidebar-link:hover {
    background: var(--gray-100);
}

.sidebar-link span {
    font-size: 1.25rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
    
    .sidebar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .sidebar-item .icon {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
    
    .sidebar-item .label {
        font-size: 0.75rem;
    }
}


/* ============================================
   SIDEBAR FIX - MOBILE
   ============================================ */

/* Hide sidebar by default - ซ่อนตั้งแต่แรก */
.sidebar {
    position: fixed;
    top: 0;
    right: -320px; /* ซ่อนนอกจอ */
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    visibility: hidden; /* ซ่อน */
}

.sidebar.open {
    right: 0;
    visibility: visible; /* แสดงเมื่อเปิด */
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile layout fix */
@media (max-width: 768px) {
    /* ป้องกัน sidebar ทับ header */
    .sidebar {
        top: 0;
        padding-top: env(safe-area-inset-top);
    }
    
    .sidebar-header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    /* Grid layout สำหรับมือถือ */
    .sidebar-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .sidebar-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.75rem 0.5rem;
        border-radius: 10px;
        text-decoration: none;
        background: transparent;
    }
    
    .sidebar-item .icon {
        width: 44px;
        height: 44px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
        margin-bottom: 0.4rem;
    }
    
    .sidebar-item .label {
        font-size: 0.7rem;
        color: var(--text-secondary);
        text-align: center;
        line-height: 1.2;
    }
}

/* Remove old modal styles that might conflict */
#moreModal {
    display: none !important;
}

/* =============================================
   Quick Action Modals - Medicine, Sleep, Food
   ============================================= */

/* Modal Active State */
.modal.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Form Row - 2 columns */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Quality Buttons - Sleep */
.quality-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.quality-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: white;
    font-size: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.quality-btn small {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.quality-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.quality-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Meal Type Buttons - Food */
.meal-type-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.meal-type-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: white;
    font-size: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.meal-type-btn small {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.meal-type-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.meal-type-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 70px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    font-size: 0.9rem;
    pointer-events: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--success-color);
}

.toast-error {
    background: var(--danger-color);
}

.toast-info {
    background: var(--primary-color);
}
