:root {
    /* Purple-blue gradient accents */
    --primary-color-1: #6f42c1; /* Purple */
    --primary-color-2: #4e73df; /* Blue */
    --accent-gradient: linear-gradient(135deg, var(--primary-color-1) 0%, var(--primary-color-2) 100%);

    /* Light Mode Variables */
    --bg-color: #f7f9fc;
    --text-color: #1c274c;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    
    /* Task Colors (Defaults, can be changed in settings) */
    --work-task-color: #4e73df;
    --personal-task-color: #6f42c1;
    --overdue-color: #e74c3c;
    
    /* Calendar Slot Height (60px per hour / 4 slots = 15px per 15 min slot) */
    --slot-height: 15px; 
}

/* Dark Mode Overrides */
.dark-mode {
    --bg-color: #1a1a2e;
    --text-color: #e4e9f2;
    --card-bg: #272741;
    --border-color: #3f3f61;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* --- Base & Layout --- */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

main {
    display: flex;
    max-width: 1400px;
    margin: 20px auto;
    gap: 20px;
    padding: 0 20px;
}

header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

h1 {
    font-size: 1.8rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

button {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 600;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* --- Unscheduled Tasks Area --- */
#unscheduled-area {
    width: 300px;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    box-shadow: var(--shadow);
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

#unscheduled-area h2 {
    font-size: 1.4rem;
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-color-2);
}

#unscheduled-tasks-list {
    list-style: none;
    padding: 0;
}

.unscheduled-area.drag-over {
    background-color: rgba(var(--primary-color-2), 0.1);
    border: 2px dashed var(--primary-color-2);
}

/* --- Calendar View --- */
#calendar-view {
    flex-grow: 1;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* Week Navigation */
.week-navigation {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.week-navigation button {
    background: none;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    box-shadow: none;
}
.week-navigation button:hover {
    background-color: rgba(var(--primary-color-2), 0.1);
}

/* Calendar Grid */
#calendar-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr); 
    max-height: calc(80vh - 70px); /* Adjust height for nav */
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
}

.day-header {
    grid-column: 2 / span 7;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
}

.day-header > div {
    text-align: center;
    padding: 8px 0;
    font-weight: 700;
    border-right: 1px solid var(--border-color);
}
.day-header > div:last-child {
    border-right: none;
}

/* Time Column (Sticky) */
#time-column {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding-top: 5px; 
    /* This must be the total height of a full hour block (4 slots) */
    grid-row: 2 / span 96; /* 24 hours * 4 slots = 96 rows */
}

/* 15-MINUTE SLOT STYLING (CRITICAL CHANGE) */
.time-label {
    text-align: right;
    padding-right: 5px;
    height: calc(var(--slot-height) * 4); /* 60px total for the hour */
    line-height: calc(var(--slot-height) * 4);
    transform: translateY(calc(var(--slot-height) * -0.5)); /* vertically center label */
    font-size: 0.8em;
    color: #6c757d;
}

.day-column {
    display: flex;
    flex-direction: column;
    position: relative; /* For absolute positioning of scheduled tasks */
}

.time-slot {
    height: var(--slot-height); /* 15px per slot */
    border-bottom: 1px dashed rgba(var(--text-color), 0.1);
    border-right: 1px solid var(--border-color);
}

.time-slot.drag-over {
    background-color: rgba(78, 115, 223, 0.2); 
    box-shadow: inset 0 0 5px var(--primary-color-2);
}

.day-column:last-child .time-slot {
    border-right: none;
}


/* --- Task Card Styles --- */
.task-card {
    background-color: var(--card-bg);
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: grab;
    border-left: 5px solid var(--work-task-color); /* Default */
    font-size: 0.9em;
    transition: all 0.1s;
}

.task-card h4 {
    margin: 0 0 5px 0;
    font-size: 1em;
    word-wrap: break-word;
}

.task-card.completed {
    opacity: 0.6;
    background-color: #e9f5ff; /* Lighter background for done tasks */
    border-left: 5px solid #28aa46; /* Green for completion */
    text-decoration: line-through;
    color: #777;
}

/* Scheduled Task Positioning */
.scheduled-task {
    position: absolute;
    width: calc(100% - 2px); 
    left: 1px;
    background-color: #d1e7ff;
    border: 1px solid var(--primary-color-2);
    padding: 4px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 30;
    cursor: grab;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scheduled-task h4 {
    font-size: 0.8em;
    margin: 0;
}

.scheduled-task.completed {
    background-color: #d4edda;
    border: 1px solid #28a745;
    text-decoration: line-through;
}

/* --- Modal Styles --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    padding-top: 60px;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 500px;
    position: relative;
    color: var(--text-color);
}

.modal-content input[type="text"],
.modal-content input[type="datetime-local"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: inherit;
    color: inherit;
    box-sizing: border-box;
}

.modal-content h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    color: var(--primary-color-2);
}

.close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.is-hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    main {
        flex-direction: column;
        padding: 0 10px;
    }
    #unscheduled-area {
        width: 100%;
        max-height: 300px;
    }
}