:root {
    /* Color Palette - Premium & Calm */
    --primary: #6366f1;
    /* Indigo */
    --primary-dark: #4338ca;
    --secondary: #ec4899;
    /* Pink/Rose */
    --accent: #8b5cf6;
    /* Violet */
    --background: #0f172a;
    /* Slate 900 */
    --surface: #1e293b;
    /* Slate 800 */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

:root.light-mode {
    --background: #f8f9fa;
    /* Almost white gray */
    --surface: #ffffff;
    --text-main: #333333;
    /* Dark gray */
    --text-muted: #666666;
    --primary: #0ea5e9;
    /* Sky blue (Celeste) */
    --primary-dark: #0284c7;
}

/* Light Mode Overrides removed from top */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
}

.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    transition: transform 0.2s, background 0.2s;
}

.glass-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

p {
    margin-bottom: var(--spacing-sm);
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-block {
    width: 100%;
}

/* Form Elements */
.form-group {
    margin-bottom: var(--spacing-md);
}

label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.9rem;
    color: var(--text-muted);
}

input,
textarea,
select {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: white;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.w-100 {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Loading */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background: var(--background);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Calendar Views Responsive Layout --- */

.calendar-header {
    padding: 2rem 6rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.calendar-layout {
    display: flex;
    gap: 3rem;
    padding: 0 6rem 3rem 6rem;
    height: calc(100vh - 100px);
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.sidebar-section {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.calendar-section {
    flex: 1;
    background: #fff;
    color: #333;
    border-radius: 12px;
    padding: 1rem;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

#calendar {
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .calendar-layout {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1.5rem;
    }

    .calendar-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .calendar-header .spacer {
        display: none;
    }

    .sidebar-section {
        width: 100%;
        height: auto;
        order: 1;
        /* Sidebar first (Big 3) */
        padding-right: 0;
        overflow-y: visible;
    }

    .calendar-section {
        order: 2;
        /* Calendar second */
        height: 600px;
        /* Fixed height for scrollable calendar */
    }

    .glass-card {
        padding: 1rem;
    }

    /* Adjust Navigation Buttons */
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* --- Modal & Popover Fixes --- */

/* Force specific styling for the Task Modal to avoid transparency issues */
#task-modal .glass-card {
    background-color: var(--surface) !important;
    /* Force solid dark color */
    color: var(--text-main) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Ensure inputs in modal are visible */
#task-modal input,
#task-modal select {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#task-modal label {
    color: var(--text-muted) !important;
}

/* FullCalendar Popover (the "+2 more" popup) Theme */
.fc-theme-standard .fc-popover {
    background-color: var(--surface) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 9999 !important;
}

.fc-theme-standard .fc-popover-header {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

.fc-theme-standard .fc-popover-body {
    background-color: var(--surface) !important;
}

/* Ensure Event Content inside Popover is visible */
.fc-popover .quick-check-btn {
    border-color: rgba(255, 255, 255, 0.9) !important;
}

/* Calendar Event Text Visibility */
.fc-event-main {
    color: #fff !important;
}

/* Light Mode Overrides - Final Cascade */
.light-mode .glass-panel {
    background: #ffffff !important;
    border: 1px solid #666666 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}

.light-mode .glass-card {
    background: #ffffff !important;
    border: 1px solid #666666 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
}

.light-mode .glass-card:hover {
    background: #f8f9fa !important;
    border-color: #333333 !important;
}

.light-mode input,
.light-mode textarea,
.light-mode select {
    background: #ffffff !important;
    border: 1px solid #666666 !important;
    color: #333333 !important;
}

.light-mode .btn-secondary {
    background: #e2e8f0 !important;
    color: #333333 !important;
}

.light-mode .btn-secondary:hover {
    background: #cbd5e1 !important;
}

/* Priority Analysis List Colors */
.list-critical {
    color: #ffcccc;
}

.list-growth {
    color: #ffffcc;
}

.list-strength {
    color: #ccffcc;
}

/* Light Mode Priority/Analysis Overrides */
.light-mode .list-critical {
    color: #dc2626 !important;
    /* Red 600 */
}

.light-mode .list-growth {
    color: #d97706 !important;
    /* Amber 600 */
}

.light-mode .list-strength {
    color: #16a34a !important;
    /* Green 600 */
}

/* --- New Dashboard Styles --- */

/* Progress Bar */
.progress-bar-bg {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
    border-radius: 4px;
    width: 100%;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary));
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Icon Button */
.icon-btn {
    padding: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-left: 0.5rem;
}

/* Action Buttons Grid */
.btn-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    min-height: 130px;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Responsive Utilities */
.desktop-only {
    display: inline-block;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
}