/**
 * Modern Appointment Calendar Styling
 * Enhanced visual design with gradients, animations, and modern UI patterns
 */

/* Main Calendar Container */
.appointment-calendar {
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 4px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.appointment-calendar:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Calendar Inner Container */
.fc {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Header Styling */
.fc-header-toolbar {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 20px 24px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 0 !important;
    position: relative;
    z-index: 2;
}

.fc-toolbar-title {
    font-size: 28px !important;
    font-weight: 700 !important;
    color: #1e293b;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation Buttons */
.fc-button {
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 12px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    transition: all 0.2s ease !important;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 1 !important;
}

.fc-button-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3) !important;
}

.fc-button-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4) !important;
}

.fc-button-primary:not(:disabled):active,
.fc-button-primary:not(:disabled).fc-button-active {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%) !important;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.6) !important;
    transform: translateY(0);
}

/* Today Button Special Styling */
.fc-today-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}

.fc-today-button:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

/* View Buttons Group */
.fc-button-group {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: inline-flex;
}

.fc-button-group .fc-button {
    border-radius: 0 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
    margin: 0 !important;
}

.fc-button-group .fc-button:first-child {
    border-radius: 8px 0 0 8px !important;
}

.fc-button-group .fc-button:last-child {
    border-right: none !important;
    border-radius: 0 8px 8px 0 !important;
}

.fc-button-group .fc-button:only-child {
    border-radius: 8px !important;
}

/* Calendar Grid */
.fc-scrollgrid {
    border: none !important;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

/* Day Headers */
.fc-col-header-cell {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: none !important;
    padding: 16px 8px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
    position: relative;
}

.fc-col-header-cell::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #3b82f6, transparent);
}

/* Day Cells */
.fc-daygrid-day,
.fc-timegrid-slot {
    border-color: #f1f5f9 !important;
    transition: background-color 0.2s ease;
}

.fc-daygrid-day:hover {
    background-color: #f8fafc !important;
}

.fc-daygrid-day-number {
    color: #64748b;
    font-weight: 600;
    font-size: 14px;
    padding: 8px;
    transition: color 0.2s ease;
}

/* "Today" fill + pattern: month/week grid and time grid only — not list view rows (see .fc-list-day.fc-day-today below) */
.fc-daygrid-day.fc-day-today,
.fc-timegrid-col.fc-day-today {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%) !important;
    position: relative;
}

.fc-daygrid-day.fc-day-today::before,
.fc-timegrid-col.fc-day-today::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(59, 130, 246, 0.1) 25%, transparent 25%, transparent 75%, rgba(59, 130, 246, 0.1) 75%);
    background-size: 10px 10px;
    pointer-events: none;
}

.fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    color: #1d4ed8;
    font-weight: 800;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Event Styling */
.fc-event {
    border: none !important;
    border-radius: 8px !important;
    padding: 4px 8px !important;
    margin: 2px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.fc-event:hover {
    transform: translateY(-2px) scale(1.02);
    z-index: 10;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25) !important;
}

.fc-event-title {
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    color: inherit;
}

.fc-event-time {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 500;
    color: inherit;
}

/* Status-based Event Colors - Eye-friendly pastel tones */
.fc-event.status-confirmed {
    background: linear-gradient(135deg, #86efac 0%, #4ade80 100%) !important;
    color: #14532d !important; /* Dark green text for contrast */
    border-color: #4ade80 !important;
}

.fc-event.status-cancelled {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%) !important;
    color: #374151 !important; /* Dark gray text for contrast */
    border-color: #9ca3af !important;
}

.fc-event.status-completed {
    background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 100%) !important;
    color: #0c4a6e !important; /* Dark blue text for contrast */
    border-color: #38bdf8 !important;
}

.fc-event.status-rescheduled {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%) !important;
    color: #581c87 !important; /* Dark purple text for contrast */
    border-color: #a78bfa !important;
}

.fc-event.status-pending {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 50%, #facc15 100%) !important;
    color: #713f12 !important; /* Dark amber text for contrast */
    border-color: #facc15 !important;
}

/* Voice Call Event Styles */
.fc-call-event {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-color: #059669 !important;
    color: white !important;
    position: relative;
}

.fc-call-event:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    border-color: #047857 !important;
}

.fc-call-event .fc-event-title {
    font-weight: 500;
}

.fc-call-event .fc-event-time {
    opacity: 0.9;
}

/* Voice Call Status Specific Styles */
.fc-call-event.analyzed-call {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-left: 4px solid #064e3b !important;
}

