:root {
    --bg-light: #f8f9fa;
    --text-light: #212529;
    --bg-dark: #212529;
    --text-dark: #f8f9fa;
    --task-color: #4cc9f0;
    --meeting-color: #f72585;
    --personal-color: #7209b7;
    --unassigned-color: #adb5bd;
    --border-light: #dee2e6;
    --border-dark: #495057;
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-dark: 0 4px 6px rgba(0, 0, 0, 0.3);
    --card-light: #ffffff;
    --card-dark: #343a40;
    
    /* Rainbow theme colors */
    --rainbow-1: #ff595e;
    --rainbow-2: #ffca3a;
    --rainbow-3: #8ac926;
    --rainbow-4: #1982c4;
    --rainbow-5: #6a4c93;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-light);
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

header {
    position: sticky;
    top: 0;
    background-color: var(--bg-light);
    box-shadow: var(--shadow-light);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    transition: background-color 0.3s, box-shadow 0.3s;
}

body.dark-mode header {
    background-color: var(--bg-dark);
    box-shadow: var(--shadow-dark);
}

h1 {
    font-size: 1.5rem;
    margin: 0;
}

.current-date {
    font-weight: 300;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
}

.tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

body.dark-mode .tabs {
    border-color: var(--border-dark);
}

.tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: border-color 0.3s;
}

.tab.active {
    border-bottom: 3px solid var(--rainbow-4);
    font-weight: 500;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Time slots and calendar */
.time-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1rem;
    height: 75vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--rainbow-4) transparent;
}

.time-container::-webkit-scrollbar {
    width: 6px;
}

.time-container::-webkit-scrollbar-track {
    background: transparent;
}

.time-container::-webkit-scrollbar-thumb {
    background-color: var(--rainbow-4);
    border-radius: 6px;
}

.time-header {
    display: flex;
    padding: 0.5rem 0;
    font-weight: 500;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background-color: var(--bg-light);
    z-index: 10;
}

body.dark-mode .time-header {
    border-color: var(--border-dark);
    background-color: var(--bg-dark);
}

.time-slot {
    display: flex;
    height: 60px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

body.dark-mode .time-slot {
    border-color: var(--border-dark);
}

.time-label {
    width: 60px;
    font-size: 0.8rem;
    color: #6c757d;
    text-align: center;
    padding-top: 0.25rem;
}

.time-content {
    flex: 1;
    position: relative;
    padding-left: 0.5rem;
}

.time-block {
    position: absolute;
    width: calc(100% - 8px); /* Will be overridden for overlapping blocks */
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer; /* Changed from grab to pointer for easier editing */
    color: white;
    font-size: 0.9rem;
    overflow: hidden;
    transition: box-shadow 0.2s;
    margin-left: 4px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    left: 0; /* Default, will be adjusted for overlapping blocks */
}

.time-block:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.drag-handle {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 10px;
    opacity: 0.7;
    cursor: grab;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background-color 0.2s, opacity 0.2s;
    z-index: 10; /* Ensure it's on top for touch devices */
}

.drag-handle:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.2);
}

.time-block.dragging {
    opacity: 0.8;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.time-block.dragging .drag-handle {
    cursor: grabbing;
}

body.dark-mode .time-block.dragging {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

/* New resize corner handle */
.resize-corner {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: se-resize;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 6px 0;
    z-index: 5;
}

/* Modified resize handle */
.time-block .resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 15px; /* Make room for corner handle */
    height: 8px;
    cursor: ns-resize;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0 0 0 6px;
}

.time-block:hover .resize-handle,
.time-block:hover .resize-corner {
    background-color: rgba(255, 255, 255, 0.4);
}

.time-block .block-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 15px; /* Space for the drag indicator */
}

.time-block .block-category {
    font-size: 0.75rem;
    opacity: 0.9;
}

.task-block {
    background-color: var(--task-color);
}

.meeting-block {
    background-color: var(--meeting-color);
}

.personal-block {
    background-color: var(--personal-color);
}

.unassigned-block {
    background-color: var(--unassigned-color);
}

/* Current time indicator */
.current-time-indicator {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #ff595e;
    z-index: 50;
    pointer-events: none;
}

.current-time-indicator::before {
    content: '';
    position: absolute;
    left: 0;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ff595e;
}

.current-time-label {
    position: absolute;
    left: 12px;
    top: -10px;
    background-color: #ff595e;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Make sure it works in both light and dark mode */
body.dark-mode .current-time-indicator,
body.dark-mode .current-time-indicator::before,
body.dark-mode .current-time-label {
    background-color: #ff595e;
    color: white;
}

/* Inbox */
.inbox-container {
    background-color: #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

body.dark-mode .inbox-container {
    background-color: #343a40;
}

.inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.inbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 5px;
}

.inbox-list::-webkit-scrollbar {
    width: 6px;
}

.inbox-list::-webkit-scrollbar-track {
    background: transparent;
}

.inbox-list::-webkit-scrollbar-thumb {
    background-color: var(--rainbow-4);
    border-radius: 6px;
}

.inbox-item {
    background-color: white;
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: var(--shadow-light);
    transition: transform 0.2s, box-shadow 0.2s;
}

body.dark-mode .inbox-item {
    background-color: #495057;
    box-shadow: var(--shadow-dark);
}

.inbox-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.1);
}

