/**
 * Video Card Component Styles
 * Modern workshop card design with gradient illustration headers
 * 
 * @package CustomVideosPlugin
 * @since 2.0.0
 */

/* ====================================
   CSS Variables
   ==================================== */
:root {
    --cvp-card-bg: #ffffff;
    --cvp-card-border: #e5e7eb;
    --cvp-card-shadow: rgba(0, 0, 0, 0.05);
    --cvp-card-shadow-hover: rgba(0, 0, 0, 0.1);
    --cvp-text-primary: #111827;
    --cvp-text-secondary: #6b7280;
    --cvp-text-muted: #9ca3af;
    --cvp-border-radius: 12px;
    --cvp-badge-bg: #dbeafe;
    --cvp-badge-text: #2563eb;
    --cvp-accent-green: #22c55e;
    --cvp-accent-blue: #3b82f6;
}

/* ====================================
   Grid Layout
   ==================================== */
.videos-grid {
    display: grid !important;
    grid-template-columns: repeat(1, 1fr) !important;
    gap: 1.5rem !important;
    min-height: 400px;
    position: relative;
}

/* Loading overlay to prevent layout shift */
.videos-grid.is-loading {
    pointer-events: none;
}

.videos-grid.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    border-radius: 8px;
}

.videos-grid.is-loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
    font-size: 1rem;
    color: #666;
    background: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .videos-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1024px) {
    .videos-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (min-width: 1440px) {
    .videos-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ====================================
   Card Base
   ==================================== */
.cvp-video-card {
    background: var(--cvp-card-bg);
    border-radius: var(--cvp-border-radius);
    box-shadow: 0 1px 3px var(--cvp-card-shadow);
    border: 1px solid var(--cvp-card-border);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.cvp-video-card:hover {
    box-shadow: 0 4px 12px var(--cvp-card-shadow-hover);
    transform: translateY(-2px);
}

/* ====================================
   Card Header (Illustration)
   ==================================== */
.cvp-card-header {
    position: relative;
    aspect-ratio: 16 / 9;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    border-radius: var(--cvp-border-radius) var(--cvp-border-radius) 0 0;
}

/* Gradient backgrounds for different categories */
.cvp-card-header--gradient-green {
    background: linear-gradient(135deg, #dcfce7 0%, #fef9c3 100%);
}

.cvp-card-header--gradient-blue {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
}

.cvp-card-header--gradient-purple {
    background: linear-gradient(135deg, #f3e8ff 0%, #fce7f3 100%);
}

.cvp-card-header--gradient-orange {
    background: linear-gradient(135deg, #fed7aa 0%, #fef3c7 100%);
}

/* Header top row */
.cvp-card-header__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 2;
}

.cvp-card-header__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #166534;
    opacity: 0.8;
}

/* Play/link button */
.cvp-card-header__action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.cvp-card-header__action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.cvp-card-header__action svg {
    width: 16px;
    height: 16px;
    color: white;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Header title area */
.cvp-card-header__content {
    z-index: 2;
}

.cvp-card-header__title {
    font-size: 1.875rem;
    font-weight: 900;
    line-height: 1.1;
    color: #1f2937;
    margin: 0;
    text-transform: uppercase;
    word-break: break-word;
}

.cvp-card-header__subtitle {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #15803d;
    margin-top: 4px;
}

/* Decorative elements */
.cvp-card-header__decor {
    position: absolute;
    font-size: 9rem;
    color: rgba(34, 197, 94, 0.1);
    right: -16px;
    bottom: -16px;
    transform: rotate(12deg);
    pointer-events: none;
}

.cvp-card-header__decor--small {
    position: absolute;
    font-size: 1.875rem;
    color: rgba(34, 197, 94, 0.2);
    top: 16px;
    right: 48px;
    pointer-events: none;
}

.cvp-card-header__accent {
    position: absolute;
    right: 16px;
    bottom: 80px;
    width: 64px;
    height: 64px;
    background: rgba(96, 165, 250, 0.2);
    border-radius: 50%;
    filter: blur(20px);
    pointer-events: none;
}

/* ====================================
   Card Body
   ==================================== */
.cvp-card-body {
    padding: 0.8rem 1.25rem 0rem 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Top row: badge + actions */
.cvp-card-body__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

/* Category badge */
.cvp-card-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-radius: 0;
    padding: 4px 8px;
    background: var(--cvp-badge-bg);
}

/* Action buttons */
.cvp-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cvp-card-actions button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--cvp-text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.cvp-card-actions button:hover {
    color: var(--cvp-accent-blue);
}

/* Heart button with original image icons */
.cvp-card-actions button.cvp-like-btn {
    background-image: url('https://happyteachersacademy.com/community/wp-content/uploads/sites/2/2025/08/white.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.cvp-card-actions button.cvp-like-btn:hover,
.cvp-card-actions button.cvp-like-btn.liked {
    background-image: url('https://happyteachersacademy.com/community/wp-content/uploads/sites/2/2025/08/red.png');
}

.cvp-card-actions button svg {
    width: 20px;
    height: 20px;
}

.cvp-card-actions button img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Title */
.cvp-card-body__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--cvp-text-primary);
    margin: 0;
}

.cvp-card-body__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cvp-card-body__title a:hover {
    color: var(--cvp-accent-blue);
}

/* Meta row */
.cvp-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 10px;
    font-weight: 500;
    color: var(--cvp-text-secondary);
}

.cvp-card-meta__separator {
    color: var(--cvp-text-muted);
}

/* ====================================
   Card Footer
   ==================================== */
.cvp-card-footer {
    padding: 0 1.25rem 0rem;
}

/* Instructor row */
.cvp-card-instructor {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.25rem 0rem;
}

.cvp-card-instructor__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50% !important;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cvp-card-instructor__name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--cvp-text-secondary);
}

/* Multi-author: overlapping avatars, no name */
.cvp-card-instructor__avatars {
    display: flex;
    align-items: center;
}

.cvp-card-instructor__avatars .cvp-avatar-tip {
    z-index: 1;
}

.cvp-card-instructor__avatars .cvp-avatar-tip:not(:first-child) {
    margin-left: -10px;
    z-index: 2;
}

/* Lock button */
.cvp-card-lock-btn {
    width: 100%;
    padding: 0.5rem 0rem;
    background: transparent;
    border: none;
    border-top: 1px solid var(--cvp-card-border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    color: var(--cvp-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: not-allowed;
}

.cvp-card-lock-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Watch button (when unlocked) */
.cvp-card-watch-btn {
    width: 100%;
    padding: 0.5rem 0rem;
    background: transparent;
    border: none;
    border-top: 1px solid var(--cvp-card-border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    color: var(--cvp-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.cvp-card-watch-btn:hover {
    color: var(--cvp-text-primary);
}

.cvp-card-watch-btn svg {
    width: 20px;
    height: 20px;
}

/* ====================================
   Star Rating
   ==================================== */
.cvp-star-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 0;
}

.cvp-star-rating img {
    width: 14px;
    height: 14px;
}

.cvp-star-rating__count {
    font-size: 11px;
    color: var(--cvp-text-muted);
    margin-left: 4px;
}

/* Mini rating in actions row */
.cvp-card-rating-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgb(251 191 36 / var(--tw-text-opacity, 1));
    margin-right: 10px;
}

.cvp-card-rating-mini img {
    width: 16px;
    height: 16px;
}

/* ====================================
   Duration Meta
   ==================================== */ */
.cvp-card-meta__duration {
    display: inline-flex;
    align-items: center;
    color: var(--cvp-text-secondary);
    font-weight: bold;
}

.cvp-card-meta__level,
.cvp-card-meta__language,
.cvp-card-meta__topic {
    color: var(--cvp-text-secondary);
}

/* ====================================
   Tooltips
   ==================================== */
.cvp-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.cvp-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background-color: #1f2937;
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    margin-bottom: 8px;
    z-index: 10;
}

.cvp-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.cvp-tooltip-wrapper:hover .cvp-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ====================================
   Responsive Adjustments
   ==================================== */
@media (max-width: 640px) {
    .cvp-card-header__title {
        font-size: 1.5rem;
    }
    
    .cvp-card-header__decor {
        font-size: 6rem;
    }
    
    .cvp-card-body,
    .cvp-card-footer {
        padding: 1rem;
    }
    
    .cvp-card-footer {
        padding-top: 0;
    }
}

/* ====================================
   Animation
   ==================================== */
.cvp-video-card {
    animation: cvp-card-fade-in 0.4s ease-out both;
}

@keyframes cvp-card-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for grid — fill-mode: both keeps cards invisible until their delay fires */
.videos-grid .cvp-video-card:nth-child(1) { animation-delay: 0.02s; }
.videos-grid .cvp-video-card:nth-child(2) { animation-delay: 0.04s; }
.videos-grid .cvp-video-card:nth-child(3) { animation-delay: 0.06s; }
.videos-grid .cvp-video-card:nth-child(4) { animation-delay: 0.08s; }
.videos-grid .cvp-video-card:nth-child(5) { animation-delay: 0.1s; }
.videos-grid .cvp-video-card:nth-child(6) { animation-delay: 0.12s; }
.videos-grid .cvp-video-card:nth-child(7) { animation-delay: 0.14s; }
.videos-grid .cvp-video-card:nth-child(8) { animation-delay: 0.16s; }

/* ====================================
   Legacy .video-card override
   Keep for backwards compatibility
   ==================================== */
.video-card {
    border: none !important;
    box-shadow: none !important;
}