.fc-call-event.pending-call {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border-left: 4px solid #92400e !important;
}

/* Inquiry urgency colors only on title badges — row stays green (.fc-call-event) */
.fc-call-event .fc-voice-urgency {
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.fc-call-event .fc-voice-urgency-high {
    background: #EF4444 !important;
    color: #ffffff !important;
    border: 1px solid #DC2626 !important;
}

.fc-call-event .fc-voice-urgency-medium {
    background: #FACC15 !important;
    color: #111827 !important;
    border: 1px solid #EAB308 !important;
}

.fc-call-event .fc-voice-urgency-low {
    background: #3B82F6 !important;
    color: #ffffff !important;
    border: 1px solid #2563EB !important;
}

.fc-call-event .fc-voice-urgency-no-action {
    background: #6B7280 !important;
    color: #ffffff !important;
    border: 1px solid #4B5563 !important;
}

.fc-call-event .fc-voice-urgency-default {
    background: #9CA3AF !important;
    color: #111827 !important;
    border: 1px solid #6B7280 !important;
}

/* List view: keep green row visible on hover */
.fc .fc-list-event.fc-call-event:hover td {
    background-color: transparent !important;
}

/* Call Type Indicators */
.call-type-indicator {
    font-size: 12px;
    opacity: 0.8;
}

/* Voice Call List View Enhancements */
.fc-listWeek .fc-call-event {
    border-radius: 6px !important;
    margin-bottom: 2px !important;
    padding: 8px 12px !important;
}

.fc-listWeek .fc-call-event .fc-list-event-title {
    font-weight: 600 !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fc-listWeek .fc-call-event .fc-list-event-time {
    font-weight: 500 !important;
    opacity: 0.9;
}

/* Badge Styles for Voice Calls */
.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
}

.badge-success {
    background-color: #10b981;
    color: white;
}

.badge-warning {
    background-color: #f59e0b;
    color: white;
}

.badge-info {
    background-color: #3b82f6;
    color: white;
}

.badge-secondary {
    background-color: #6b7280;
    color: white;
}

/* Dark mode event adjustments */
.dark .fc-event {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.dark .fc-event:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
}

.dark .fc-event-title {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Dark mode status colors - Adjusted for better visibility */
.dark .fc-event.status-confirmed {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%) !important;
    color: #f0fdf4 !important;
    border-color: #22c55e !important;
}

.dark .fc-event.status-cancelled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%) !important;
    color: #f9fafb !important;
    border-color: #6b7280 !important;
}

.dark .fc-event.status-completed {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%) !important;
    color: #f0f9ff !important;
    border-color: #0ea5e9 !important;
}

.dark .fc-event.status-rescheduled {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%) !important;
    color: #faf5ff !important;
    border-color: #8b5cf6 !important;
}

.dark .fc-event.status-pending {
    background: linear-gradient(135deg, #fde047 0%, #facc15 100%) !important;
    color: #713f12 !important; /* Keep dark text for readability */
    border-color: #facc15 !important;
}

/* Dark Mode Voice Call Event Styles */
.dark .fc-call-event.analyzed-call {
    background: linear-gradient(135deg, #0f766e 0%, #0d4f48 100%) !important;
    border-left-color: #042f2e !important;
}

.dark .fc-call-event.pending-call {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%) !important;
    border-left-color: #78350f !important;
}

.dark .fc-call-event:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4) !important;
}

.dark .fc-call-event .fc-event-title {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Dark Mode Badge Styles */
.dark .badge-success {
    background-color: #059669;
    color: #ecfdf5;
}

.dark .badge-warning {
    background-color: #d97706;
    color: #fffbeb;
}

.dark .badge-info {
    background-color: #2563eb;
    color: #dbeafe;
}

.dark .badge-secondary {
    background-color: #4b5563;
    color: #f9fafb;
}

/* Time Grid Styling */
.fc-timegrid-axis {
    border: none !important;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

.fc-timegrid-slot-label {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
}

.fc-timegrid-divider {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: none !important;
    height: 2px;
}

/* List View – colorful by status: distinct background + left border (easy to identify) */
.fc-list-event {
    border-left: 4px solid #3b82f6 !important;
    border-radius: 10px !important;
    margin-bottom: 10px !important;
    margin-left: 0 !important;
    margin-right: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
    transition: box-shadow 0.25s ease, transform 0.2s ease !important;
    padding: 14px 18px !important;
}

.fc-list-event td {
    padding: 14px 18px !important;
    vertical-align: middle !important;
}

/* Confirmed = bright green (saturated, not pale) */
.fc-list-event.status-confirmed {
    background: linear-gradient(135deg, #6ee7b7 0%, #34d399 50%, #22c55e 100%) !important;
    border-left-color: #059669 !important;
    color: #064e3b !important;
}

/* Pending = bright golden yellow (luminous, saturated) */
.fc-list-event.status-pending {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 50%, #facc15 100%) !important;
    border-left-color: #ca8a04 !important;
    color: #713f12 !important;
}

/* Completed = blue – done/calm */
.fc-list-event.status-completed {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%) !important;
    border-left-color: #2563eb !important;
    color: #1e3a8f !important;
}

/* Rescheduled = purple – distinct */
.fc-list-event.status-rescheduled {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%) !important;
    border-left-color: #7c3aed !important;
    color: #4c1d95 !important;
}

/* Cancelled = grey – muted */
.fc-list-event.status-cancelled {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%) !important;
    border-left-color: #64748b !important;
    color: #475569 !important;
}

