/* =====================================================
   SCORM SLIDESHOW PLAYER - MAIN STYLES
   Professional 16:9 Slide Player with Dark Theme
   Updated: Left Sidebar, Slim Bottom Bar
   ===================================================== */

/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent: #8b5cf6;
    --accent-hover: #a78bfa;

    --bg-dark: #0f0f1a;
    --bg-darker: #080810;
    --bg-card: rgba(20, 20, 35, 0.95);
    --bg-glass: rgba(30, 30, 50, 0.8);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b7280;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(99, 102, 241, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--primary-glow);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --sidebar-width: 220px;
    --footer-height: 40px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Container */
.player-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    position: relative;
}

/* =====================================================
   SIDEBAR TOGGLE BUTTON
   ===================================================== */
.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    background: rgba(30, 30, 50, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    opacity: 0.6;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    opacity: 1;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

/* =====================================================
   LEFT SIDEBAR
   ===================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: 56px;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 10px;
}

.sidebar-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Thumbnail List */
.thumbnail-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thumbnail-list::-webkit-scrollbar {
    width: 6px;
}

.thumbnail-list::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.thumbnail-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.thumbnail:hover {
    border-color: var(--primary);
    transform: scale(1.02);
}

.thumbnail.active {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.thumbnail.has-game::after {
    content: '🎮';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    background: var(--accent);
    padding: 2px 4px;
    border-radius: 4px;
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 190;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =====================================================
   MAIN CONTENT AREA
   ===================================================== */
.player-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    padding-bottom: calc(var(--footer-height) + 10px);
    position: relative;
    overflow: hidden;
}

/* 16:9 Slide Container */
.slide-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-container {
    position: relative;
    width: 100%;
    max-width: calc((100vh - var(--footer-height) - 20px) * 16 / 9);
    max-height: calc(100vh - var(--footer-height) - 20px);
    aspect-ratio: 16 / 9;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

/* Slide Image */
.slide-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.slide-image.loaded {
    opacity: 1;
}

.slide-image.fade-out {
    opacity: 0;
}

/* Loading Spinner */
.slide-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.slide-loading.active {
    display: block;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.large {
    width: 64px;
    height: 64px;
    border-width: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* App Loading Screen */
.app-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-darker);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-slow);
}

.app-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.app-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.app-loading-content span {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
}

/* Navigation Arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 50;
    opacity: 0.5;
}

.nav-arrow:hover {
    background: var(--primary);
    border-color: var(--primary);
    opacity: 1;
    box-shadow: var(--shadow-glow);
    transform: translateY(-50%) scale(1.05);
}

.nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.nav-arrow:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-arrow.prev {
    left: 20px;
}

.nav-arrow.next {
    right: 20px;
}

/* =====================================================
   GAME POPUP OVERLAY
   ===================================================== */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 300;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.game-overlay.active {
    display: flex;
}

/* Show navigation arrows above game overlay */
.game-overlay.active~.player-main .nav-arrow,
.player-container:has(.game-overlay.active) .nav-arrow {
    z-index: 350;
    opacity: 0.7;
}

/* Game Popup Container - 16:9 format, 90% of screen size */
.game-popup {
    position: relative;
    /* 90% of viewport width, but constrained by height for 16:9 */
    width: min(90vw, calc(90vh * 16 / 9));
    height: min(90vh, calc(90vw * 9 / 16));
    /* Enforce exact 16:9 aspect ratio */
    aspect-ratio: 16 / 9;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 80px rgba(99, 102, 241, 0.4);
    border: 1px solid var(--border-color);
    /* Zoom-in animation */
    animation: gamePopupZoomIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform-origin: center center;
}

/* Zoom-in animation for game popup */
@keyframes gamePopupZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Popup Header - Hidden (removed from design) */
.game-popup-header {
    display: none;
}

/* Game Frame - fills entire popup for true 16:9 */
.game-frame-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
}

.game-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Game Loading Indicator */
.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg-dark);
    z-index: 5;
    transition: opacity var(--transition-normal);
}

.game-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-loading span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Continue Button - Hidden (disabled by design) */
.game-continue-btn {
    display: none;
}

.game-continue-btn:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--accent-hover));
    box-shadow: var(--shadow-glow), 0 0 30px rgba(99, 102, 241, 0.5);
    transform: translateX(-50%) scale(1.05);
}

.game-continue-btn:active {
    transform: translateX(-50%) scale(0.98);
}

/* =====================================================
   SLIM BOTTOM BAR
   ===================================================== */
.player-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

/* Progress Bar at Top of Footer */
.progress-bar-container {
    width: 100%;
    height: 3px;
    background: var(--bg-dark);
    flex-shrink: 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width var(--transition-normal);
}

/* Navigation Controls */
.nav-controls {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 20px;
}

.page-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 60px;
    justify-content: center;
}

