/* filepath: c:\Users\user\Downloads\AfterTimeWebPage\assets\css\calendar.css */
/* Calendar Styles */
.calendar-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    max-width: 2000px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.calendar-wrapper {
    flex: 1;
    min-width: 320px;
    background: var(--panel-bg, #1f2130);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    padding: 1.5rem;
    border: 1px solid rgba(255,255,255,0.08);
}

.calendar-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.calendar-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

.nav-button {
    background: rgba(108, 92, 231, 0.2);
    color: var(--text-primary, #e2e6f0);
    border: 1px solid rgba(108, 92, 231, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-button:hover {
    background: rgba(108, 92, 231, 0.4);
    transform: scale(1.05);
}

#month-year {
    margin: 0 1rem;
    min-width: 180px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: auto;
    gap: 6px;
    width: 100%;
}

.weekday-header {
    text-align: center;
    font-weight: 600;
    padding: 0.5rem 0;
    color: var(--text-dim, #9aa2b4);
    font-size: 0.9rem;
}

.calendar-day {
    aspect-ratio: 1/1; /* Create square cells */
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 40px;
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.calendar-day.selected {
    background: rgba(108, 92, 231, 0.3);
    border: 2px solid #6c5ce7;
}

.calendar-day.today {
    background: rgba(108, 92, 231, 0.15);
}

.calendar-day.other-month {
    opacity: 0.4;
}

.day-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.day-number {
    font-size: 0.9rem;
    font-weight: 500;
}

.event-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c5ce7;
    display: inline-block;
    margin-right: 3px;
}

.events-count {
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-size: 0.7rem;
    background: rgba(108, 92, 231, 0.7);
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 18px;
    text-align: center;
}

/* Task Panel */
.task-panel {
    flex: 1;
    min-width: 750px; /* reverted */
    background: var(--panel-bg, #1f2130);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    padding: 1.5rem;
    border: 1px solid rgba(255,255,255,0.08);
    max-height: 2000px; /* reverted */
    display: flex;
    flex-direction: column;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.task-button {
    background: linear-gradient(135deg, #6c5ce7, #8e44ad);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.task-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

.tasks-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
}

.tasks-container::-webkit-scrollbar {
    width: 6px;
}

.tasks-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.tasks-container::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.5);
    border-radius: 10px;
}

.task-item {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #6c5ce7;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.task-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(3px);
}

.task-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.task-title {
    font-weight: 600;
    color: var(--text-primary, #e2e6f0);
}

.task-time {
    color: var(--text-dim, #9aa2b4);
    font-size: 0.85rem;
}

.task-description {
    color: var(--text-dim, #9aa2b4);
    font-size: 0.9rem;
    line-height: 1.4;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.task-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    color: var(--text-dim, #9aa2b4);
    transition: all 0.2s ease;
}

.task-action-btn:hover {
    color: var(--text-primary, #e2e6f0);
}

.task-action-btn.edit-btn:hover {
    color: #6c5ce7;
}

.task-action-btn.delete-btn:hover {
    color: #e74c3c;
}

.no-tasks-message {
    color: var(--text-dim, #9aa2b4);
    text-align: center;
    padding: 2rem 0;
    font-style: italic;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.modal-content {
    background: var(--panel-bg, #1f2130);
    margin: 10% auto;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: modalFadeIn 0.3s ease;
}

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

.close-modal {
    color: var(--text-dim, #9aa2b4);
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-modal:hover {
    color: var(--text-primary, #e2e6f0);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary, #e2e6f0);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #e2e6f0);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6c5ce7;
    box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.3);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.save-button,
.cancel-button {
    padding: 0.75rem 1.5rem;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-button {
    background: linear-gradient(135deg, #6c5ce7, #8e44ad);
    color: white;
    border: none;
}

.save-button:hover {
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
    transform: translateY(-2px);
}

.cancel-button {
    background: transparent;
    color: var(--text-dim, #9aa2b4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cancel-button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #e2e6f0);
}

/* Time slot styles */
.time-slots-container {
    margin-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
}

.time-slot {
    background: rgba(108, 92, 231, 0.3);
    border-left: 3px solid #6c5ce7;
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-primary, #e2e6f0);
    overflow: hidden;
    position: relative;
}

.time-slot-time {
    font-size: 0.75rem;
    color: var(--text-dim, #9aa2b4);
    margin-bottom: 0.25rem;
    display: block;
}

.time-slot-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Daily view for time slots */
.daily-schedule {
    display: flex;
    flex-direction: column;
    min-height: 1200px;
    flex: 1; /* Added to make it grow and fill available space */
    min-width: 0; /* Critical for flex containers to allow children to shrink below content size */
    width: 100%; /* Ensure it takes full width of its container */
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative; /* added so scheduled-event absolute positioning anchors here */
}

.hour-slot {
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0 0.5rem;
    position: relative;
}

.hour-label {
    position: absolute;
    left: 0.5rem;
    top: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-dim, #9aa2b4);
    opacity: 0.7;
}

.scheduled-event {
    position: absolute;
    left: 3rem; /* reverted from 0.75rem */
    right: 0.5rem; /* reverted */
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #6c5ce7, #8e44ad);
    color: white;
    font-size: 0.8rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
    display: flex;
    flex-direction: column;
    min-height: 2.5em; /* Ensure minimum height for content */
}

.scheduled-event:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.scheduled-event-title {
    font-weight: 600;
    white-space: normal; /* Allow text to wrap */
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Show maximum of 2 lines */
    -webkit-box-orient: vertical;
}

.scheduled-event-time {
    font-size: 0.7rem;
    opacity: 0.8;
}

/* Schedule Management Styles */
.schedule-manage-wrapper {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.schedule-manage-wrapper .daily-schedule {
    flex: 1;
}

.manage-column {
    width: 230px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.manage-header {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e2e6f0);
}

.manage-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem 0.4rem 0.6rem;
    font-size: 0.75rem;
}

.manage-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid #6c5ce7;
    border-radius: 6px;
    padding: 0.45rem 0.5rem 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.manage-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.manage-item-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary, #e2e6f0);
    line-height: 1.1;
}

.manage-item-time {
    font-size: 0.65rem;
    color: var(--text-dim, #9aa2b4);
}

.manage-item-actions {
    display: flex;
    gap: 0.25rem;
}

.manage-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cfd3dc;
    font-size: 0.6rem;
    padding: 0.25rem 0.35rem;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: 0.15s;
    text-align: center;
}

.manage-btn:hover {
    background: #6c5ce7;
    color: #fff;
    border-color: #6c5ce7;
}

.manage-btn.delete {
    background: rgba(231, 76, 60, 0.15);
    border-color: rgba(231, 76, 60, 0.4);
}

.manage-btn.delete:hover {
    background: #e74c3c;
    border-color: #e74c3c;
}

.manage-empty {
    text-align: center;
    opacity: 0.6;
    padding: 0.75rem 0.4rem;
    font-style: italic;
}

/* Multi-day selector styles */
.multi-day-selector {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    margin-top: 10px;
}

.multi-day-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

#multi-month-year {
    font-weight: 500;
    font-size: 1rem;
}

.mini-nav-button {
    background: rgba(108, 92, 231, 0.2);
    color: var(--text-primary, #e2e6f0);
    border: 1px solid rgba(108, 92, 231, 0.5);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-nav-button:hover {
    background: rgba(108, 92, 231, 0.4);
    transform: scale(1.05);
}

.multi-day-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 15px;
}

.mini-weekday-header {
    text-align: center;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-dim, #9aa2b4);
    padding: 5px 0;
}

.mini-day {
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.mini-day:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mini-day.selected {
    background: rgba(108, 92, 231, 0.3);
    border: 1px solid #6c5ce7;
}

.mini-day.other-month {
    opacity: 0.4;
}

.multi-day-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mini-action-button {
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: var(--text-primary, #e2e6f0);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-action-button:hover {
    background: rgba(108, 92, 231, 0.3);
}

.selected-dates-count {
    text-align: center;
    font-size: 0.8rem;
    margin-top: 10px;
    color: var(--text-dim, #9aa2b4);
}

.selected-dates-count span {
    font-weight: 600;
    color: #6c5ce7;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* Safety: hide legacy tasks container if present */
    #tasks-container {
        display: none !important;
    }

    .calendar-container {
        flex-direction: column;
        gap: 1rem;
        margin: 1rem auto;
    }

    .calendar-wrapper {
        min-width: 100%;
        padding: 1rem;
    }

    .task-panel {
        min-width: 100%;
        max-height: none;
        padding: 1rem;
    }

    .task-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .task-header div {
        width: 100%;
        justify-content: space-between;
    }

    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 1.5rem;
    }

    .calendar-day {
        min-height: 30px;
    }

    /* Improve touch targets */
    .nav-button, .task-button, .save-button, .cancel-button {
        min-height: 44px;
        min-width: 44px;
    }

    .form-group input, .form-group textarea {
        padding: 1rem 0.75rem;
    }

    /* Calendar day improvements for touch */
    .day-content {
        padding: 0.4rem;
    }

    /* Fix timeslot layout for mobile */
    .daily-schedule {
        min-height: 1000px;
    }

    /* More aggressive fix for scheduled events on mobile */
    .scheduled-event {
        left: 2.5rem !important; /* keep horizontal adjustment */
        right: 5px !important;
        padding: 0.55rem !important;
        min-height: 2.5rem !important; /* ensure visibility for very short events */
        /* Removed height:auto override so inline percentage height reflects multi-hour duration */
    }

    /* Force proper sizing for extremely short events */
    .scheduled-event[style*="height:0"],
    .scheduled-event[style*="height: 0"],
    .scheduled-event[style*="height:1"],
    .scheduled-event[style*="height: 1"],
    .scheduled-event[style*="height:2"],
    .scheduled-event[style*="height: 2"],
    .scheduled-event[style*="height:3"],
    .scheduled-event[style*="height: 3"] {
        min-height: 2.5rem !important;
        max-height: none !important;
    }

    /* Force title to always be visible */
    .scheduled-event-title {
        white-space: normal !important; /* Allow text to wrap */
        margin-bottom: 0.25rem !important;
        line-height: 1.2 !important;
        font-size: 0.75rem !important;
    }

    /* Improve hour label visibility */
    .hour-label {
        font-size: 0.65rem !important;
        width: 2.2rem !important;
        text-align: center !important;
        background-color: rgba(0,0,0,0.2) !important; /* Add background for better readability */
        border-radius: 3px !important;
        padding: 1px 3px !important;
    }

    /* Handle the delete button position */
    .scheduled-event-delete {
        top: 2px !important;
        right: 2px !important;
        font-size: 1.2rem !important;
    }
}

@media (max-width: 480px) {
    .calendar-grid {
        gap: 3px;
    }

    .weekday-header {
        font-size: 0.8rem;
        padding: 0.3rem 0;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .nav-button {
        width: 36px;
        height: 36px;
    }

    #month-year {
        min-width: 140px;
        font-size: 0.9rem;
    }

    /* Further improve scheduled event display on very small screens */
    .scheduled-event {
        left: 1.8rem !important;
        padding: 0.15rem 0.25rem 0.25rem !important;
    }

    .hour-label {
        font-size: 0.6rem !important;
        width: 1.6rem !important;
    }

    .scheduled-event-title {
        font-size: 0.7rem !important;
        margin-bottom: 0.1rem !important;
    }

    .scheduled-event-time {
        font-size: 0.65rem !important;
    }

    /* Optimize multi-day selector for small screens */
    .multi-day-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .mini-day {
        font-size: 0.7rem;
    }
}

@media (max-width: 1100px) {
    .schedule-manage-wrapper {
        flex-direction: column;
    }

    .manage-column {
        width: 100%;
        order: -1;
    }
}

.task-button, .today-button {
    padding: 0.5rem 0.75rem;
    background: var(--accent-color, #0ff);
    color: var(--dark-bg, #121320);
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.task-button:hover, .today-button:hover {
    background: var(--accent-hover, #00d1d1);
    box-shadow: 0 0 8px var(--accent-color, #0ff);
}

.task-button:disabled {
    background: #454963;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
}

.today-button-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.today-button {
    min-width: 120px;
}