.fc-list-event:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1) !important;
    transform: translateX(3px);
}

.fc-list-event.status-confirmed:hover {
    background: linear-gradient(135deg, #34d399 0%, #22c55e 100%) !important;
}

.fc-list-event.status-pending:hover {
    background: linear-gradient(135deg, #fde047 0%, #facc15 100%) !important;
}

.fc-list-event.status-completed:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%) !important;
}

.fc-list-event.status-rescheduled:hover {
    background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%) !important;
}

.fc-list-event.status-cancelled:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%) !important;
}

/* Time – readable on each background */
.fc-list-event-time {
    font-weight: 700 !important;
    font-size: 0.8125rem !important;
    min-width: 6rem;
}

.fc-list-event.status-confirmed .fc-list-event-time { color: #064e3b !important; }
.fc-list-event.status-pending .fc-list-event-time { color: #713f12 !important; }
.fc-list-event.status-completed .fc-list-event-time { color: #1e40af !important; }
.fc-list-event.status-rescheduled .fc-list-event-time { color: #5b21b6 !important; }
.fc-list-event.status-cancelled .fc-list-event-time { color: #475569 !important; }

/* Title – primary text per status */
.fc-list-event-title {
    font-weight: 600 !important;
    font-size: 0.9375rem !important;
    line-height: 1.4 !important;
}

.fc-list-event.status-confirmed .fc-list-event-title { color: #064e3b !important; }
.fc-list-event.status-pending .fc-list-event-title { color: #713f12 !important; }
.fc-list-event.status-completed .fc-list-event-title { color: #1e3a8f !important; }
.fc-list-event.status-rescheduled .fc-list-event-title { color: #4c1d95 !important; }
.fc-list-event.status-cancelled .fc-list-event-title { color: #475569 !important; }

.fc-list-event .fc-list-event-dot,
.fc-list-event .fc-list-event-graphic {
    display: none !important;
}

/* Remove the graphic column entirely (was causing thin line on left) */
.fc-list-table .fc-list-event-graphic {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
}

/* Remove thin gray line: .fc-theme-standard adds border:1px to td/th – override for list view */
.fc-theme-standard .fc-list-table td,
.fc-theme-standard .fc-list-table th {
    border-left: none !important;
}

/* Week Numbers */
.fc-daygrid-week-number {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #64748b;
    font-weight: 600;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
}

/* More Link */
.fc-daygrid-more-link {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%) !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 2px 6px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
}

.fc-daygrid-more-link:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    transform: scale(1.05);
}

/* Popover Styling (month “+N more” list: show ~3 rows, scroll the rest) */
.fc-popover {
    --fc-popover-rows-visible: 3;
    /* One stacked block event row: padding, margin, 12px text — tune if row height changes */
    --fc-popover-row-h: 2.85rem;
    --fc-popover-body-pad-b: 0.65rem;
    border: none !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
    background: white !important;
    backdrop-filter: blur(10px);
    max-width: min(22rem, calc(100vw - 1.5rem)) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    /* Sit above the next calendar row / card edge when parent uses overflow: visible */
    z-index: 100 !important;
}

.fc-popover-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 12px 16px !important;
    border-radius: 12px 12px 0 0 !important;
    flex-shrink: 0 !important;
}

.fc-popover-title {
    color: #1e293b !important;
    font-weight: 700 !important;
}

.fc-popover .fc-popover-body {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    /* Extra --fc-popover-body-pad-b avoids the last row looking “sliced” at the scroll cut */
    max-height: min(
        calc(
            var(--fc-popover-rows-visible) * var(--fc-popover-row-h) +
            var(--fc-popover-body-pad-b)
        ),
        50vh
    ) !important;
    /* Horizontal + bottom inset so the last pill is not flush against the scrollport edge (box-sizing keeps 3 full rows) */
    padding: 0 0.45rem var(--fc-popover-body-pad-b) 0.5rem !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-color: rgba(71, 85, 105, 0.5) rgba(15, 23, 42, 0.08);
}

/* Scrollbar always visible in the “more” list (esp. dark theme / overlay scrollbars) */
.fc-popover .fc-popover-body::-webkit-scrollbar {
    width: 8px;
}

.fc-popover .fc-popover-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.06);
    border-radius: 4px;
}

.fc-popover .fc-popover-body::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.45);
    border-radius: 4px;
}

.fc-popover .fc-popover-body::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 0.65);
}

/*
 * “+N more” popover: FullCalendar (see main.js Popover#updateSize) places it next to
 * the day / link via inline top+left. Override only .fc-more-popover so the panel opens
 * centered in the viewport; !important wins over those inline values.
 */
.appointment-calendar .fc-popover.fc-more-popover {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    z-index: 10060 !important;
    min-width: min(32rem, calc(100vw - 1.5rem)) !important;
    max-width: min(38rem, calc(100vw - 1rem)) !important;
    border: 2px solid rgba(16, 185, 129, 0.55) !important;
    box-shadow:
        0 0 0 1px rgba(16, 185, 129, 0.2),
        0 25px 50px -12px rgba(0, 0, 0, 0.35),
        0 0 40px -8px rgba(16, 185, 129, 0.25) !important;
}

/* Dark backdrop effect only around the modal panel (not entire screen) */
.appointment-calendar .fc-popover.fc-more-popover::before {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.5);
    z-index: -1;
    pointer-events: none;
}

