/**
 * TaskFlow - Main Stylesheet
 * iOS 26 inspired design with glassmorphism and dynamic effects
 */

/* ============================================
   CSS Variables & Themes
   ============================================ */

:root {
    /* Colors - Light Theme */
    --primary: #007AFF;
    --primary-rgb: 0, 122, 255;
    --primary-dark: #0056CC;
    --primary-light: #4DA3FF;
    
    --success: #34C759;
    --success-rgb: 52, 199, 89;
    --warning: #FF9500;
    --warning-rgb: 255, 149, 0;
    --danger: #FF3B30;
    --danger-rgb: 255, 59, 48;
    
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E5E5EA;
    --bg-glass: rgba(255, 255, 255, 0.72);
    --bg-glass-heavy: rgba(255, 255, 255, 0.85);
    --bg-overlay: rgba(0, 0, 0, 0.4);
    
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-tertiary: #8E8E93;
    --text-quaternary: #C7C7CC;
    
    --border-color: rgba(0, 0, 0, 0.1);
    --border-light: rgba(0, 0, 0, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Blur */
    --blur-sm: 8px;
    --blur-md: 16px;
    --blur-lg: 24px;
    --blur-xl: 40px;
    
    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-toast: 400;
    --z-tooltip: 500;
    
    /* Font */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-glass: rgba(28, 28, 30, 0.72);
    --bg-glass-heavy: rgba(28, 28, 30, 0.85);
    --bg-overlay: rgba(0, 0, 0, 0.6);
    
    --text-primary: #FFFFFF;
    --text-secondary: #EBEBF5;
    --text-tertiary: #8E8E93;
    --text-quaternary: #48484A;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Auto theme based on system */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg-primary: #000000;
        --bg-secondary: #1C1C1E;
        --bg-tertiary: #2C2C2E;
        --bg-glass: rgba(28, 28, 30, 0.72);
        --bg-glass-heavy: rgba(28, 28, 30, 0.85);
        --bg-overlay: rgba(0, 0, 0, 0.6);
        
        --text-primary: #FFFFFF;
        --text-secondary: #EBEBF5;
        --text-tertiary: #8E8E93;
        --text-quaternary: #48484A;
        
        --border-color: rgba(255, 255, 255, 0.1);
        --border-light: rgba(255, 255, 255, 0.05);
        --shadow-color: rgba(0, 0, 0, 0.3);
    }
}

/* ============================================
   Reset & Base Styles
   ============================================ */

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

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

a:hover {
    opacity: 0.8;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
}

img, svg {
    display: block;
    max-width: 100%;
}

/* ============================================
   Layout Components
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-xl));
    -webkit-backdrop-filter: blur(var(--blur-xl));
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: var(--z-sticky);
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-logo-icon {
    font-size: 1.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.nav-item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.nav-item-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-light);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), #5856D6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.main-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-xl));
    -webkit-backdrop-filter: blur(var(--blur-xl));
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.main-body {
    flex: 1;
    padding: var(--space-xl);
    overflow-y: auto;
}

/* ============================================
   Glass Cards
   ============================================ */

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 24px var(--shadow-color);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--shadow-color);
}

.glass-card-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.glass-card-body {
    padding: var(--space-lg);
}

.glass-card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

.glass-card-danger {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

/* Dashboard Styles */
.stat-card {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-card .glass-card-body {
    padding: var(--space-md);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.stat-card-danger {
    animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.quick-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.quick-actions .btn {
    flex: 1;
    min-width: 140px;
}

.dashboard-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-sm);
}

.event-list-mini {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.event-item-mini {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.event-item-mini:hover {
    background: var(--bg-tertiary);
}

.event-color-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.event-time-mini {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 60px;
}

.event-title-mini {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-stat {
    margin-bottom: var(--space-lg);
}

.progress-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-stat-value {
    font-weight: 700;
    color: var(--text-primary);
}

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

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.stats-summary {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.stats-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border-light);
}

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

.stats-summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stats-summary-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

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

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(var(--success-rgb), 0.4);
}

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

.btn-danger:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(var(--danger-rgb), 0.4);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: 1.125rem;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

.btn-pill {
    border-radius: var(--radius-full);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), #5856D6);
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 8px 32px rgba(var(--primary-rgb), 0.4);
    z-index: var(--z-sticky);
    transition: all var(--transition-spring);
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 12px 40px rgba(var(--primary-rgb), 0.5);
}

/* ============================================
   Form Elements
   ============================================ */

.form-group {
    margin-bottom: var(--space-md);
}

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

.form-control {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

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

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

.form-control-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-sm));
    -webkit-backdrop-filter: blur(var(--blur-sm));
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md) center;
    background-size: 16px;
    padding-right: 40px;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.form-check-input {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    appearance: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.form-check-input:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.form-check-input:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.form-check-input[type="radio"] {
    border-radius: var(--radius-full);
}

.form-check-input[type="radio"]:checked::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: var(--radius-full);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: '';
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============================================
   Task Items
   ============================================ */

.task-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.task-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--task-color, var(--primary));
    border-radius: 2px;
}

