/* Modern Reset & Base */
:root {
    --bg-start: #0f1a12;
    --bg-end:   #0a0f0a;
    --card-bg:  #0c120d;
    --input-bg: #0a0e0b;
    --border:   #c026d3;
    --accent:   #d946ef;
    --accent-dark: #b91cf5;
    --text:     #ffffff;
    --text-dim: #d1a8ff;
    --glow:     rgba(192, 38, 211, 0.25);
    --glow-strong: rgba(217, 70, 239, 0.4);
    
    /* Mobile optimizations */
    --touch-target-min: 44px;
    --mobile-padding: 12px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

body {
    background: radial-gradient(ellipse at bottom, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 2rem;
    padding-top: 4rem;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Announcement Bar - Optimized */
.announcement-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(44, 1, 44, 0.85);
    color: #ffffff;
    text-align: center;
    padding: 0.75rem;
    z-index: 1000;
    font-size: 1rem;
    border-bottom: 1px solid rgba(192, 38, 211, 0.18);
    backdrop-filter: blur(8px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.3s ease;
}

/* Logo */
.logo-text {
    font-size: 2.8rem;
    margin: 0;
    line-height: 1;
    text-align: center;
    font-weight: 800;
    background: linear-gradient(90deg, #d946ef, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(217, 70, 239, 0.6);
}

/* Stars Background - Performance Optimized */
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}

.star {
    position: absolute;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.75;
    animation: twinkle 4.5s infinite alternate;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.5);
    will-change: transform, opacity; /* Performance hint */
}

@keyframes twinkle {
    0%   { opacity: 0.45; transform: scale(0.85); }
    100% { opacity: 0.95; transform: scale(1.15); }
}

/* Container */
.container {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* Navbar - Mobile Optimized */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 0.5rem 0;
    background: transparent;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}

/* Menu Toggle - Touch Friendly */
.menu-toggle {
    padding: 0.6rem 0.9rem;
    border-radius: 0.5rem;
    color: #ffffff;
    cursor: pointer;
    border: none;
    font-size: 1.6rem;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

.menu-toggle:hover {
    color: var(--accent);
    text-shadow: 0 0 12px var(--glow);
    transform: scale(1.1);
}

.menu-toggle:active {
    transform: scale(0.95);
}

/* Sidebar - Mobile First */
.sidebar {
    position: fixed;
    top: 3rem;
    left: -280px;
    width: 280px;
    height: calc(100% - 3rem);
    background: rgba(12, 18, 13, 0.98);
    backdrop-filter: blur(20px);
    padding: 1rem 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    border-right: 1px solid rgba(192, 38, 211, 0.3);
    box-shadow: 0 0 25px rgba(192, 38, 211, 0.12);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar.open {
    left: 0;
}

.sidebar a {
    color: rgba(255,255,255,0.94);
    padding: 0.9rem 1.2rem;
    text-decoration: none;
    display: block;
    transition: all 0.2s;
    background: rgba(192, 38, 211, 0.02);
    margin: 0 0.6rem 0.2rem;
    border-radius: 8px;
    min-height: var(--touch-target-min);
    font-size: 1rem;
}

.sidebar a:active {
    background: rgba(192, 38, 211, 0.2);
    transform: scale(0.98);
}

.sidebar-section-header {
    position: relative;
    padding: 0.8rem 1rem;
    font-weight: bold;
    color: var(--accent);
    border-bottom: 1px solid rgba(192,38,211,0.3);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.sidebar-close {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #ffffff;
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    opacity: 0.75;
    transition: all 0.2s ease;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
}

.sidebar-close:hover,
.sidebar-close:focus {
    opacity: 1;
    color: var(--accent);
    transform: translateY(-50%) scale(1.1);
}

.sidebar-close:active {
    transform: translateY(-50%) scale(0.95);
}

/* Controls - Mobile Optimized */
.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.subject-controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 3.5rem 0 2rem;
    flex-wrap: wrap;
}

/* Form Elements - Touch Friendly */
input, select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    background: var(--input-bg);
    color: #ffffff;
    font-size: 1rem;
    width: 220px;
    max-width: 100%;
    transition: all 0.25s ease;
    min-height: var(--touch-target-min);
}

input[type="date"] {
    color-scheme: dark;
    width: 180px;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--glow);
    outline: none;
}

input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    cursor: pointer;
    margin-right: 0.75rem;
}

input[type="radio"] {
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    cursor: pointer;
    margin-right: 0.75rem;
}

/* Buttons - Touch Optimized */
button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    color: #ffffff;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    min-width: 120px;
    min-height: var(--touch-target-min);
    transition: all 0.25s ease;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

button:active {
    transform: scale(0.97);
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

button:active::after {
    width: 100%;
    height: 100%;
}

/* Button Colors */
.bg-blue-600 { background-color: #2563eb; }
.bg-blue-600:hover { background-color: #1d4ed8; }
.bg-blue-600:active { background-color: #1e40af; }

.bg-red-600 { background-color: #dc2626; }
.bg-red-600:hover { background-color: #b91c1c; }
.bg-red-600:active { background-color: #991b1b; }

.bg-green-600 { background-color: #16a34a; }
.bg-green-600:hover { background-color: #15803d; }
.bg-green-600:active { background-color: #166534; }

/* ==================== WEEK NAVIGATION ==================== */
.week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(192, 38, 211, 0.07);
    border: 1px solid rgba(192, 38, 211, 0.2);
    border-radius: 0.75rem;
}

.week-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 100px;
    text-align: center;
    letter-spacing: 0.03em;
}

.week-nav-btn {
    background: rgba(192, 38, 211, 0.15);
    border: 1px solid rgba(192, 38, 211, 0.4);
    color: #ffffff;
    padding: 0.5rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    min-width: auto;
    cursor: pointer;
    transition: all 0.2s ease;
}

.week-nav-btn:hover {
    background: rgba(192, 38, 211, 0.3);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--glow);
}

.week-nav-btn:active {
    transform: scale(0.96);
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Day Cards */
.day-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    min-height: 280px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5), 0 0 20px var(--glow);
    backdrop-filter: blur(4px);
}

.day-section:hover {
    background: #2d3748;
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.6), 0 0 30px var(--glow-strong);
}

/* Drag-over highlight */
.day-section.drag-over {
    background: rgba(192, 38, 211, 0.15);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), 0 12px 35px rgba(0,0,0,0.6);
    transform: translateY(-3px);
}

/* Subjects Section */
.subjects-section {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    margin-top: 2rem;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 8px 25px rgba(0,0,0,0.5), 0 0 20px var(--glow);
    backdrop-filter: blur(4px);
}

.subjects-section:hover {
    background: #2d3748;
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.6), 0 0 30px var(--glow-strong);
}

/* Download Section */
.download-section {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

/* Typography */
h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #ffffff;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #ffffff;
}

/* Task Lists - Scrollable on Mobile */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================== TASK CARD ==================== */
.task-list li {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(192, 38, 211, 0.08);
    border: 1px solid rgba(192, 38, 211, 0.3);
    border-radius: 0.5rem;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    word-break: break-word;
    gap: 0.4rem;
    cursor: grab;
    user-select: none;
}

.task-list li:active {
    cursor: grabbing;
}

.task-list li.dragging {
    opacity: 0.45;
    border-style: dashed;
    border-color: var(--accent);
    transform: scale(0.97);
}

.task-list li.drag-placeholder {
    background: rgba(192, 38, 211, 0.12);
    border: 2px dashed var(--accent);
    min-height: 48px;
    border-radius: 0.5rem;
}

.task-list li.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.task-list li.completed span {
    text-decoration: line-through;
}

/* Task card top row: checkbox + title + delete */
.task-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.task-card-top .task-title {
    flex: 1;
    text-align: left;
    font-size: 0.97rem;
    line-height: 1.4;
}

/* Delete button */
.task-delete-btn {
    background: none;
    border: none;
    color: rgba(255, 100, 100, 0.65);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: 0.3rem;
    min-width: auto;
    min-height: auto;
    line-height: 1;
    transition: color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.task-delete-btn:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.12);
}

.task-delete-btn:active {
    transform: scale(0.9);
}

/* Task deadline badge */
.task-deadline-badge {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-align: left;
    padding: 0.15rem 0.5rem;
    background: rgba(192, 38, 211, 0.12);
    border-radius: 0.25rem;
    display: inline-block;
    width: fit-content;
    letter-spacing: 0.01em;
}

/* Subject Lists */
.subject-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.subject-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(192, 38, 211, 0.08);
    border: 1px solid rgba(192, 38, 211, 0.3);
    border-radius: 0.375rem;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.subject-list li:active {
    background: rgba(192, 38, 211, 0.15);
}

/* Utility Classes */
.text-sm { font-size: 0.875rem; }
.text-gray-300 { color: var(--text-dim); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.flex-1 { flex: 1; }
.ml-2 { margin-left: 0.5rem; }

.header-titles {
    user-select: none;
    pointer-events: none;
}

.header-titles h1 {
    background: linear-gradient(90deg, var(--accent-dark), var(--accent), #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Loading Indicator */
#loadingIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* Temporary Message */
#tempMessage {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(76, 175, 80, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 10001;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    pointer-events: none;
}

/* ============================================ */
/* MOBILE OPTIMIZATIONS */
/* ============================================ */

@media (max-width: 768px) {
    body {
        padding: 1rem;
        padding-top: 3.5rem;
    }
    
    .announcement-bar {
        font-size: 0.85rem;
        padding: 0.6rem;
        white-space: normal;
        word-break: break-word;
    }
    
    .logo-text {
        font-size: 2rem;
    }
    
    .controls, .subject-controls {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    
    input, select, button {
        width: 100%;
        max-width: 280px;
        margin-bottom: 0;
        font-size: 0.95rem;
    }

    input[type="date"] {
        width: 100%;
        max-width: 280px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .day-section {
        padding: 1rem;
        min-height: auto;
    }
    
    .day-section:hover {
        transform: none;
    }
    
    .subjects-section {
        padding: 1rem;
    }
    
    .subjects-section:hover {
        transform: none;
    }
    
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-left, .nav-right {
        width: 100%;
        justify-content: center;
    }
    
    .sidebar {
        width: 260px;
        left: -260px;
        top: 2.5rem;
        height: calc(100% - 2.5rem);
    }
    
    .sidebar a {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }
    
    .sidebar-close {
        font-size: 2.2rem;
        padding: 0.4rem 0.8rem;
        right: 0.8rem;
    }
    
    .task-list {
        max-height: 300px;
    }
    
    .task-list li {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .subject-list li {
        padding: 0.6rem 0.8rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    button {
        min-height: 44px;
    }
    
    input, select {
        min-height: 44px;
    }

    .week-nav {
        gap: 1rem;
        padding: 0.6rem 1rem;
    }

    .week-label {
        font-size: 1rem;
    }

    .week-nav-btn {
        font-size: 0.85rem;
        padding: 0.45rem 0.9rem;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    body {
        padding: 0.75rem;
        padding-top: 3rem;
    }
    
    .announcement-bar {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    .logo-text {
        font-size: 1.6rem;
    }
    
    input, select, button {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        max-width: 240px;
    }

    input[type="date"] {
        max-width: 240px;
    }
    
    .sidebar {
        width: 240px;
        left: -240px;
    }
    
    .sidebar a {
        padding: 0.7rem 0.9rem;
        font-size: 0.9rem;
    }
    
    .sidebar-close {
        font-size: 1.8rem;
        right: 0.6rem;
    }
    
    .day-section {
        padding: 0.8rem;
    }
    
    .task-list li {
        font-size: 0.88rem;
    }
    
    .subject-list li {
        flex-wrap: wrap;
    }
    
    #tempMessage {
        font-size: 12px;
        padding: 6px 12px;
        bottom: 16px;
    }
}

/* Landscape Mode */
@media (max-width: 896px) and (orientation: landscape) {
    body {
        padding: 0.5rem;
        padding-top: 3rem;
    }
    
    .task-list {
        max-height: 180px;
    }
    
    .grid {
        gap: 0.75rem;
    }
    
    .day-section {
        padding: 0.75rem;
    }
    
    .sidebar {
        top: 2.8rem;
        height: calc(100% - 2.8rem);
    }
}

/* Tablet Devices */
@media (min-width: 769px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    body {
        padding: 1.5rem;
        padding-top: 4rem;
    }
    
    .task-list {
        max-height: 350px;
    }
}

/* High DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .star {
        box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.5);
    }
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .star {
        animation: none;
        opacity: 0.5;
    }
    
    button:active {
        transform: none;
    }
}

/* Print Styles */
@media print {
    .announcement-bar,
    .sidebar,
    .menu-toggle,
    .controls,
    .subject-controls,
    .download-section,
    .stars,
    .week-nav {
        display: none !important;
    }
    
    body {
        padding: 0;
        background: white;
    }
    
    .day-section,
    .subjects-section {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}