.appointment-calendar .fc-popover.fc-more-popover .fc-popover-header {
    padding: 14px 18px !important;
    border-bottom-width: 2px !important;
    border-bottom-color: rgba(16, 185, 129, 0.25) !important;
}

.appointment-calendar .fc-popover.fc-more-popover .fc-popover-title {
    font-size: 1.1rem !important;
    letter-spacing: 0.02em;
}

/* Larger scroll list; same compact rows as the month grid (phone + ref + urgency) */
.appointment-calendar .fc-popover.fc-more-popover .fc-popover-body {
    max-height: min(26rem, 62vh) !important;
    min-height: 0 !important;
    padding: 0.5rem 0.75rem 0.85rem 0.75rem !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable;
}

/* Loading State */
.fc-calendar-loading {
    position: relative;
}

.fc-calendar-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .fc-header-toolbar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .fc-toolbar-title {
        font-size: 22px !important;
    }
    
    .fc-button {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    
    .appointment-calendar {
        margin: 0 -4px;
        border-radius: 8px;
    }
}

/* Dark Mode Support */
.dark .fc {
    background: #1e293b;
    color: #f1f5f9;
}

.dark .fc-header-toolbar {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%) !important;
    border-bottom-color: #475569 !important;
    color: #f1f5f9 !important;
}

.dark .fc-header-toolbar * {
    color: #f1f5f9 !important;
}

/* Toolbar title - ensure visibility in dark mode with solid color */
.dark .fc-toolbar-title {
    color: #60a5fa !important;
    -webkit-text-fill-color: #60a5fa !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    text-shadow: 0 1px 3px rgba(96, 165, 250, 0.5) !important;
}

/* Ensure all child elements in title are visible */
.dark .fc-toolbar-title *,
.dark .fc-toolbar-title span,
.dark .fc-toolbar-title a {
    color: #60a5fa !important;
    -webkit-text-fill-color: #60a5fa !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
}

.dark .fc-toolbar-chunk {
    color: #f1f5f9 !important;
}

/* Ensure all text elements in toolbar are visible */
.dark .fc-header-toolbar button,
.dark .fc-header-toolbar .fc-button,
.dark .fc-header-toolbar span,
.dark .fc-header-toolbar div,
.dark .fc-toolbar-chunk {
    color: #f1f5f9 !important;
}

/* Fix navigation arrow buttons */
.dark .fc-button .fc-icon {
    color: #f1f5f9 !important;
}

/* Ensure button text in toolbar is visible */
.dark .fc-button-primary {
    color: white !important;
}

