/**
 * RVKAI Content Modal Viewer Styles
 * Modal overlay for viewing recommended content
 */

/* ============================================
   MODAL OVERLAY
   ============================================ */

.rvkai-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.rvkai-modal.rvkai-modal-open {
    opacity: 1;
    visibility: visible;
}

/* Backdrop */
.rvkai-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Body scroll lock */
body.rvkai-modal-body-open {
    overflow: hidden;
}

/* ============================================
   MODAL CONTAINER
   ============================================ */

/* CSS Variables for modal dimensions (can be overridden via inline styles) */
.rvkai-modal {
    --rvkai-modal-width: 100%;
    --rvkai-modal-height: 100%;
    --rvkai-modal-max-width: 100%;
    --rvkai-modal-max-height: 100%;
    --rvkai-modal-border-radius: 0;
}

.rvkai-modal-container {
    position: relative;
    width: var(--rvkai-modal-width);
    height: var(--rvkai-modal-height);
    max-width: var(--rvkai-modal-max-width);
    max-height: var(--rvkai-modal-max-height);
    background: #ffffff;
    border-radius: var(--rvkai-modal-border-radius);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.98);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Fullscreen mode (default) - no shadow needed */
.rvkai-modal[data-fullscreen="true"] .rvkai-modal-container {
    box-shadow: none;
}

.rvkai-modal.rvkai-modal-open .rvkai-modal-container {
    transform: scale(1);
}

/* Video mode - 800px max-width with 16:9 aspect ratio */
.rvkai-modal.rvkai-modal-video-mode .rvkai-modal-container {
    max-width: 800px;
    width: 90%;
    height: auto;
    max-height: 90vh;
}

/* Video mode backdrop - 55% opacity per user decision */
.rvkai-modal.rvkai-modal-video-mode .rvkai-modal-backdrop {
    background: rgba(0, 0, 0, 0.55);
}

/* ============================================
   MODAL HEADER
   ============================================ */

.rvkai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    /* Use theme brand color - inherits from rvkai-chat-container CSS variables */
    background: var(--rvk-header-bg, var(--rvk-primary, var(--rvk-brand-primary, #0891b2)));
    color: #ffffff;
    flex-shrink: 0;
    gap: 10px;
}

.rvkai-modal-header-left {
    flex-shrink: 0;
}

.rvkai-modal-back-to-chat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rvkai-modal-back-to-chat:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.rvkai-modal-back-to-chat i {
    font-size: 12px;
}

.rvkai-modal-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.rvkai-modal-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rvkai-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Time Indicator */
.rvkai-modal-time-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
}

.rvkai-modal-time-indicator i {
    font-size: 11px;
    opacity: 0.8;
}

.rvkai-modal-time-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.rvkai-modal-external,
.rvkai-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 14px;
}

.rvkai-modal-external:hover,
.rvkai-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
    color: #ffffff;
    transform: scale(1.05);
}

.rvkai-modal-close:hover {
    /* Use a darker shade of theme color for close button */
    background: var(--rvk-brand-primary-active, rgba(0, 0, 0, 0.3));
}

/* ============================================
   MODAL BODY
   ============================================ */

.rvkai-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

/* Loading State */
.rvkai-modal-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #ffffff;
    color: #6b7280;
    font-size: 14px;
    z-index: 10;
}

