/**
 * TV Schedule Manager - Frontend Styles
 * Modern, animated UI with smooth transitions
 */

/* ========================================
   CSS Variables
   ======================================== */
.tvsm-schedule-container {
    --tvsm-primary: #2563eb;
    --tvsm-primary-hover: #1d4ed8;
    --tvsm-primary-light: #dbeafe;
    --tvsm-accent: #0ea5e9;
    --tvsm-success: #10b981;
    --tvsm-warning: #f59e0b;
    --tvsm-danger: #ef4444;
    --tvsm-info: #3b82f6;

    --tvsm-text: #111827;
    --tvsm-text-muted: #6b7280;
    --tvsm-text-light: #9ca3af;

    --tvsm-border: #e5e7eb;

    --tvsm-bg: #ffffff;
    --tvsm-bg-alt: #f8fafc;
    --tvsm-bg-hover: #f1f5f9;
    --tvsm-card-bg: #ffffff;

    --tvsm-radius: 12px;
    --tvsm-radius-sm: 8px;
    --tvsm-radius-lg: 16px;

    --tvsm-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --tvsm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --tvsm-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --tvsm-shadow-primary: 0 4px 14px rgba(37, 99, 235, 0.35);

    --tvsm-transition-fast: 0.15s ease;
    --tvsm-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --tvsm-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    --tvsm-active-tab: var(--tvsm-primary);
}

/* ========================================
   Page Load Animation - Smooth Fade In
   ======================================== */
@keyframes tvsmFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tvsmSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes tvsmPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: var(--tvsm-shadow);
    }
    50% {
        transform: scale(1.02);
        box-shadow: var(--tvsm-shadow-md);
    }
}

/* ========================================
   Container - Smooth Load
   ======================================== */
.tvsm-schedule-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--tvsm-text);
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
    animation: tvsmFadeIn 0.4s ease-out;
}

.tvsm-schedule-container *,
.tvsm-schedule-container *::before,
.tvsm-schedule-container *::after {
    box-sizing: border-box;
}

/* ========================================
   Schedule Header
   ======================================== */
.tvsm-schedule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tvsm-border);
    animation: tvsmFadeIn 0.5s ease-out 0.1s both;
}

.tvsm-schedule-date-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--tvsm-text);
}

.tvsm-schedule-count {
    font-size: 14px;
    color: var(--tvsm-text-muted);
    background: var(--tvsm-bg-alt);
    padding: 4px 12px;
    border-radius: 20px;
}

/* ========================================
   Date Navigation - FIXED CURSORS
   ======================================== */
.tvsm-date-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 10px;
    background: linear-gradient(135deg, var(--tvsm-bg-alt) 0%, #f1f5f9 100%);
    border-radius: var(--tvsm-radius-lg);
    border: 1px solid var(--tvsm-border);
    animation: tvsmFadeIn 0.4s ease-out;
}

/* Navigation Arrows - Clickable */
.tvsm-date-nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--tvsm-radius);
    background: var(--tvsm-bg);
    color: var(--tvsm-text);
    text-decoration: none;
    transition: all var(--tvsm-transition);
    flex-shrink: 0;
    box-shadow: var(--tvsm-shadow);
    border: 1px solid var(--tvsm-border);

    /* FORCE POINTER CURSOR */
    cursor: pointer !important;
    -webkit-user-select: none;
    user-select: none;
}

.tvsm-date-nav-arrow:hover {
    background: var(--tvsm-primary);
    color: #fff;
    border-color: var(--tvsm-primary);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--tvsm-shadow-primary);
}

.tvsm-date-nav-arrow:active {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--tvsm-shadow);
}

/* Disabled Arrows - NOT clickable */
.tvsm-date-nav-arrow--disabled,
.tvsm-date-nav-arrow[aria-disabled="true"] {
    opacity: 0.35;
    cursor: not-allowed !important;
    pointer-events: none;
    background: var(--tvsm-bg-alt);
    border-color: transparent;
    box-shadow: none;
}

/* ========================================
   Date Tabs - BEAUTIFUL & CLICKABLE
   ======================================== */
.tvsm-date-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    flex: 1;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tvsm-date-tabs::-webkit-scrollbar {
    display: none;
}

