/* ==========================================================================
   📅 NurseTurbo — Premium iOS-Style Calendar CSS  (v2)
   Apple Calendar-inspired: Year / Month / Day + Timeline views
   ========================================================================== */

/* ── Color tokens ────────────────────────────────────────────────────────── */
:root {
    --cal-confirmed: #14b8a6;
    --cal-pending:   #f59e0b;
    --cal-cancelled: #ef4444;
    --cal-today-bg:  var(--primary, #004c4c);
    --cal-bg:        #ffffff;
    --cal-surface:   #f8fafc;
    --cal-text:      #0f172a;
    --cal-muted:     #94a3b8;
    --cal-border:    #f1f5f9;
    --cal-line:      #e2e8f0;
    --cal-skeleton-from: #f1f5f9;
    --cal-skeleton-to:   #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --cal-bg:      #0f172a;
        --cal-surface: #1e293b;
        --cal-text:    #f8fafc;
        --cal-muted:   #475569;
        --cal-border:  #1e293b;
        --cal-line:    #1e293b;
        --cal-skeleton-from: #1e293b;
        --cal-skeleton-to:   #334155;
    }
}

/* ── Root container ──────────────────────────────────────────────────────── */
.calendar-view-container {
    background-color: var(--cal-bg);
    color: var(--cal-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* ── Skeleton loading shimmer ────────────────────────────────────────────── */
.calendar-skeleton-line {
    background: linear-gradient(
        90deg,
        var(--cal-skeleton-from) 25%,
        var(--cal-skeleton-to)   50%,
        var(--cal-skeleton-from) 75%
    );
    background-size: 200% 100%;
    animation: calSkeletonShimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes calSkeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── View transition animations ─────────────────────────────────────────── */
@keyframes calSlideLeftOut  { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }
@keyframes calSlideLeftIn   { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes calSlideRightOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes calSlideRightIn  { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes calScaleUp       { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes calScaleDown     { from { transform: scale(1.04); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes calSlideUp       { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes calFadeIn        { from { opacity: 0; } to { opacity: 1; } }

.animate-slide-left-out  { animation: calSlideLeftOut  0.22s cubic-bezier(0.4,0,1,1) forwards; }
.animate-slide-left-in   { animation: calSlideLeftIn   0.28s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-slide-right-out { animation: calSlideRightOut 0.22s cubic-bezier(0.4,0,1,1) forwards; }
.animate-slide-right-in  { animation: calSlideRightIn  0.28s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-scale-up        { animation: calScaleUp   0.32s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-scale-down      { animation: calScaleDown 0.32s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-slide-up        { animation: calSlideUp   0.30s cubic-bezier(0.16,1,0.3,1) forwards; }
.animate-fade-in-quick   { animation: calFadeIn    0.20s ease-out forwards; }

/* ==========================================================================
   YEAR VIEW — Mini month grids
   ========================================================================== */

.mini-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.mini-weekday {
    font-size: 7px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--cal-muted);
    text-align: center;
    line-height: 14px;
    letter-spacing: 0.02em;
}

.mini-day-cell {
    font-size: 8px;
    font-weight: 500;
    color: var(--cal-text);
    text-align: center;
    line-height: 14px;
    border-radius: 50%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-today {
    background-color: var(--cal-today-bg);
    color: #ffffff !important;
    font-weight: 800;
    border-radius: 50%;
}

.mini-has-events {
    font-weight: 800;
    color: var(--cal-today-bg);
}

/* ==========================================================================
   MONTH VIEW — Day cell grid + event chips
   ========================================================================== */

.month-day-cell {
    min-height: 64px;
    min-width: 0;
    overflow: hidden;
    padding-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.month-day-cell:active {
    background-color: var(--cal-border);
}

/* Day number styles */
.month-day-num {
    font-size: 14px;
    font-weight: 600;
    color: #004c4c;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    line-height: 1;
}

.month-day-today {
    background-color: var(--cal-today-bg) !important;
    color: #ffffff !important;
    font-weight: 800;
}

.month-day-selected {
    border: 2px solid var(--cal-today-bg);
    color: var(--cal-today-bg);
    font-weight: 700;
}

/* Event chips inside month cells */
.event-chip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.event-chip-more {
    font-size: 9px;
    font-weight: 800;
    color: var(--cal-muted);
    text-align: left;
    line-height: 14px;
    padding-left: 2px;
}

/* ==========================================================================
   DAY VIEW — Week strip
   ========================================================================== */

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 8px 4px 10px;
    flex-shrink: 0;
}

.week-day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}

.week-day-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--cal-muted);
    letter-spacing: 0.04em;
    line-height: 1;
}

.week-day-num {
    font-size: 16px;
    font-weight: 600;
    color: var(--cal-text);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}

/* Today but not selected */
.week-today {
    color: var(--cal-today-bg);
    font-weight: 800;
}

/* Selected day (not today) */
.week-selected {
    background-color: var(--cal-today-bg);
    color: #ffffff !important;
    font-weight: 800;
}

/* Today AND selected */
.week-today-selected {
    background-color: var(--cal-today-bg);
    color: #ffffff !important;
    font-weight: 800;
}

/* ==========================================================================
   DAY VIEW — Hourly timeline
   ========================================================================== */

.timeline-grid-outer {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    padding-bottom: 120px; /* Safe scroll buffer so bottom hours are never cut off by mobile nav bars */
}

/* Remove scrollbar from timeline */
.timeline-grid-outer::-webkit-scrollbar { display: none; }
.timeline-grid-outer { scrollbar-width: none; }

.timeline-grid-inner {
    position: relative;
    width: 100%;
}

/* Each 1-hour row */
.timeline-hour-row {
    display: flex;
    align-items: flex-start;
    position: relative;
    width: 100%;
}

.timeline-hour-label {
    width: 52px;
    padding-right: 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: var(--cal-muted);
    flex-shrink: 0;
    padding-top: 2px;
    line-height: 1;
}

.timeline-hour-line {
    flex: 1;
    height: 1px;
    background-color: var(--cal-line);
    margin-top: 7px;
}

/* Events column — overlaid absolutely */
.timeline-events-col {
    position: absolute;
    top: 0;
    left: 52px;        /* align with right of time labels */
    right: 12px;
}

/* Individual event block */
.timeline-event {
    position: absolute;
    left: 0;
    right: 0;
    border-left-width: 3px;
    border-left-style: solid;
    border-radius: 6px;
    padding: 4px 6px;
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.timeline-event:active {
    opacity: 0.75;
    transform: scale(0.98);
}

.timeline-event-title {
    display: block;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-event-time {
    display: block;
    font-size: 10px;
    font-weight: 600;
    opacity: 0.8;
    line-height: 1.2;
    margin-top: 1px;
}

.timeline-event-hospital {
    display: block;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Current time "now" indicator */
.timeline-now-line {
    position: absolute;
    left: 44px;   /* slightly left of events column to show the dot */
    right: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 10;
    transform: translateY(-50%);
}

.timeline-now-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--cal-today-bg);
    flex-shrink: 0;
    margin-right: 0;
}

.timeline-now-bar {
    flex: 1;
    height: 2px;
    background-color: var(--cal-today-bg);
}