.dark .fc-button-primary .fc-icon {
    color: white !important;
}

/* Week/Month/Day view button labels */
.dark .fc-button-group .fc-button {
    color: #f1f5f9 !important;
}

.dark .fc-button-group .fc-button-active {
    color: white !important;
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%) !important;
}

.dark .fc-button-primary {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%) !important;
    color: white !important;
    border-color: #2563eb !important;
}

.dark .fc-button-primary:hover {
    background: linear-gradient(135deg, #2b77cb 0%, #2a4f7a 100%) !important;
    color: white !important;
    border-color: #1d4ed8 !important;
}

.dark .fc-button-primary:not(:disabled):active,
.dark .fc-button-primary:not(:disabled).fc-button-active {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    color: white !important;
    border-color: #1e3a8a !important;
}

.dark .fc-today-button {
    background: linear-gradient(135deg, #0f766e 0%, #0d4f48 100%) !important;
    color: white !important;
}

.dark .fc-today-button:hover {
    background: linear-gradient(135deg, #0e6b64 0%, #0c4440 100%) !important;
}

/* Column headers (day names) - ensure visibility in dark mode */
.dark .fc-col-header-cell {
    background: linear-gradient(135deg, #475569 0%, #334155 100%) !important;
    color: #f1f5f9 !important;
    border-color: #64748b !important;
}

.dark .fc-col-header-cell::after {
    background: linear-gradient(90deg, transparent, #60a5fa, transparent) !important;
}

/* Ensure day name text is always visible */
.dark .fc-col-header-cell-cushion {
    color: #f1f5f9 !important;
}

.dark .fc-col-header-cell-cushion a {
    color: #f1f5f9 !important;
}

.dark .fc-daygrid-day,
.dark .fc-timegrid-slot {
    border-color: #475569 !important;
    background: #1e293b;
}

/* List view container - match scrollgrid-sync-inner background in dark mode */
.dark .fc-list,
.dark .fc-listWeek,
.dark .fc-listWeek-view,
.dark .fc-list-view,
.dark .fc-scrollgrid-sync-inner {
    background: #1e293b !important;
}

/* List view table and cells - inherit dark background */
.dark .fc-list table,
.dark .fc-listWeek table,
.dark .fc-list tbody,
.dark .fc-listWeek tbody {
    background: #1e293b !important;
}

.dark .fc-daygrid-day:hover {
    background-color: #334155 !important;
}

/* Date numbers - ensure visibility and contrast in dark mode */
.dark .fc-daygrid-day-number {
    color: #e2e8f0 !important;
    font-weight: 600 !important;
}

.dark .fc-daygrid-day-number a {
    color: #e2e8f0 !important;
}

.dark .fc-daygrid-day.fc-day-today,
.dark .fc-timegrid-col.fc-day-today {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%) !important;
}

.dark .fc-daygrid-day.fc-day-today::before,
.dark .fc-timegrid-col.fc-day-today::before {
    background: linear-gradient(45deg, rgba(96, 165, 250, 0.1) 25%, transparent 25%, transparent 75%, rgba(96, 165, 250, 0.1) 75%);
}

.dark .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    color: #60a5fa;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Time grid axis (time labels) - ensure visibility */
.dark .fc-timegrid-axis {
    color: #cbd5e1 !important;
    border-color: #64748b !important;
    background: #1e293b !important;
}

.dark .fc-timegrid-axis .fc-timegrid-axis-frame {
    color: #cbd5e1 !important;
}

.dark .fc-timegrid-slot-label {
    color: #cbd5e1 !important;
    font-weight: 500 !important;
}

.dark .fc-timegrid-slot-label-cushion {
    color: #cbd5e1 !important;
}

/* Week view column headers */
.dark .fc-timegrid-col-header-cell {
    background: linear-gradient(135deg, #475569 0%, #334155 100%) !important;
    color: #f1f5f9 !important;
    border-color: #64748b !important;
}

.dark .fc-timegrid-col-header-cell-cushion {
    color: #f1f5f9 !important;
}

.dark .fc-timegrid-col-header-cell-cushion a {
    color: #f1f5f9 !important;
}

.dark .fc-timegrid-divider {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    border-color: #475569 !important;
}

/* List view events – dark: same status colors, richer tints */
.dark .fc-list-event {
    border-left: 4px solid #3b82f6 !important;
    border-radius: 10px !important;
    margin-bottom: 10px !important;
    margin-left: 6px !important;
    margin-right: 6px !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3) !important;
    transition: box-shadow 0.25s ease, transform 0.2s ease !important;
    padding: 14px 18px !important;
}

.dark .fc-list-event > *,
.dark .fc-list-event td,
.dark .fc-list-event .fc-list-event-dot,
.dark .fc-list-event .fc-list-event-graphic {
    background-color: transparent !important;
}

.dark .fc-list-event .fc-list-event-dot,
.dark .fc-list-event .fc-list-event-graphic {
    display: none !important;
}

.dark .fc-list-event.status-confirmed {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.55) 0%, rgba(34, 197, 94, 0.5) 100%) !important;
    border-left-color: #10b981 !important;
}

.dark .fc-list-event.status-pending {
    background: linear-gradient(135deg, rgba(253, 224, 71, 0.5) 0%, rgba(250, 204, 21, 0.45) 100%) !important;
    border-left-color: #facc15 !important;
}

.dark .fc-list-event.status-completed {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.35) 0%, rgba(59, 130, 246, 0.25) 100%) !important;
    border-left-color: #60a5fa !important;
}

