/* ==========================================================================
   Timetable Components — course blocks, day headers, time slots, UI elements
   ========================================================================== */

/* --------------------------------------------------------------------------
   Toolbar buttons (.download-btn group + standalone download-btn)
   -------------------------------------------------------------------------- */

/* Shared styles for all toolbar icon buttons */
.download-btn, .add-temp-course-btn, .upload-btn, .compare-btn, .ai-btn {
    position: relative;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease-in-out;
}

.download-btn i, .add-temp-course-btn i, .upload-btn i, .compare-btn i, .ai-btn i {
    transition: color 0.2s ease-in-out;
}

.download-btn:hover, .add-temp-course-btn:hover, .upload-btn:hover, .compare-btn:hover, .ai-btn:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.download-btn:hover i, .add-temp-course-btn:hover i, .upload-btn:hover i, .compare-btn:hover i, .ai-btn:hover i {
    color: #2563eb;
}

/* Extended download button (inline-flex variant) */
.download-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Tooltip shared by all toolbar buttons */
.download-tooltip {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--color-text-dark);
    color: white;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    margin-top: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 20;
}

.download-btn:hover .download-tooltip,
.add-temp-course-btn:hover .download-tooltip,
.upload-btn:hover .download-tooltip,
.compare-btn:hover .download-tooltip,
.ai-btn:hover .download-tooltip {
    opacity: 1;
    visibility: visible;
}

/* --------------------------------------------------------------------------
   Day headers, grid lines, time labels
   -------------------------------------------------------------------------- */

/* Canonical .day-header — merged from all conflicting definitions */
.day-header {
    position: absolute;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-right: 1px solid var(--color-border);
    background-color: white;
    font-weight: 500;
    margin-left: -10px;
    top: 0;
    font-size: 1rem;
    width: 120px;
}

/* Precise positions inside #schDays */
#schDays .day-header:nth-child(1) { left: 85px; }
#schDays .day-header:nth-child(2) { left: 205px; }
#schDays .day-header:nth-child(3) { left: 325px; }
#schDays .day-header:nth-child(4) { left: 445px; }
#schDays .day-header:nth-child(5) { left: 565px; }
/* Weekend columns (print/shared): markup ships them display:none with class
   .weekend-col; static-grid.js reveals them when a course meets S/U */
#schDays .day-header:nth-child(6) { left: 685px; }
#schDays .day-header:nth-child(7) { left: 805px; }

/* Fallback positions for .day-header outside #schDays */
.day-header:nth-child(1) { left: 70px; }
.day-header:nth-child(2) { left: 190px; }
.day-header:nth-child(3) { left: 310px; }
.day-header:nth-child(4) { left: 430px; }
.day-header:nth-child(5) { left: 550px; }
.day-header:nth-child(6) { left: 670px; }
.day-header:nth-child(7) { left: 790px; }

/* Vertical day-separator lines */
.day-line {
    position: absolute;
    top: 40px;
    width: 1px;
    background-color: #ddd;
}

.day-line:nth-child(1) { left: 75px; }
.day-line:nth-child(2) { left: 195px; }
.day-line:nth-child(3) { left: 315px; }
.day-line:nth-child(4) { left: 435px; }
.day-line:nth-child(5) { left: 555px; }
.day-line:nth-child(6) { left: 675px; }

/* Horizontal hour-separator lines */
.hour-line {
    position: absolute;
    left: 70px;
    width: 615px;
    height: 1px;
    background-color: #ddd;
}

.time-label {
    font-size: 0.875rem;
    color: #4b5563;
}

/* --------------------------------------------------------------------------
   Course blocks
   -------------------------------------------------------------------------- */

.course-shadow {
    position: absolute;
    background-color: rgba(0, 123, 255, 0.1);
    border: 2px dashed rgba(0, 123, 255, 0.4);
    border-radius: 4px;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.2s ease;
}

.course-block {
    position: absolute;
    border-radius: 3px;
    padding: 8px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.course-block:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Conflict/removal states */
.overlap-highlight {
    background-color: var(--color-danger) !important;
    border: 2px solid #dc2626 !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5) !important;
    animation: pulse 1s infinite;
}

.course-block.removal-ready {
    animation: pulse-warning 1s infinite;
    border: 2px solid #f59e0b !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5) !important;
}

.course-block.removing-confirmed {
    animation: fade-out 0.18s ease-out forwards;
    border: 2px solid var(--color-danger) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.7) !important;
}

/* Course preview block (hover shadow on grid) */
.course-preview-block {
    animation: pulse 2s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Context menu
   -------------------------------------------------------------------------- */

.course-context-menu {
    min-width: 200px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: context-menu-appear 0.15s ease-out;
}

.course-context-menu .context-menu-item {
    transition: background-color 0.15s ease;
}

.course-context-menu .context-menu-item:hover {
    background-color: #f3f4f6;
}

.course-context-menu .context-menu-item:active {
    background-color: var(--color-border);
}

/* --------------------------------------------------------------------------
   Scrollbar styling
   -------------------------------------------------------------------------- */

.overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f1f5f9;
}

.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   Course info card
   -------------------------------------------------------------------------- */