.rvkai-modal-loading i {
    font-size: 32px;
    color: var(--rvk-brand-primary, #0891b2);
}

/* Content Area */
.rvkai-modal-content {
    width: 100%;
    height: 100%;
}

/* ============================================
   IFRAME CONTENT
   ============================================ */

.rvkai-modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

/* ============================================
   VIDEO CONTENT
   ============================================ */

.rvkai-modal-video-wrapper {
    position: relative;
    width: 100%;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
}

/* Fallback for older browsers without aspect-ratio support */
@supports not (aspect-ratio: 16 / 9) {
    .rvkai-modal-video-wrapper {
        height: 0;
        padding-bottom: 56.25%; /* 9/16 = 0.5625 */
    }

    .rvkai-modal-video-wrapper iframe,
    .rvkai-modal-video-wrapper video {
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Video mode body */
.rvkai-modal.rvkai-modal-video-mode .rvkai-modal-body {
    background: #000000;
}

.rvkai-modal.rvkai-modal-video-mode .rvkai-modal-video-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
}

/* Video wrapper in video mode - ensure 16:9 is maintained */
.rvkai-modal.rvkai-modal-video-mode .rvkai-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.rvkai-modal-video {
    width: 100%;
    height: 100%;
}

.rvkai-modal-video-native {
    object-fit: contain;
}

/* ============================================
   ERROR STATE
   ============================================ */

.rvkai-modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    color: #6b7280;
}

.rvkai-modal-error i {
    font-size: 48px;
    color: #ef4444;
    margin-bottom: 16px;
}

.rvkai-modal-error p {
    margin: 0;
    font-size: 14px;
}

.rvkai-modal-error a {
    color: #0891b2;
    text-decoration: none;
    font-weight: 500;
}

.rvkai-modal-error a:hover {
    text-decoration: underline;
}

/* ============================================
   MODAL FOOTER
   ============================================ */

.rvkai-modal-footer {
    display: none;
    padding: 6px 12px;
    background: var(--rvk-header-bg, var(--rvk-brand-primary, #0891b2));
    text-align: center;
    flex-shrink: 0;
}

.rvkai-modal-swipe-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
}

.rvkai-modal-swipe-hint i {
    animation: rvkai-bounce-hint 1.5s ease-in-out infinite;
}

@keyframes rvkai-bounce-hint {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .rvkai-modal-header {
        padding: 6px 10px;
        gap: 6px;
    }

    .rvkai-modal-title-text {
        font-size: 12px;
    }

    .rvkai-modal-back-to-chat span {
        display: none;
    }

    .rvkai-modal-back-to-chat {
        padding: 8px 10px;
    }

    .rvkai-modal-time-indicator {
        padding: 4px 8px;
        font-size: 10px;
    }

    .rvkai-modal-external,
    .rvkai-modal-close {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .rvkai-modal-footer {
        display: block;
    }
}

@media (max-width: 480px) {
    .rvkai-modal-header {
        padding: 6px 8px;
    }

    .rvkai-modal-title {
        font-size: 12px;
    }

    .rvkai-modal-time-indicator {
        display: none;
    }

    .rvkai-modal-external {
        display: none;
    }
    
    /* Full screen on mobile */
    .rvkai-modal-container {
        border-radius: 0 !important;
    }
}

/* ============================================
   DARK THEME SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    .rvkai-modal-container {
        background: #1a1a2e;
    }

    .rvkai-modal-body {
        background: #0f0f1a;
    }

    .rvkai-modal-loading {
        background: #1a1a2e;
        color: #9ca3af;
    }

    .rvkai-modal-iframe {
        background: #1a1a2e;
    }

    .rvkai-modal-error {
        color: #9ca3af;
    }
}

/* ============================================
   RECOMMENDATION TYPE ICONS
   ============================================ */

.rvk-recommendation-item[data-type="blog"] .rvk-recommendation-type-icon::before {
    content: "\f15c"; /* fa-file-lines */
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
}

.rvk-recommendation-item[data-type="video"] .rvk-recommendation-type-icon::before {
    content: "\f04b"; /* fa-play */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.rvk-recommendation-item[data-type="page"] .rvk-recommendation-type-icon::before {
    content: "\f0f6"; /* fa-file */
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
}

/* Type badge styling */
.rvk-recommendation-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--rvk-primary-light, rgba(8, 145, 178, 0.1));
    color: var(--rvk-primary, #0891b2);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rvk-recommendation-type i {
    font-size: 9px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes rvkai-modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes rvkai-modal-scale-in {
    from {
        transform: scale(0.95) translateY(20px);
    }
    to {
        transform: scale(1) translateY(0);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .rvkai-modal,
    .rvkai-modal-container {
        transition: none;
    }
}