.dark .fc-list-event.status-rescheduled {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.35) 0%, rgba(139, 92, 246, 0.25) 100%) !important;
    border-left-color: #a78bfa !important;
}

.dark .fc-list-event.status-cancelled {
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.3) 0%, rgba(148, 163, 184, 0.2) 100%) !important;
    border-left-color: #94a3b8 !important;
}

.dark .fc-list-event:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4) !important;
    transform: translateX(3px);
}

.dark .fc-list-event.status-confirmed:hover {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.65) 0%, rgba(34, 197, 94, 0.6) 100%) !important;
}

.dark .fc-list-event.status-pending:hover {
    background: linear-gradient(135deg, rgba(253, 224, 71, 0.6) 0%, rgba(250, 204, 21, 0.55) 100%) !important;
}

.dark .fc-list-event.status-completed:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.45) 0%, rgba(96, 165, 250, 0.35) 100%) !important;
}

.dark .fc-list-event.status-rescheduled:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.45) 0%, rgba(167, 139, 250, 0.35) 100%) !important;
}

.dark .fc-list-event.status-cancelled:hover {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.4) 0%, rgba(203, 213, 225, 0.3) 100%) !important;
}

.dark .fc-list-event-time {
    font-weight: 700 !important;
}

.dark .fc-list-event.status-confirmed .fc-list-event-time { color: #d1fae5 !important; }
.dark .fc-list-event.status-pending .fc-list-event-time { color: #fef9c3 !important; }
.dark .fc-list-event.status-completed .fc-list-event-time { color: #93c5fd !important; }
.dark .fc-list-event.status-rescheduled .fc-list-event-time { color: #c4b5fd !important; }
.dark .fc-list-event.status-cancelled .fc-list-event-time { color: #94a3b8 !important; }

.dark .fc-list-event-title {
    font-weight: 600 !important;
}

.dark .fc-list-event.status-confirmed .fc-list-event-title { color: #ecfdf5 !important; }
.dark .fc-list-event.status-pending .fc-list-event-title { color: #fef08a !important; }
.dark .fc-list-event.status-completed .fc-list-event-title { color: #dbeafe !important; }
.dark .fc-list-event.status-rescheduled .fc-list-event-title { color: #ede9fe !important; }
.dark .fc-list-event.status-cancelled .fc-list-event-title { color: #cbd5e1 !important; }

.dark .fc-daygrid-week-number {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    color: #94a3b8;
}

/* List View Date Headers – clear, modern (date row above each day’s events) */
/* Date row above each day's events – appointments listed under respective date */
/* Date label only – no solid block (avoids empty bar between days) */
/* Both layers: th cell + inner div (FullCalendar uses .fc-list-sticky .fc-list-day > * and .fc-theme-standard .fc-list-day-cushion) */
.fc-list-day,
.fc-list-day > th,
.fc .fc-list-sticky .fc-list-day > th,
.fc-list-day .fc-list-day-cushion {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 4px 0 6px 0 !important;
    font-weight: 600 !important;
    font-size: 0.8125rem !important;
    letter-spacing: 0.02em !important;
    color: #475569 !important;
    margin-bottom: 4px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 0 !important;
    min-height: 0 !important;
}

.fc-theme-standard .fc-list-day-cushion {
    background: transparent !important;
}

/* Force both layers off when inside appointment calendar (beats any other CSS) */
#appointment-calendar .fc-list-day > th,
#appointment-calendar .fc-list-day .fc-list-day-cushion,
#appointment-calendar .fc-theme-standard .fc-list-day-cushion,
#appointment-calendar .fc .fc-list-sticky .fc-list-day > th {
    background: transparent !important;
    min-height: 0 !important;
}

/* All list day headers: same left gutter (3px stripe; “today” only changes stripe color) */
.fc-list-day > th,
.fc .fc-list-sticky .fc-list-day > th,
#appointment-calendar .fc-list-day > th,
#appointment-calendar .fc .fc-list-sticky .fc-list-day > th {
    border-left: 3px solid transparent !important;
}
.fc-list-day .fc-list-day-cushion,
#appointment-calendar .fc-list-day .fc-list-day-cushion,
#appointment-calendar .fc-theme-standard .fc-list-day-cushion {
    padding: 4px 14px 6px 11px !important; /* 3px th stripe + 11px; matches former FC 14px text inset */
}

.fc-list-day {
    display: table-row !important;
}

.fc-list-day-text,
.fc-list-day-text a,
a.fc-list-day-text {
    font-weight: 600 !important;
    font-size: 0.9375rem !important;
    color: #1e293b !important;
}

.fc-list-day-side-text,
.fc-list-day-side-text a,
a.fc-list-day-side-text {
    font-weight: 500 !important;
    font-size: 0.8125rem !important;
    color: #64748b !important;
    margin-left: 8px !important;
}

/* List view “today”: left accent + light tint only (no daygrid background/pattern — same row height as other days) */
.fc-list-day.fc-day-today > th,
.fc .fc-list-sticky .fc-list-day.fc-day-today > th,
#appointment-calendar .fc-list-day.fc-day-today > th,
#appointment-calendar .fc .fc-list-sticky .fc-list-day.fc-day-today > th {
    border-left: 3px solid #3b82f6 !important;
    background: rgba(59, 130, 246, 0.06) !important;
}
#appointment-calendar .fc-list-day.fc-day-today .fc-list-day-cushion {
    background: transparent !important;
}
.fc-list-day.fc-day-today .fc-list-day-cushion {
    background: transparent !important;
}
.fc-list-day.fc-day-today .fc-list-day-text,
.fc-list-day.fc-day-today .fc-list-day-text a,
a.fc-list-day.fc-day-today .fc-list-day-text {
    color: #1d4ed8 !important;
    font-weight: 700 !important;
    -webkit-text-fill-color: #1d4ed8 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
}

/* List view date headers – dark mode: both layers transparent (no dark blue bar) */
.dark .fc-list-day,
.dark .fc-list-day > th,
.dark .fc .fc-list-sticky .fc-list-day > th,
.dark .fc-list-day .fc-list-day-cushion,
.dark .fc-theme-standard .fc-list-day-cushion {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #475569 !important;
    padding: 4px 0 6px 0 !important;
    min-height: 0 !important;
    margin-bottom: 4px !important;
    color: #94a3b8 !important;
}

.dark .fc-list-day-text,
.dark .fc-list-day-text a,
.dark a.fc-list-day-text {
    color: #f1f5f9 !important;
}

.dark .fc-list-day-side-text,
.dark .fc-list-day-side-text a,
.dark a.fc-list-day-side-text {
    color: #94a3b8 !important;
}

/* Dark: same left gutter and cushion padding for every date row as light mode */
.dark .fc-list-day > th,
.dark .fc .fc-list-sticky .fc-list-day > th,
.dark #appointment-calendar .fc-list-day > th,
.dark #appointment-calendar .fc .fc-list-sticky .fc-list-day > th {
    border: none !important;
    border-bottom: 1px solid #475569 !important;
    border-left: 3px solid transparent !important;
}
.dark .fc-list-day .fc-list-day-cushion,
.dark #appointment-calendar .fc-list-day .fc-list-day-cushion,
.dark .fc-theme-standard .fc-list-day-cushion {
    padding: 4px 14px 6px 11px !important;
}

/* Dark list “today”: only stripe color + row tint (shared gutter above) */
.dark .fc-list-day.fc-day-today > th,
.dark .fc .fc-list-sticky .fc-list-day.fc-day-today > th,
.dark #appointment-calendar .fc-list-day.fc-day-today > th,
.dark #appointment-calendar .fc .fc-list-sticky .fc-list-day.fc-day-today > th {
    border: none !important;
    border-bottom: 1px solid #475569 !important;
    border-left: 3px solid #60a5fa !important;
    background: rgba(30, 58, 138, 0.35) !important;
}
.dark .fc-list-day.fc-day-today .fc-list-day-cushion,
.dark #appointment-calendar .fc-list-day.fc-day-today .fc-list-day-cushion {
    background: transparent !important;
}
.dark .fc-list-day.fc-day-today .fc-list-day-text,
.dark .fc-list-day.fc-day-today .fc-list-day-text a,
.dark a.fc-list-day.fc-day-today .fc-list-day-text {
    color: #93c5fd !important;
    font-weight: 700 !important;
    -webkit-text-fill-color: #93c5fd !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
}

.dark .fc-daygrid-more-link {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%) !important;
    color: white !important;
}

.dark .fc-popover {
    background: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

.dark .fc-popover-header {
    background: linear-gradient(135deg, #475569 0%, #334155 100%) !important;
    border-bottom-color: #475569 !important;
}

.dark .fc-popover-title {
    color: #f1f5f9 !important;
}

.dark .fc-popover .fc-popover-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.4);
}

.dark .fc-popover .fc-popover-body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
}