/* Individual Date Tab - CLICKABLE */
.tvsm-date-tab {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    min-width: 75px;
    border-radius: var(--tvsm-radius);
    background: var(--tvsm-bg);
    color: var(--tvsm-text);
    text-decoration: none;
    transition: all var(--tvsm-transition);
    box-shadow: var(--tvsm-shadow);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;

    /* FORCE POINTER CURSOR */
    cursor: pointer !important;
    -webkit-user-select: none;
    user-select: none;
}

/* Hover ripple effect */
.tvsm-date-tab::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--tvsm-primary-light);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    opacity: 0;
    z-index: 0;
}

.tvsm-date-tab:hover::before {
    width: 150%;
    height: 150%;
    opacity: 0.3;
}

.tvsm-date-tab > * {
    position: relative;
    z-index: 1;
}

/* Hover State - Very Obvious */
.tvsm-date-tab:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: var(--tvsm-shadow-md);
    border-color: var(--tvsm-primary);
    background: var(--tvsm-bg);
    cursor: pointer !important;
}

/* Ensure anchor tags show pointer */
a.tvsm-date-tab,
a.tvsm-date-tab:link,
a.tvsm-date-tab:visited,
a.tvsm-date-tab:hover,
a.tvsm-date-tab:active {
    cursor: pointer !important;
}

.tvsm-date-tab:hover .tvsm-date-day {
    color: var(--tvsm-primary);
}

.tvsm-date-tab:hover .tvsm-date-number {
    color: var(--tvsm-primary);
}

/* Active/Click state */
.tvsm-date-tab:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: var(--tvsm-shadow);
}

/* Active Date Tab - Selected */
.tvsm-date-tab--active {
    background: linear-gradient(135deg, var(--tvsm-primary) 0%, var(--tvsm-primary-hover) 100%);
    color: #fff;
    border-color: var(--tvsm-primary);
    box-shadow: var(--tvsm-shadow-primary);
    transform: translateY(-2px);
}

.tvsm-date-tab--active::before {
    display: none;
}

.tvsm-date-tab--active:hover {
    background: linear-gradient(135deg, var(--tvsm-primary-hover) 0%, #1e40af 100%);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.tvsm-date-tab--active .tvsm-date-day,
.tvsm-date-tab--active .tvsm-date-number {
    color: #fff !important;
}

/* Empty/No Schedule Tab */
.tvsm-date-tab--empty {
    opacity: 0.8;
    cursor: pointer !important;
}

.tvsm-date-tab--empty:hover {
    transform: translateY(-2px);
    box-shadow: var(--tvsm-shadow-md);
    border-color: var(--tvsm-primary);
    cursor: pointer !important;
}

.tvsm-date-tab--empty::before {
    display: none;
}

/* Today Badge */
.tvsm-date-tab--today {
    position: relative;
}

.tvsm-date-day {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tvsm-text-muted);
    transition: color var(--tvsm-transition);
}

.tvsm-date-number {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: var(--tvsm-text);
    transition: color var(--tvsm-transition);
}

.tvsm-date-today-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--tvsm-success) 0%, #059669 100%);
    color: #fff;
    padding: 3px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    animation: tvsmPulse 2s ease-in-out infinite;
}

/* ========================================
   Channel Filter
   ======================================== */
.tvsm-channel-filter {
    margin-bottom: 20px;
    animation: tvsmFadeIn 0.5s ease-out 0.15s both;
}

.tvsm-channel-filter form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tvsm-channel-select {
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--tvsm-border);
    border-radius: var(--tvsm-radius);
    background: var(--tvsm-bg);
    color: var(--tvsm-text);
    cursor: pointer;
    min-width: 200px;
    transition: all var(--tvsm-transition);
}

.tvsm-channel-select:hover {
    border-color: var(--tvsm-primary);
}

.tvsm-channel-select:focus {
    outline: none;
    border-color: var(--tvsm-primary);
    box-shadow: 0 0 0 4px var(--tvsm-primary-light);
}

.tvsm-channel-filter noscript button {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    background: var(--tvsm-primary);
    color: #fff;
    border: none;
    border-radius: var(--tvsm-radius);
    cursor: pointer;
    transition: all var(--tvsm-transition);
}

