/**
 * Feed Calendar Styles
 * Mobile-first responsive design
 */

/* Calendar Header Row (desktop) */
.calendar-header {
    display: flex;
}

.calendar-header-day {
    flex: 1;
    text-align: center;
    font-weight: 600;
    padding: 0.2rem;
    font-size: 0.85rem;
    background: var(--bs-light);
    border: 1px solid var(--bs-border-color);
    border-bottom: 2px solid var(--bs-primary);
}

/* Week Row */
.calendar-week {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

/* Day Cell - auto height based on content */
.calendar-day {
    flex: 0 0 100%;
    border: 1px solid var(--bs-border-color);
    padding: 0.5rem;
    position: relative;
    background: #fff;
    margin-bottom: 0.25rem;
}

/* Tablet: 2 columns */
@media (min-width: 576px) {
    .calendar-day {
        flex: 0 0 50%;
        margin-bottom: 0;
    }
}

/* Desktop: 7 columns (full week) */
@media (min-width: 992px) {
    .calendar-day {
        flex: 0 0 calc(100% / 7);
        padding: 0.25rem;
    }

    .calendar-week {
        margin-bottom: 0;
    }
}

/* Day Header - Date Row */
.day-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 600;
    padding: 0.1rem;
    margin: -0.5rem -0.5rem 0.25rem -0.5rem;
    background: #e0e0e0;
    border-bottom: 1px solid var(--bs-border-color);
}

/* Mobile/Tablet: show day name and short date, hide desktop date */
.day-name {
    font-size: 0.75rem;
    font-weight: 700;
    display: inline;
}

.day-date-mobile {
    font-size: 0.75rem;
    display: inline;
}

.day-date-desktop {
    font-size: 0.75rem;
    display: none;
}

/* Desktop (992px+): hide day name and mobile date, show desktop date, tighter layout */
@media screen and (min-width: 992px) {
    .day-header {
        padding: 0.05rem !important;
        margin: -0.25rem -0.25rem 0.15rem -0.25rem !important;
    }
    .day-header .day-name {
        display: none !important;
    }
    .day-header .day-date-mobile {
        display: none !important;
    }
    .day-header .day-date-desktop {
        display: inline !important;
    }
    .day-entries {
        min-height: 5.5rem;
    }
}

/* Current week date row - darker cyan */
.calendar-week.current-week .day-header {
    background: #a3d9d1;
}

/* Today date row - darker red */
.calendar-day.today .day-header {
    background: #e8a9a4;
}

/* Current Week Highlight - Light Cyan 3 */
.calendar-week.current-week .calendar-day {
    background-color: #caede8;
    border-color: #9dd5cc;
}

/* Today Highlight - Light Red */
.calendar-day.today {
    background-color: #f4c7c3;
    border-color: #e09d97;
    border-width: 2px;
}

.calendar-day.today .day-header {
    color: #c0392b;
    font-weight: 700;
}

/* Past Week Styling */
.calendar-week.past-week {
    opacity: 0.7;
}

.calendar-week.past-week .calendar-day {
    background-color: var(--bs-light);
}

/* Day Entries Container */
.day-entries {
    min-height: 4rem; /* ~5 lines minimum */
    padding-bottom: 0.25rem;
}

/* Entry Cards */
.entry-card {
    background: var(--bs-light);
    border: 1px solid var(--bs-border-color);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
    color: #1a1a1a;
    font-weight: 500;
    position: relative;
    cursor: grab;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

/* Entry cards in current week - match cyan background */
.calendar-week.current-week .entry-card {
    background: #b8e4dd;
    border-color: #9dd5cc;
}

/* Entry cards on today - match light red background */
.calendar-day.today .entry-card {
    background: #edb3ae;
    border-color: #e09d97;
}

.entry-card:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.entry-card:active {
    cursor: grabbing;
}

/* Entry Content - preserve formatting */
.entry-content {
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: transparent;
    border: none;
    line-height: 1.4;
}

/* Entry Actions (edit/delete buttons) */
.entry-actions {
    display: none;
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    gap: 0.25rem;
}

.entry-card:hover .entry-actions {
    display: flex;
}

.entry-actions .btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
    line-height: 1;
}

/* Add Entry Button */
.btn-add-entry {
    position: absolute;
    bottom: 0.2rem;
    right: 0.2rem;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.calendar-day:hover .btn-add-entry {
    opacity: 1;
}

/* Sortable.js Drag States */
.entry-card.sortable-ghost {
    opacity: 0.4;
    background: var(--bs-primary-bg-subtle);
}

.entry-card.sortable-drag {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: rotate(2deg);
}

.entry-card.sortable-chosen {
    background: #fff;
}

/* Drop zone highlight */
.day-entries.sortable-drag-over {
    background: rgba(var(--bs-primary-rgb), 0.05);
    border-radius: 4px;
}

/* Mobile-specific styles */
@media (max-width: 575px) {
    .entry-card {
        padding: 0.5rem;
    }

    /* Always show actions on mobile (no hover) */
    .entry-actions {
        display: flex;
        position: static;
        margin-top: 0.5rem;
        justify-content: flex-end;
    }

    .entry-actions .btn {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }

    .btn-add-entry {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1.1rem;
        opacity: 1;
    }
}

/* Touch device enhancements */
@media (hover: none) and (pointer: coarse) {
    .entry-card {
        padding: 0.6rem;
    }

    .entry-actions {
        display: flex;
        position: static;
        margin-top: 0.5rem;
        justify-content: flex-end;
    }

    .btn-add-entry {
        opacity: 1;
    }
}

/* Modal Textarea */
#entry_content {
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

/* Refresh Indicator */
#refresh-indicator {
    opacity: 0.7;
}

#last-refresh {
    margin-left: 1rem;
}

/* Navigation buttons */
#prevWeeks, #nextWeeks {
    min-width: auto;
    padding: 0.25rem 0.5rem;
}

#goToday {
    min-width: auto;
    padding: 0.25rem 0.75rem;
}

/* Print styles */
@media print {
    .btn-add-entry,
    .entry-actions,
    #refresh-indicator,
    .modal {
        display: none !important;
    }

    .calendar-day {
        break-inside: avoid;
    }

    .calendar-week.past-week {
        opacity: 1;
    }
}
