/*
 * Video Generator - Custom Styles
 * Complements TailwindCSS with custom animations, components, and utilities
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    /* Animation durations */
    --transition-fast: 150ms;
    --transition-normal: 200ms;
    --transition-slow: 300ms;

    /* Shadows */
    --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-card-hover: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}

/* Better focus styles */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ==========================================================================
   HTMX Loading States
   ========================================================================== */

/* Loading indicator for HTMX requests */
.htmx-request {
    opacity: 0.7;
    pointer-events: none;
}

.htmx-request.htmx-indicator {
    opacity: 1;
}

/* Pulsing animation during HTMX requests */
.htmx-request .htmx-indicator-pulse {
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Spinner for loading states */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* ==========================================================================
   Flash Messages / Notifications
   ========================================================================== */

.flash-message {
    animation: slideInRight var(--transition-slow) ease-out;
}

.flash-message.flash-exit {
    animation: slideOutRight var(--transition-normal) ease-in forwards;
}

/* Flash message types */
.flash-success {
    background-color: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}

.flash-error {
    background-color: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.flash-warning {
    background-color: #fffbeb;
    border-color: #f59e0b;
    color: #92400e;
}

.flash-info {
    background-color: #eff6ff;
    border-color: #3b82f6;
    color: #1e40af;
}

/* ==========================================================================
   Form Components
   ========================================================================== */

/* Input focus ring enhancement */
input:focus,
select:focus,
textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Custom checkbox styles */
input[type="checkbox"]:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background var(--transition-fast);
}

input[type="range"]::-moz-range-thumb:hover {
    background: #2563eb;
}

/* Number input spinner buttons */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

/* ==========================================================================
   Button Components
   ========================================================================== */

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.75s linear infinite;
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    transform: translateY(-1px);
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-running {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-completed {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-failed {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-processing {
    background-color: #e0e7ff;
    color: #3730a3;
}

/* Animated badge for running/processing states */
.badge-animated::before {
    content: '';
    width: 6px;
    height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background-color: currentColor;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.progress-bar {
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: #3b82f6;
    border-radius: 4px;
    transition: width var(--transition-slow) ease-out;
}

.progress-bar-fill.progress-completed {
    background-color: #10b981;
}

.progress-bar-fill.progress-failed {
    background-color: #ef4444;
}

/* Animated progress bar (indeterminate) */
.progress-bar-indeterminate .progress-bar-fill {
    width: 30%;
    animation: indeterminate 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Event Grid / Cards
   ========================================================================== */

.event-card {
    position: relative;
    border-radius: 0.5rem;
    overflow: hidden;
    background: white;
    border: 2px solid transparent;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}

.event-card:hover {
    border-color: #93c5fd;
    transform: scale(1.02);
}

.event-card.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.event-card.selected::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-color: #3b82f6;
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2.5' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4.5 12.75l6 6 9-13.5'/%3E%3C/svg%3E");
    background-size: 16px;
    background-repeat: no-repeat;
    background-position: center;
}

.event-card-image {
    aspect-ratio: 16/9;
    object-fit: cover;
    width: 100%;
}

.event-card-placeholder {
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

/* ==========================================================================
   Video Player
   ========================================================================== */

.video-container {
    position: relative;
    background: #000;
    border-radius: 0.5rem;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    display: block;
}

.video-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.video-container:hover .video-overlay {
    opacity: 1;
}

/* ==========================================================================
   Collapsible Sections
   ========================================================================== */

.collapsible-header {
    cursor: pointer;
    user-select: none;
}

.collapsible-icon {
    transition: transform var(--transition-normal);
}

.collapsible-header[aria-expanded="true"] .collapsible-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height var(--transition-slow) ease-out;
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-image {
    aspect-ratio: 16/9;
}

.skeleton-button {
    height: 2.5rem;
    width: 6rem;
}

/* ==========================================================================
   Modal / Dialog
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal-backdrop.show {
    opacity: 1;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 50;
    opacity: 0;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.modal-content.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.5rem;
    background: #1f2937;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    margin-bottom: 4px;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ==========================================================================
   Date Picker Enhancement
   ========================================================================== */

input[type="date"] {
    position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
    display: flex;
    gap: 0.25rem;
}

.pagination-item {
    min-width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: background-color var(--transition-fast);
}

.pagination-item:hover:not(.active):not(:disabled) {
    background-color: #f3f4f6;
}

.pagination-item.active {
    background-color: #3b82f6;
    color: white;
}

.pagination-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

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

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Animation utilities */
.animate-fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

.animate-scale-in {
    animation: scaleIn var(--transition-normal) ease-out;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Transition utilities */
.transition-all-fast {
    transition: all var(--transition-fast);
}

.transition-all-normal {
    transition: all var(--transition-normal);
}

/* Truncate text with ellipsis */
.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Scrollbar styling */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #e5e7eb;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}
