/* =========================================
   DESIGN SYSTEM & VARIABLES
========================================= */
:root {
    /* Colors */
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Accents */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #3b82f6;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-bg-dark: rgba(0, 0, 0, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
    
    /* Layout */
    --sidebar-width: 320px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-size: cover;
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

ul {
    list-style: none;
}

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

input {
    font-family: inherit;
    outline: none;
}

/* =========================================
   UTILITIES
========================================= */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}

.glass-panel-dark {
    background: var(--glass-bg-dark);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--glass-border);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--glass-bg);
    color: var(--text-main);
}

.badge {
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

/* =========================================
   APP CONTAINER
========================================= */
.app-container {
    height: 100vh;
    width: 100vw;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    display: flex;
}

/* =========================================
   LOGIN SCREEN
========================================= */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.75rem;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card h1 {
    font-size: 2rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

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

.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-with-icon input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.input-with-icon input:focus, .input-group input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

#login-form .login-btn {
    width: 100%;
    margin-top: 1rem;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    display: none;
}

.login-hint {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-hint ul {
    margin-top: 0.5rem;
    padding-left: 1rem;
}

/* =========================================
   DASHBOARD / LAYOUT
========================================= */
#dashboard-screen {
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.3s ease;
}

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

.mobile-only {
    display: none;
}

/* Todo Section */
.todo-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: hidden;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-title h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.add-item-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.add-item-form input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
    color: var(--text-main);
}

.add-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--primary);
}

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

.todo-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 0.5rem;
}

/* Custom Scrollbar for Todo list */
.todo-list::-webkit-scrollbar {
    width: 6px;
}
.todo-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--glass-bg);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    transition: var(--transition);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.todo-item:hover {
    border-color: var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
}

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

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-top: 2px;
}

.custom-checkbox i {
    font-size: 10px;
    opacity: 0;
    color: white;
    transition: var(--transition);
}

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

.todo-item.completed .custom-checkbox i {
    opacity: 1;
}

.todo-text {
    flex: 1;
    font-size: 0.95rem;
    word-break: break-word;
    cursor: pointer;
}

.delete-todo-btn {
    color: var(--text-muted);
    opacity: 0;
    transition: var(--transition);
}

.todo-item:hover .delete-todo-btn {
    opacity: 1;
}

.delete-todo-btn:hover {
    color: var(--danger);
}

/* User Profile Sidebar Bottom */
.user-profile {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.user-info {
    flex: 1;
}

.username {
    font-weight: 500;
}

.logout-link {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.logout-link:hover {
    color: var(--danger);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem;
    height: 100%;
    overflow-y: auto;
}

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

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.month-nav {
    display: flex;
    gap: 0.25rem;
}

.month-title {
    font-size: 1.5rem;
    min-width: 200px;
}

/* Calendar Grid */
.calendar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow: hidden;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.calendar-cell {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    position: relative;
}

.calendar-cell:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.calendar-cell.other-month {
    opacity: 0.3;
}

.calendar-cell.today {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.calendar-cell.today .date-num {
    background: var(--primary);
    color: white;
}

.date-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.calendar-cell:not(.other-month) .date-num {
    color: var(--text-main);
}

.events-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.events-list::-webkit-scrollbar {
    width: 2px;
}
.events-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
}

.event-chip {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}

.event-chip:hover {
    opacity: 0.8;
}

/* =========================================
   MODAL
========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal {
    transform: scale(0.95);
}

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

.form-row {
    display: flex;
    gap: 1rem;
}

.input-group.half {
    flex: 1;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

/* Dark theme overrides for date/time inputs */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
    cursor: pointer;
}

.color-picker {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1024px) {
    .main-content {
        padding: 1rem;
    }
    
    .calendar-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
    
    #dashboard-screen {
        flex-direction: column;
    }
    
    .sidebar {
        position: absolute;
        left: -100%;
        background: var(--bg-darker);
    }
    
    .sidebar.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }
    
    .calendar-cell {
        min-height: 80px;
    }
    
    .calendar-weekdays div {
        font-size: 0.8rem;
    }
}
