/* Core App Styles - Base layout and theme variables only */
:root {
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --transition-fast: 150ms;
    --transition-medium: 220ms;
    --easing-standard: cubic-bezier(0.2, 0, 0, 1);
}

[data-theme="dark"] {
    /* Dark Mode Colors - Premium Solid Colors */
    --bg-primary: #0d0d0d;
    --bg-secondary: #0f0f0f;
    --bg-card: #111111;
    --text-primary: #ffffff;
    --text-secondary: #e5e5e5;
    --text-muted: #a3a3a3;
    --border-color: #262626;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent horizontal overflow and ensure full width */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-fast) var(--easing-standard), 
                color var(--transition-fast) var(--easing-standard);
    /* Prevent iOS bounce scrolling */
    overscroll-behavior: none;
    /* Prevent text selection on UI elements */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in content areas */
.content-card,
.note-card,
input,
textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Enhanced Input Field Styles */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    background-color: var(--bg-card);
}

input[type="text"]:hover:not(:focus),
input[type="email"]:hover:not(:focus),
input[type="tel"]:hover:not(:focus),
input[type="password"]:hover:not(:focus),
input[type="search"]:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

input:read-only,
input:disabled,
textarea:read-only,
textarea:disabled {
    background-color: var(--bg-secondary);
    cursor: not-allowed;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

input:focus::placeholder,
textarea:focus::placeholder {
    opacity: 0.5;
}

/* Responsive media */
img, video, iframe {
    max-width: 100%;
    height: auto;
}


/* Smooth, fast animations */
* {
    transition: background-color var(--transition-fast) var(--easing-standard),
                color var(--transition-fast) var(--easing-standard),
                border-color var(--transition-fast) var(--easing-standard),
                box-shadow var(--transition-fast) var(--easing-standard),
                transform var(--transition-medium) var(--easing-standard),
                opacity var(--transition-medium) var(--easing-standard);
}

.fade-in { 
    animation: fadeIn var(--transition-medium) var(--easing-standard) both;
}

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

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* App Container */
.app-container {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    background-color: var(--bg-primary);
}

.app-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 1px var(--border-color);
    width: 100%;
}

/* Light mode specific improvements */
[data-theme="light"] .app-wrapper {
    box-shadow: 0 0 0 1px var(--border-color), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
    padding: 0 1.5rem;
    flex-wrap: nowrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
}

.theme-icon {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.theme-toggle:hover .theme-icon {
    color: var(--accent-color);
}

/* Light mode theme toggle improvements */
[data-theme="light"] .theme-toggle {
    background: var(--bg-primary);
}

[data-theme="light"] .theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
}

/* Show moon in dark mode, sun in light mode */
.theme-icon.fa-moon { display: none; }
.theme-icon.fa-sun { display: block; }
[data-theme="dark"] .theme-icon.fa-moon { display: block; }
[data-theme="dark"] .theme-icon.fa-sun { display: none; }

/* Settings Button */
.settings-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.settings-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-1px);
}

/* Logout Button */
.logout-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    padding: 1.5rem;
    min-height: calc(100vh - 4rem);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 5.5rem; /* Header height + gap */
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    margin: 0;
}

.add-course-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast) var(--easing-standard);
    font-size: 0.875rem;
}

.add-course-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.add-course-btn:active {
    transform: scale(0.95);
}

/* Hide floating add button since we moved it to sidebar */
.floating-add-btn {
    display: none !important;
}

/* Course List */
.course-list {
    margin-top: 0;
}

.course-item {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    word-wrap: break-word;
}

.course-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.course-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    border-color: rgba(59, 130, 246, 0.3);
}

.course-item i {
    font-size: 1rem;
    width: 1rem;
    text-align: center;
}

/* Content Area */
.content-area {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents grid blowout */
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    flex: 1;
    min-height: auto; /* Don't force full height */
}

.content-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.content-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    word-break: break-word; /* Prevents long words from overflowing */
}

.content-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    word-break: break-word;
}

/* Notes Grid - Column Layout */
.notes-grid {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.notes-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0; /* Prevent flex items from overflowing */
}

/* Loading & Empty States */
.loading-state, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.empty-icon {
    width: 4rem;
    height: 4rem;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 1.5rem;
    max-width: 24rem;
}

/* =================================== */
/*  Mobile Responsive Design (<= 768px) */
/* =================================== */
@media (max-width: 768px) {
    .app-wrapper {
        margin: 0;
        box-shadow: none;
        min-height: 100dvh;
    }

    .header-content {
        height: 3.5rem;
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }
    
    .header-actions {
        gap: 0.5rem;
    }

    .main-content {
        padding: 1rem;
        min-height: calc(100dvh - 3.5rem);
    }
    
    .dashboard-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidebar {
        order: 2; /* Move sidebar below content */
    }

    .sidebar-card {
        position: static;
        padding: 1rem;
        border-radius: 0.75rem;
    }
    
    .content-area {
        order: 1;
    }

     .content-card {
         padding: 0.75rem;
         border-radius: 0.75rem;
         flex: none; /* Don't expand to fill space */
         min-height: auto;
     }
    
    .content-header {
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .content-title {
        font-size: 1.25rem;
    }
    
    .content-subtitle {
        font-size: 0.875rem;
    }
    
    .notes-grid {
        flex-direction: column;
        gap: 1rem;
    }

    /* Touch-Friendly Buttons */
    .btn, .course-item {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .theme-toggle,
    .settings-btn {
        width: 44px;
        height: 44px;
        min-width: 44px; /* Ensure touch target size */
        padding: 0;
    }
    
    .logout-btn {
        padding: 0.5rem;
    }
    
    .logout-btn span {
        display: none; /* Hide text on mobile, show icon only */
    }
    
    .logout-btn i {
        font-size: 1rem;
        margin-right: 0;
    }
    
     /* Quick Input & Modals */
     .quick-input-bar {
         flex-direction: column;
         gap: 0.5rem;
         margin-bottom: 0.75rem;
     }
    
    .quick-input-bar input,
    .form-group input,
    .quick-input-bar .btn,
    .form-actions .btn {
        width: 100%;
        min-height: 40px;
        font-size: 16px; /* Prevents iOS auto-zoom on focus */
        padding: 10px 14px;
        border-radius: 8px;
        justify-content: center;
    }

    .modal .modal-content:not(.recording-modal-content) {
        width: calc(100% - 2rem);
        margin: 1rem;
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .modal-header h2 {
        font-size: 1.25rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* Small Mobile Screens (<= 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }
    
    .content-card,
    .sidebar-card {
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    .header-content {
        padding: 0 0.75rem;
    }
    
    .logo {
        font-size: 1.125rem;
    }
    
    .content-title {
        font-size: 1.125rem;
    }

    .modal .modal-content:not(.recording-modal-content) {
        width: calc(100% - 1rem);
        margin: 0.5rem;
        padding: 1rem;
    }
}

/* Extra Small Screens (<= 360px) */
@media (max-width: 360px) {
    .header-content {
        padding: 0 0.5rem;
        gap: 0.25rem;
    }

    .logo span {
        display: none; /* Hide "Dashboard" text on very small screens */
    }

    .logo {
        font-size: 1.25rem; /* Keep icon size reasonable */
    }
}   