.tvsm-channel-filter noscript button:hover {
    background: var(--tvsm-primary-hover);
    transform: translateY(-2px);
}

/* ========================================
   Schedule Content - Staggered Animation
   ======================================== */
.tvsm-schedule-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: tvsmFadeIn 0.5s ease-out 0.2s both;
}

/* ========================================
   Schedule Items
   ======================================== */
.tvsm-schedule-item {
    display: flex;
    gap: 16px;
    padding: 18px 22px;
    background: var(--tvsm-card-bg);
    border-radius: var(--tvsm-radius);
    border: 1px solid var(--tvsm-border);
    transition: all var(--tvsm-transition);
    cursor: pointer;
    animation: tvsmSlideIn 0.4s ease-out both;
}

.tvsm-schedule-item:nth-child(1) { animation-delay: 0.05s; }
.tvsm-schedule-item:nth-child(2) { animation-delay: 0.1s; }
.tvsm-schedule-item:nth-child(3) { animation-delay: 0.15s; }
.tvsm-schedule-item:nth-child(4) { animation-delay: 0.2s; }
.tvsm-schedule-item:nth-child(5) { animation-delay: 0.25s; }
.tvsm-schedule-item:nth-child(n+6) { animation-delay: 0.3s; }

.tvsm-schedule-item:hover {
    box-shadow: var(--tvsm-shadow-md);
    transform: translateY(-3px);
    border-color: var(--tvsm-primary-light);
}

.tvsm-schedule-item--no-expand {
    cursor: default;
}

.tvsm-schedule-item--no-expand:hover {
    transform: none;
}

.tvsm-schedule-item--past {
    opacity: 0.55;
}

.tvsm-schedule-item--live {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, var(--tvsm-card-bg) 100%);
    border-left: 4px solid var(--tvsm-danger);
    animation: tvsmPulse 3s ease-in-out infinite;
}

/* Time Column */
.tvsm-item-time {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 75px;
}

.tvsm-time-start {
    font-size: 17px;
    font-weight: 700;
    color: var(--tvsm-text);
}

.tvsm-time-separator {
    font-size: 12px;
    color: var(--tvsm-text-light);
}

.tvsm-time-end {
    font-size: 13px;
    color: var(--tvsm-text-muted);
}

.tvsm-live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--tvsm-danger) 0%, #dc2626 100%);
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.tvsm-live-dot {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    animation: tvsmPulse 1s ease-in-out infinite;
}

/* Content Column */
.tvsm-item-content {
    flex: 1;
    display: flex;
    gap: 16px;
    min-width: 0;
}

/* Image */
.tvsm-item-image {
    flex-shrink: 0;
    width: 85px;
    height: 65px;
    border-radius: var(--tvsm-radius-sm);
    overflow: hidden;
    background: var(--tvsm-bg-alt);
}

.tvsm-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--tvsm-transition);
}

.tvsm-schedule-item:hover .tvsm-item-image img {
    transform: scale(1.05);
}

.tvsm-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--tvsm-text-light);
}

/* Details */
.tvsm-item-details {
    flex: 1;
    min-width: 0;
}

.tvsm-item-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--tvsm-text);
    transition: color var(--tvsm-transition);
}

.tvsm-schedule-item:hover .tvsm-item-title {
    color: var(--tvsm-primary);
}

.tvsm-schedule-item--collapsed .tvsm-item-title::after {
    content: '';
    display: inline-block;
    margin-left: 8px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--tvsm-text-light);
    vertical-align: middle;
    transition: transform var(--tvsm-transition);
}

.tvsm-schedule-item--expanded .tvsm-item-title::after {
    content: '';
    display: inline-block;
    margin-left: 8px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--tvsm-primary);
    vertical-align: middle;
    transform: rotate(180deg);
}

/* Expandable Content */
.tvsm-item-details-expanded {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--tvsm-border);
    animation: tvsmFadeIn 0.3s ease-out;
}

.tvsm-schedule-item--expanded .tvsm-item-details-expanded {
    display: block;
}

.tvsm-schedule-item--collapsed .tvsm-item-details-expanded {
    display: none;
}