body.dark-mode .inbox-item:hover {
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
}

/* Forms */
.add-block-form {
    margin-top: 1rem;
    background-color: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-light);
}

body.dark-mode .add-block-form {
    background-color: #343a40;
    box-shadow: var(--shadow-dark);
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    background-color: white;
    color: var(--text-light);
}

body.dark-mode input, 
body.dark-mode select, 
body.dark-mode textarea {
    background-color: #495057;
    color: var(--text-dark);
    border-color: var(--border-dark);
}

/* Improved select styling */
select {
    appearance: menulist;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
}

body.dark-mode select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* Fixed checkbox layout */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-container input[type="checkbox"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.checkbox-container label {
    margin: 0;
    font-weight: normal;
    display: inline;
}

.btn {
    background-color: var(--rainbow-4);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s, opacity 0.2s;
}

.btn:hover {
    background-color: #1567a2;
}

.btn-success {
    background-color: var(--rainbow-3);
}

.btn-success:hover {
    background-color: #72a821;
}

.btn-danger {
    background-color: var(--rainbow-1);
}

.btn-danger:hover {
    background-color: #e02e34;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Task subtasks */
.subtasks {
    margin-top: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 5px;
}

.subtasks::-webkit-scrollbar {
    width: 4px;
}

.subtasks::-webkit-scrollbar-track {
    background: transparent;
}

.subtasks::-webkit-scrollbar-thumb {
    background-color: var(--rainbow-4);
    border-radius: 4px;
}

.subtask {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.subtask-checkbox {
    width: auto !important;
    margin: 0;
    flex-shrink: 0;
}

.subtask-text {
    flex: 1;
}

/* Custom Categories */
.category-tag {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: white;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

.categories-container {
    margin-top: 1rem;
    max-height: 70vh;
    overflow-y: auto;
}

.category-item {
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 1rem;
    border-radius: 8px;
    background-color: white;
    margin-bottom: 1rem;
}

body.dark-mode .category-item {
    background-color: #343a40;
}

.category-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

body.dark-mode .category-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.category-actions {
    display: flex;
    gap: 0.5rem;
}

.edit-category, .delete-category {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Media Queries */
@media (max-width: 768px) {
    .time-label {
        width: 40px;
        font-size: 0.7rem;
    }
    
    .time-block {
        font-size: 0.8rem;
        padding: 0.4rem;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
        max-height: 90vh;
    }
    
    .button-group {
        flex-wrap: wrap;
    }
    
    .button-group .btn {
        flex: 1 0 auto;
        min-width: 90px;
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body.dark-mode .modal-content {
    background-color: #343a40;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    background-color: white;
    padding-top: 0.5rem;
    z-index: 10;
}

body.dark-mode .modal-header {
    background-color: #343a40;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background-color: white;
    padding: 15px 0;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: -15px;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

body.dark-mode .button-group {
    background-color: #343a40;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.3);
}

/* Category Colors */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
}

.color-option.selected {
    border-color: black;
}

body.dark-mode .color-option.selected {
    border-color: white;
}

/* Category Edit Modal */
#edit-category-modal .color-picker {
    margin-bottom: 1rem;
}

/* Additional fun UI elements */
.rainbow-border {
    position: relative;
    border-radius: 12px;
    padding: 3px;
    overflow: hidden;
}

.rainbow-border::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    z-index: -1;
    background: linear-gradient(
        to right,
        var(--rainbow-1),
        var(--rainbow-2),
        var(--rainbow-3),
        var(--rainbow-4),
        var(--rainbow-5),
        var(--rainbow-1)
    );
    background-size: 400% 400%;
    animation: rainbow 5s linear infinite;
    border-radius: 12px;
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--rainbow-4);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

body.dark-mode .loading {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--rainbow-4);
}

/* Duration slider */
.duration-slider-container {
    padding: 0 10px;
    margin-top: 15px;
}

.duration-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    margin: 10px 0;
}

.duration-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--rainbow-4);
    cursor: pointer;
    border: none;
}

.duration-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--rainbow-4);
    cursor: pointer;
    border: none;
}

body.dark-mode .duration-slider {
    background: #555;
}

.duration-value {
    display: inline-block;
    background-color: var(--rainbow-4);
    color: white;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
    margin-left: 5px;
}

/* Description textarea */
.description-container {
    position: relative;
}

textarea.description-input {
    max-height: 150px;
    min-height: 80px;
    resize: vertical;
}

/* Delete button styling */
#delete-block {
    opacity: 0.9;
    transition: opacity 0.2s;
}

#delete-block:hover {
    opacity: 1;
}

/* Dark theme adjustments for feature cards in landing page */
.feature-card.dark-mode {
    background-color: var(--card-dark);
    color: var(--text-dark);
}

.feature-card.dark-mode h3 {
    color: var(--text-dark);
}

.feature-card.dark-mode p {
    color: #b0b5ba;
}

/* Dark mode for screenshots */
.screenshots.dark-theme {
    background-color: var(--bg-dark);
}

.screenshot.dark-mode {
    background-color: var(--card-dark);
}

/* Ensure footer is properly styled in dark mode */
.footer.dark-mode {
    background-color: #1a1d20;
}

.footer.dark-mode .footer-bottom {
    border-color: #333;
}