.task-item:hover {
    background: var(--bg-glass-heavy);
    transform: translateX(4px);
}

.task-item.completed {
    opacity: 0.6;
}

.task-item.completed .task-title {
    text-decoration: line-through;
}

.task-checkbox {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-top: 2px;
}

.task-checkbox:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.task-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

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

.task-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: var(--space-xs);
    word-wrap: break-word;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.task-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: var(--space-sm);
}

.task-category-tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    font-weight: 500;
}

.task-actions {
    display: flex;
    gap: var(--space-xs);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.task-item:hover .task-actions {
    opacity: 1;
}

/* Priority badges */
.priority-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.priority-high {
    background: rgba(var(--danger-rgb), 0.15);
    color: var(--danger);
}

.priority-medium {
    background: rgba(var(--warning-rgb), 0.15);
    color: var(--warning);
}

.priority-low {
    background: rgba(var(--success-rgb), 0.15);
    color: var(--success);
}

/* ============================================
   Calendar
   ============================================ */

.calendar-container {
    height: calc(100vh - 200px);
    min-height: 500px;
}

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

.calendar-nav {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.calendar-title {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
}

.calendar-views {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 4px;
}

.calendar-view-btn {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.calendar-view-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.calendar-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.calendar-header-row {
    display: contents;
}

.calendar-header-cell {
    padding: var(--space-md);
    text-align: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.calendar-header-cell:first-child {
    border-right: 1px solid var(--border-color);
}

.calendar-time-slot {
    padding: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: right;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-light);
    height: 60px;
}

.calendar-cell {
    position: relative;
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    min-height: 60px;
    padding: 2px;
}

.calendar-cell:last-child {
    border-right: none;
}

.calendar-event {
    position: absolute;
    left: 2px;
    right: 2px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    z-index: 1;
}

.calendar-event:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 2;
}

.calendar-event-task {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.9), rgba(88, 86, 214, 0.9));
    color: white;
}

.calendar-event-block {
    background: linear-gradient(135deg, rgba(var(--success-rgb), 0.9), rgba(48, 176, 80, 0.9));
    color: white;
}

/* Monthly calendar */
.calendar-monthly {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.calendar-monthly-header {
    display: contents;
}

.calendar-monthly-header-cell {
    padding: var(--space-md) var(--space-sm);
    text-align: center;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-day {
    background: var(--bg-secondary);
    min-height: 130px;
    padding: var(--space-md);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-day:hover {
    background: var(--bg-glass-heavy);
}

.calendar-day-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    margin-bottom: var(--space-xs);
}

.calendar-day-number {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.calendar-all-day-indicator {
    font-size: 0.6rem;
    opacity: 0.8;
}

.calendar-day.today {
    background: rgba(var(--primary-rgb), 0.05);
}

.calendar-day.today .calendar-day-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.calendar-day.other-month {
    background: var(--bg-tertiary);
    opacity: 0.5;
}

.calendar-day.other-month:hover {
    opacity: 0.7;
}

.calendar-day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-day-event {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: transform var(--transition-fast);
    line-height: 1.4;
}

.calendar-day-event:hover {
    transform: translateX(2px);
}

.event-time {
    font-weight: 700;
    opacity: 0.9;
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(var(--blur-sm));
    -webkit-backdrop-filter: blur(var(--blur-sm));
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    overflow: hidden;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(var(--blur-xl));
    -webkit-backdrop-filter: blur(var(--blur-xl));
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 80px var(--shadow-color);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-spring);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.modal-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    width: 100%;
}

.modal-footer-actions .btn {
    width: 100%;
}

.modal-footer .btn-danger {
    width: 100%;
    margin-bottom: var(--space-sm);
}

/* Color Picker Grid */
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
    width: 100%;
}

.color-picker-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.6);
    font-weight: bold;
    min-height: 40px;
    max-height: 50px;
    box-sizing: border-box;
}

.color-picker-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.color-picker-option.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

/* Toggle Switch */
.form-check-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
}

.form-check-toggle .form-check-input {
    display: none;
}

.form-check-toggle-slider {
    position: relative;
    width: 50px;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.form-check-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-fast);
}

.form-check-toggle .form-check-input:checked + .form-check-toggle-slider {
    background: var(--primary);
}

.form-check-toggle .form-check-input:checked + .form-check-toggle-slider::after {
    transform: translateX(22px);
}

.form-check-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* Form Hints */
.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* Form Control Large */
.form-control-lg {
    padding: var(--space-md);
    font-size: 1.0625rem;
}

/* Event Time Section */
.event-time-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.event-time-section .form-group {
    margin-bottom: var(--space-sm);
}

.event-time-section .form-group:last-child {
    margin-bottom: 0;
}

.event-time-section .grid-2 {
    gap: var(--space-sm);
}

/* Duration Picker */
.duration-picker {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    align-items: center;
}

.duration-btn {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 44px;
    text-align: center;
}

.duration-btn:hover {
    background: var(--bg-glass-heavy);
    border-color: var(--primary);
}

.duration-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.duration-input {
    width: 70px !important;
    text-align: center;
}

/* Recurrence Details (collapsible) */
.recurrence-details {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    margin-top: var(--space-sm);
}