.dark .fc-popover .fc-popover-body::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 213, 225, 0.55);
}

.dark .fc-popover .fc-popover-body {
    scrollbar-color: rgba(148, 163, 184, 0.45) rgba(30, 41, 59, 0.6);
}

.dark .appointment-calendar .fc-popover.fc-more-popover {
    box-shadow:
        0 0 0 1px rgba(16, 185, 129, 0.35),
        0 25px 50px -12px rgba(0, 0, 0, 0.55) !important;
}

.dark .appointment-calendar .fc-popover.fc-more-popover::before {
    background: rgba(0, 0, 0, 0.62);
}

.dark .calendar-wrapper {
    background: #1e293b !important;
    border-color: #475569 !important;
}

.dark .calendar-controls {
    background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
    border-bottom-color: #475569 !important;
    color: #f1f5f9 !important;
}

.dark .calendar-controls * {
    color: #f1f5f9 !important;
}

.dark .calendar-controls .legend span {
    color: #cbd5e1 !important;
}

.dark #refresh-countdown {
    background: #1e40af !important;
    color: #dbeafe !important;
}

.dark .calendar-controls .text-gray-500,
.dark .calendar-controls .text-gray-600 {
    color: #cbd5e1 !important;
}

.dark #calendar-current-view {
    color: #f1f5f9 !important;
}