#courseInfo {
    transition: all 0.3s ease;
}

/* --------------------------------------------------------------------------
   Modern design system — cards, inputs, search, tips
   -------------------------------------------------------------------------- */

/* Theme cross-fade — scoped replacement for the old `* { transition: all .3s }`
   catch-all, which taxed paint on the 675x1200 absolute grid and animated
   modal toggles / grid transforms unintentionally. Interactive elements carry
   their own transitions. */
body,
.day-header,
.time-label,
.hour-line,
.day-line,
#schTimes,
.bg-white {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.glass-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modern-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Floating label */
.floating-label-container {
    position: relative;
}

/* The hint label doesn't float — layout.css fades it out on focus/content —
   so it sits exactly where the typed text goes (left matches px-4, vertically
   centred), and the input needs no asymmetric headroom padding. */
.floating-label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #9ca3af;
    pointer-events: none;
    font-size: 16px;
}

.modern-input {
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Modern search input */
.modern-search-input {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid transparent;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-search-input:focus {
    background: rgba(255, 255, 255, 1);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Search result items */
.search-result-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

/* Expert tips */
.expert-tip-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(10px);
}

.tip-icon {
    background: linear-gradient(135deg, var(--color-primary), #a855f7);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: pulse 2s infinite;
}

/* Loading shimmer */
.shimmer {
    background: linear-gradient(to right, #f6f7f8 8%, #edeef1 18%, #f6f7f8 33%);
    background-size: 800px 104px;
    animation: shimmer 1.5s infinite ease-in-out;
}

/* --------------------------------------------------------------------------
   Course info header / content
   -------------------------------------------------------------------------- */

.course-info-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt));
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    font-weight: 600;
}

.course-info-content {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.course-info-content.show {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Favorites items
   -------------------------------------------------------------------------- */

.favorite-item {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInFavorite 0.5s forwards;
}

.favorite-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.favorite-remove-btn {
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.favorite-item:hover .favorite-remove-btn {
    opacity: 1;
}

/* Empty state */
.empty-state {
    opacity: 0;
    animation: fadeInUp 0.6s forwards;
}

.empty-state-icon {
    animation: float 3s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Feature icons (toolbar icons section)
   -------------------------------------------------------------------------- */

.feature-icon {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

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

.feature-icon:hover::before {
    left: 100%;
}

.feature-icon:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.feature-item {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Gradient text utility */
.gradient-text {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt), #ec4899);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

/* Modern button */
.modern-btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.modern-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

/* --------------------------------------------------------------------------
   AI floating button
   -------------------------------------------------------------------------- */

#ai-floating-button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    animation: slideInFromBottom 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#ai-floating-button:hover {
    transform: scale(1.05);
}

#ai-floating-button button {
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(147, 51, 234, 0.3);
    backdrop-filter: blur(10px);
}

#ai-floating-button button:hover {
    box-shadow: 0 12px 40px rgba(147, 51, 234, 0.4);
    transform: translateY(-2px);
}

#ai-floating-button button:active {
    transform: translateY(0px) scale(0.95);
}

#ai-help-bubble {
    max-width: 300px;
    z-index: 60;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(147, 51, 234, 0.1);
    cursor: pointer;
}

#ai-help-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

#ai-help-bubble.show {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

#ai-floating-button .animate-ping {
    animation: aiPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */

.modern-filter-card {
    position: relative;
    overflow: hidden;
    animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-filter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    animation: shimmer-filter 3s infinite;
}

.filter-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.filter-icon-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.6s ease;
}

.modern-filter-card:hover .filter-icon-wrapper::before {
    transform: translate(-50%, -50%) scale(2);
}

.filter-icon-wrapper:hover {
    transform: rotate(5deg) scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.filter-select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    white-space: nowrap;
    margin: 0;
}

.modern-filter-select {
    padding: 12px 16px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    background: linear-gradient(to bottom, #ffffff, #f9fafb);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-dark);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    min-width: 140px;
    height: 44px;
}

.modern-filter-select:hover {
    border-color: #c7d2fe;
    background: linear-gradient(to bottom, #ffffff, #eef2ff);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.modern-filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: #ffffff;
}

.modern-filter-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-alt));
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.modern-filter-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.modern-filter-button:hover::before {
    left: 100%;
}

.modern-filter-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

.modern-filter-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* --------------------------------------------------------------------------
   Conflict dialog
   -------------------------------------------------------------------------- */

#conflict-dialog,
#confirm-dialog {
    animation: fadeIn 0.2s ease-in-out;
}

/* --------------------------------------------------------------------------
   Conflict detection
   -------------------------------------------------------------------------- */

.conflict-shake {
    animation: conflict-shake 0.6s ease-in-out;
}

.conflict-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-danger);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: pulse 2s ease-in-out infinite;
}

/* Expert-search tip icon glow — purple drop-shadow matching the brand accent.
   Lives here instead of `style="filter:..."` in the template so the CSP can
   eventually tighten style-src 'self' without rewriting the markup. */
.tip-icon-glow {
    filter: drop-shadow(0 0 8px rgba(147, 51, 234, 0.6));
}