.tvsm-item-episode {
    font-size: 13px;
    font-weight: 600;
    color: var(--tvsm-accent);
    margin-bottom: 8px;
}

.tvsm-item-description {
    font-size: 14px;
    line-height: 1.6;
    color: var(--tvsm-text-muted);
    margin: 0 0 12px 0;
}

.tvsm-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--tvsm-text-light);
}

.tvsm-meta-category,
.tvsm-meta-duration,
.tvsm-meta-channel {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: var(--tvsm-bg-alt);
    border-radius: 20px;
}

.tvsm-meta-category::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--tvsm-accent);
    border-radius: 50%;
}

/* Badges */
.tvsm-item-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tvsm-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 6px;
    background: var(--tvsm-bg-alt);
    color: var(--tvsm-text-muted);
}

.tvsm-badge--live {
    background: linear-gradient(135deg, var(--tvsm-danger) 0%, #dc2626 100%);
    color: #fff;
}

.tvsm-badge--premiere {
    background: linear-gradient(135deg, var(--tvsm-success) 0%, #059669 100%);
    color: #fff;
}

.tvsm-badge--finale {
    background: linear-gradient(135deg, var(--tvsm-warning) 0%, #d97706 100%);
    color: #fff;
}

.tvsm-badge--repeat {
    background: var(--tvsm-bg-alt);
    color: var(--tvsm-text-muted);
}

/* ========================================
   Empty State
   ======================================== */
.tvsm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--tvsm-bg-alt) 0%, #f1f5f9 100%);
    border-radius: var(--tvsm-radius-lg);
    border: 2px dashed var(--tvsm-border);
    animation: tvsmFadeIn 0.5s ease-out;
}

.tvsm-empty-state-icon {
    margin-bottom: 20px;
    color: var(--tvsm-text-light);
    opacity: 0.6;
}

.tvsm-empty-state-text {
    font-size: 17px;
    font-weight: 500;
    color: var(--tvsm-text-muted);
    margin: 0;
}

/* ========================================
   Loading State
   ======================================== */
.tvsm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    background: var(--tvsm-bg);
}

.tvsm-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--tvsm-border);
    border-top-color: var(--tvsm-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
    .tvsm-schedule-container {
        padding: 0 12px;
    }

    .tvsm-date-nav {
        padding: 8px;
        gap: 8px;
    }

    .tvsm-date-nav-arrow {
        width: 40px;
        height: 40px;
    }

    .tvsm-date-tab {
        padding: 10px 16px;
        min-width: 65px;
    }

    .tvsm-date-number {
        font-size: 20px;
    }

    .tvsm-schedule-item {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
    }

    .tvsm-item-time {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        min-width: auto;
    }

    .tvsm-item-content {
        flex-direction: column;
        gap: 12px;
    }

    .tvsm-item-image {
        width: 100%;
        height: 140px;
    }

    .tvsm-schedule-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .tvsm-schedule-date-title {
        font-size: 20px;
    }

    .tvsm-channel-filter form {
        flex-direction: column;
        align-items: stretch;
    }

    .tvsm-channel-select {
        width: 100%;
    }
}

/* ========================================
   Screen Reader Only
   ======================================== */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Focus States for Accessibility
   ======================================== */
.tvsm-date-tab:focus,
.tvsm-date-nav-arrow:focus,
.tvsm-schedule-item:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--tvsm-primary-light), var(--tvsm-shadow-md);
}

.tvsm-date-tab:focus-visible,
.tvsm-date-nav-arrow:focus-visible {
    outline: 2px solid var(--tvsm-primary);
    outline-offset: 2px;
}

/* ========================================
   UX Fixes: remove page blackout effect
   ======================================== */
.tvsm-schedule-container,
.tvsm-schedule-header,
.tvsm-date-nav,
.tvsm-channel-filter,
.tvsm-schedule-content,
.tvsm-empty-state,
.tvsm-schedule-item {
    animation: none !important;
}

/* Keep clickable cursor explicit on all date tabs */
.tvsm-date-tab,
.tvsm-date-tab--active,
.tvsm-date-tab--empty,
a.tvsm-date-tab,
a.tvsm-date-tab--active,
a.tvsm-date-tab--empty {
    cursor: pointer !important;
}