.recurrence-summary {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.recurrence-summary::-webkit-details-marker {
    display: none;
}

.recurrence-summary::after {
    content: '▸';
    margin-left: auto;
    transition: transform var(--transition-fast);
}

.recurrence-details[open] .recurrence-summary::after {
    transform: rotate(90deg);
}

.recurrence-content {
    padding: var(--space-sm) var(--space-md) var(--space-md);
    border-top: 1px solid var(--border-light);
}

.recurrence-content .form-group {
    margin-bottom: var(--space-sm);
}

.recurrence-content .form-group:last-child {
    margin-bottom: 0;
}

/* Category Select */
.category-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-sm) center;
    background-size: 20px;
    padding-right: var(--space-xl);
}

/* Button with icon and text */
.btn-icon-text {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* ============================================
   Toast Notifications
   ============================================ */

.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(var(--blur-lg));
    -webkit-backdrop-filter: blur(var(--blur-lg));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: 0 8px 32px var(--shadow-color);
    min-width: 300px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform var(--transition-spring);
}

.toast.show {
    transform: translateX(0);
}

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

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

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

.toast-warning .toast-icon {
    color: var(--warning);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.toast-close {
    color: var(--text-tertiary);
    padding: var(--space-xs);
}

/* ============================================
   Loading States
   ============================================ */

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

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

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

/* ============================================
   Dropdown Menu
   ============================================ */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-sm);
    background: var(--bg-glass-heavy);
    backdrop-filter: blur(var(--blur-xl));
    -webkit-backdrop-filter: blur(var(--blur-xl));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px var(--shadow-color);
    min-width: 180px;
    padding: var(--space-sm);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-sm) 0;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-overlay);
        z-index: calc(var(--z-sticky) - 1);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
    }
    
    .sidebar.open + .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    :root {
        --space-lg: 20px;
        --space-xl: 24px;
    }
    
    .main-header {
        padding: var(--space-md);
    }
    
    .main-body {
        padding: var(--space-md);
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .calendar-container {
        height: calc(100vh - 160px);
    }
    
    .fab {
        bottom: var(--space-lg);
        right: var(--space-lg);
        width: 56px;
        height: 56px;
    }
    
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
        overflow: hidden;
    }
    
    .modal {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        margin-top: auto;
    }
    
    .modal-body {
        padding: var(--space-md);
        overflow-x: hidden;
    }
    
    .modal-header {
        padding: var(--space-md);
    }
    
    .modal-footer {
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .modal-footer .btn-danger {
        width: 100%;
        order: 3;
    }
    
    .modal-footer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }
    
    .modal-footer-actions .btn {
        width: 100%;
    }
    
    /* Improve form inputs for touch */
    .form-control {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-control-lg {
        min-height: 52px;
    }
    
    textarea.form-control {
        min-height: 70px;
    }
    
    /* Color picker on mobile - smaller */
    .color-picker-grid {
        gap: 6px;
    }
    
    .color-picker-option {
        min-height: 36px;
        max-height: 42px;
        border-width: 2px;
    }
    
    /* Toggle switch */
    .form-check-toggle-slider {
        width: 50px;
        height: 28px;
    }
    
    .form-check-toggle-slider::after {
        width: 22px;
        height: 22px;
    }
    
    .form-check-toggle .form-check-input:checked + .form-check-toggle-slider::after {
        transform: translateX(22px);
    }
    
    /* Event time section */
    .event-time-section {
        padding: var(--space-sm);
    }
    
    /* Form groups spacing */
    .form-group {
        margin-bottom: var(--space-sm);
    }
}

@media (max-width: 480px) {
    .calendar-views {
        display: none;
    }
    
    .header-actions .btn:not(.btn-icon) span {
        display: none;
    }
    
    /* Stack date/time inputs on very small screens */
    .event-time-section .grid-2 {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .btn-icon-text .btn-text {
        display: none;
    }
    
    /* Even smaller color picker */
    .color-picker-option {
        min-height: 32px;
        max-height: 38px;
    }
}

/* ============================================
   Animations
   ============================================ */

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

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

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

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

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

.animate-fadeIn {
    animation: fadeIn var(--transition-base) forwards;
}

.animate-slideUp {
    animation: slideUp var(--transition-base) forwards;
}

.animate-slideDown {
    animation: slideDown var(--transition-base) forwards;
}

.animate-scaleIn {
    animation: scaleIn var(--transition-spring) forwards;
}

/* Staggered animations */
.stagger-children > * {
    opacity: 0;
    animation: slideUp var(--transition-base) forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }

/* ============================================
   Utilities
   ============================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-small { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Color utilities */
.bg-primary { background-color: var(--primary); }
.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--warning); }
.bg-danger { background-color: var(--danger); }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* ============================================
   Progress Bar
   ============================================ */

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

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

/* ============================================
   Update System Styles
   ============================================ */

#update-log {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] #update-log {
    background: rgba(0, 0, 0, 0.3);
}

#update-log div {
    padding: 2px 0;
    border-bottom: 1px solid var(--border-light);
}

#update-log div:last-child {
    border-bottom: none;
}