.page-current {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.page-separator {
    color: var(--text-muted);
}

.page-total {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Control Buttons */
.control-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.control-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* =====================================================
   FULLSCREEN STYLES
   ===================================================== */
.player-container.fullscreen .player-footer {
    opacity: 1;
    transition: opacity var(--transition-normal);
}

.player-container.fullscreen .player-main {
    padding: 10px;
    padding-bottom: calc(var(--footer-height) + 10px);
}

.player-container.fullscreen .slide-container {
    max-width: calc((100vh - var(--footer-height) - 20px) * 16 / 9);
    max-height: calc(100vh - var(--footer-height) - 20px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.player-container.fullscreen .nav-arrow {
    opacity: 0.5;
}

.player-container.fullscreen:hover .nav-arrow {
    opacity: 0.7;
}

.player-container.fullscreen .sidebar-toggle {
    opacity: 0.3;
}

.player-container.fullscreen:hover .sidebar-toggle {
    opacity: 0.6;
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 18px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    border-color: var(--success);
}

.toast.warning {
    border-color: var(--warning);
}

.toast.error {
    border-color: var(--error);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =====================================================
   ORIENTATION HINT OVERLAY
   ===================================================== */
.orientation-hint {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.orientation-hint.active {
    display: flex;
}

.orientation-hint-content {
    text-align: center;
    max-width: 300px;
    padding: 30px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.orientation-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: rotateHint 2s ease-in-out infinite;
}

@keyframes rotateHint {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }
}

.orientation-hint-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.orientation-hint-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.orientation-hint-close {
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.orientation-hint-close:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

/* =====================================================
   RESPONSIVE ADJUSTMENTS
   ===================================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 180px;
    }

    .nav-arrow {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .nav-arrow.prev {
        left: 10px;
    }

    .nav-arrow.next {
        right: 10px;
    }

    .sidebar-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Mobile Game Popup - Same as desktop: 90% of screen, 16:9 format */
    .game-overlay {
        padding: 10px;
    }

    .game-popup {
        /* Override to maintain 16:9 at 90% of screen on mobile too */
        width: min(90vw, calc(90vh * 16 / 9));
        height: min(90vh, calc(90vw * 9 / 16));
        aspect-ratio: 16 / 9;
        max-width: none;
        max-height: none;
        border-radius: var(--radius-md);
        border: 1px solid var(--border-color);
    }

    .game-popup-header {
        padding: 8px 12px;
    }

    .game-continue-btn {
        padding: 6px 12px;
        font-size: 10px;
    }
}

/* =====================================================
   MOBILE IMPROVEMENTS - Small Screens
   ===================================================== */
@media (max-width: 480px) {
    :root {
        --footer-height: 50px;
    }

    .nav-arrow {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .nav-arrow.prev {
        left: 5px;
    }

    .nav-arrow.next {
        right: 5px;
    }

    .sidebar {
        width: 85vw;
        max-width: 280px;
    }

    .sidebar-toggle {
        width: 38px;
        height: 38px;
        top: 8px;
        left: 8px;
    }

    .control-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .nav-controls {
        gap: 12px;
        padding: 0 12px;
    }

    .page-info {
        font-size: 0.8rem;
        min-width: 50px;
    }

    .game-popup {
        /* Maintain 16:9 at 90% of screen on small mobile too */
        width: min(90vw, calc(90vh * 16 / 9));
        height: min(90vh, calc(90vw * 9 / 16));
        aspect-ratio: 16 / 9;
    }

    .game-continue-btn {
        padding: 12px 32px;
        font-size: 14px;
    }

    .toast {
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    .toast-container {
        right: 10px;
        top: 10px;
    }
}

/* =====================================================
   PORTRAIT ORIENTATION SUPPORT
   ===================================================== */
@media (orientation: portrait) and (max-width: 768px) {
    .slide-container {
        max-width: 100%;
        max-height: calc(100vw * 9 / 16);
    }

    .player-main {
        padding: 5px;
        padding-bottom: calc(var(--footer-height) + 5px);
    }

    .nav-arrow {
        opacity: 0.7;
    }
}

/* =====================================================
   TOUCH DEVICE OPTIMIZATIONS
   ===================================================== */
@media (hover: none) and (pointer: coarse) {
    .nav-arrow {
        opacity: 0.6;
    }

    .nav-arrow:hover {
        transform: translateY(-50%);
    }

    .control-btn:hover {
        background: transparent;
        border-color: var(--border-color);
        box-shadow: none;
    }

    .control-btn:active {
        background: var(--primary);
        border-color: var(--primary);
    }

    .thumbnail:hover {
        transform: none;
    }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {

    .player-footer,
    .nav-arrow,
    .sidebar,
    .sidebar-toggle {
        display: none !important;
    }

    .player-main {
        padding: 0;
    }

    .slide-container {
        max-width: 100%;
        box-shadow: none;
        border: none;
    }
}