.dark #calendar-current-view * {
    color: #f1f5f9 !important;
}

.dark #current-calendar-type {
    color: #f1f5f9 !important;
}

/* Calendar Statistics Enhancement */
.calendar-stats-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.calendar-stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transition: left 0.6s ease;
}

.calendar-stats-card:hover::before {
    left: 100%;
}

.calendar-stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: #cbd5e1;
}

/* Enhanced Filter Controls */
.calendar-filter-section {
    background: linear-gradient(135deg, #fefefe 0%, #f8fafc 100%);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    margin-bottom: 24px;
}

.calendar-filter-section h2 {
    color: #1e293b;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Enhanced Select Styling */
.calendar-select {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    background: white;
    transition: all 0.3s ease;
    font-weight: 500;
}

.calendar-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Pulse Animation for Loading */
.calendar-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .5;
    }
}

/* Fullscreen Mode */
.fullscreen-calendar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: white;
    padding: 20px;
}

.fullscreen-calendar .appointment-calendar {
    height: calc(100vh - 120px);
}

.fullscreen-calendar .fc {
    height: 100% !important;
}

/* Calendar Focus States for Accessibility */
.fc-button:focus,
.fc-event:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.dark .fc-button:focus,
.dark .fc-event:focus {
    outline-color: #60a5fa;
}

/* SVG and Icon Support */
.fc-icon,
.fc svg {
    color: currentColor !important;
    stroke: currentColor !important;
    fill: currentColor !important;
}

.dark .fc-icon,
.dark .fc svg {
    color: #f1f5f9 !important;
    stroke: #f1f5f9 !important;
    fill: #f1f5f9 !important;
}

/* Button Icons */
.fc-button .fc-icon {
    font-size: 14px;
    vertical-align: middle;
}

.dark .fc-button .fc-icon {
    color: white !important;
}

/* Print Styles */
@media print {
    .calendar-controls,
    .calendar-wrapper {
        box-shadow: none !important;
        background: white !important;
    }
    
    .fc-button,
    .calendar-controls button {
        display: none !important;
    }
    
    .appointment-calendar {
        background: white !important;
    }
}