/**
 * Guided Learning Responsive Styles
 * Ensures all components work across all devices
 */

/* ============================================
   GUIDED LEARNING CHAT INTEGRATION
   ============================================ */

/* Main button - responsive positioning */
#guided-learning-btn {
    position: absolute;
    z-index: 30;
    transition: all 0.3s ease;
}

/* Mobile adjustments */
@media (max-width: 640px) {
    #guided-learning-btn {
        width: 40px;
        height: 40px;
        left: -8px;
        bottom: calc(100% + 8px);
    }
    
    #guided-learning-menu {
        width: calc(100vw - 32px);
        max-width: 320px;
        left: -8px;
        bottom: calc(100% + 56px);
    }
    
    #gl-path-selector-modal .bg-dark-800 {
        max-height: 95vh;
        margin: 8px;
    }
}

@media (min-width: 641px) {
    #guided-learning-btn {
        width: 48px;
        height: 48px;
        left: 0;
        bottom: calc(100% + 12px);
    }
    
    #guided-learning-menu {
        width: 384px;
        left: 0;
        bottom: calc(100% + 72px);
    }
}

/* Session indicator - responsive */
#gl-session-indicator {
    max-width: 280px;
}

@media (max-width: 640px) {
    #gl-session-indicator {
        left: 8px;
        bottom: 96px;
        max-width: 240px;
    }
}

/* ============================================
   VIDEO PLAYER RESPONSIVE
   ============================================ */

.gl-video-player-container {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
}

.gl-video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.gl-video-wrapper > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Video controls responsive */
.gl-video-controls {
    padding: 12px;
}

@media (min-width: 640px) {
    .gl-video-controls {
        padding: 16px;
    }
}

/* Progress bar touch-friendly */
.gl-progress-container {
    padding: 8px 0;
    cursor: pointer;
}

.gl-progress-bar {
    height: 4px;
    transition: height 0.2s ease;
}

.gl-progress-container:hover .gl-progress-bar,
.gl-progress-container:active .gl-progress-bar {
    height: 8px;
}

/* Control buttons touch-friendly */
.gl-video-controls button {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 640px) {
    .gl-video-controls button {
        min-width: 40px;
        min-height: 40px;
    }
}

/* Volume slider mobile */
@media (max-width: 640px) {
    .gl-volume-slider {
        display: none;
    }
}

/* ============================================
   ADMIN DASHBOARD - GUIDED LEARNING TAB
   ============================================ */

/* Stats grid responsive */
#guided-learning-stats .grid {
    gap: 12px;
}

@media (max-width: 640px) {
    #guided-learning-stats .grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    #guided-learning-stats .grid > div {
        padding: 12px 8px;
    }
    
    #guided-learning-stats .text-2xl {
        font-size: 1.25rem;
    }
}

/* Path cards responsive */
#guided-learning-paths-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#guided-learning-paths-list > div {
    padding: 16px;
}

@media (max-width: 640px) {
    #guided-learning-paths-list > div {
        padding: 12px;
    }
    
    #guided-learning-paths-list .flex.items-start {
        flex-direction: column;
        gap: 12px;
    }
    
    #guided-learning-paths-list .flex.items-center.gap-2 {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Filters responsive */
.guided-learning-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .guided-learning-filters {
        flex-direction: column;
    }
    
    .guided-learning-filters > * {
        width: 100%;
    }
}

/* Bulk actions bar */
#bulk-actions-container {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    #bulk-actions-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    #bulk-actions-container button {
        width: 100%;
        justify-content: center;
    }
}

/* Pagination responsive */
#guided-learning-pagination {
    margin-top: 16px;
}

@media (max-width: 640px) {
    #guided-learning-pagination .flex.items-center.justify-between {
        flex-direction: column;
        gap: 12px;
    }
}

/* ============================================
   PATH SELECTOR MODAL
   ============================================ */

#gl-path-selector-modal {
    padding: 16px;
}

#gl-path-selector-modal > div {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Search and filters */
#gl-path-selector-modal .flex.flex-col.sm\\:flex-row {
    gap: 12px;
}

@media (max-width: 640px) {
    #gl-path-selector-modal .flex.flex-col.sm\\:flex-row {
        flex-direction: column;
    }
    
    #gl-path-selector-modal select {
        width: 100%;
    }
}

/* Path cards in modal */
#gl-paths-container > div {
    padding: 16px;
}

@media (max-width: 640px) {
    #gl-paths-container > div {
        padding: 12px;
    }
    
    #gl-paths-container .flex.items-start.space-x-4 {
        flex-direction: column;
        gap: 12px;
    }
    
    #gl-paths-container button.px-4 {
        width: 100%;
        opacity: 1;
    }
}

/* ============================================
   QUIZ DISPLAY RESPONSIVE
   ============================================ */

.gl-quiz-container {
    max-width: 100%;
}

.gl-quiz-container .space-y-4 > div {
    padding: 16px;
}

@media (max-width: 640px) {
    .gl-quiz-container .space-y-4 > div {
        padding: 12px;
    }
}

/* Quiz options touch-friendly */
.gl-quiz-container label {
    padding: 12px;
    min-height: 48px;
    display: flex;
    align-items: center;
}

/* ============================================
   CONTENT NODE DISPLAY
   ============================================ */

.gl-content-node {
    max-width: 100%;
    overflow-x: auto;
}

.gl-content-node img {
    max-width: 100%;
    height: auto;
}

.gl-content-node pre {
    overflow-x: auto;
    max-width: 100%;
}

.gl-content-node table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

/* ============================================
   FORMULA NODE DISPLAY
   ============================================ */

.gl-formula-node {
    overflow-x: auto;
}

.gl-formula-node .katex-display {
    overflow-x: auto;
    max-width: 100%;
}

/* ============================================
   FLOWCHART NODE DISPLAY
   ============================================ */

.gl-flowchart-node {
    overflow-x: auto;
}

.gl-flowchart-node .mermaid {
    max-width: 100%;
}

/* ============================================
   PROGRESS INDICATOR
   ============================================ */

.gl-progress-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gl-progress-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.gl-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10B981, #34D399);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes gl-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gl-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gl-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.gl-animate-fade-in {
    animation: gl-fade-in 0.3s ease-out;
}

.gl-animate-slide-up {
    animation: gl-slide-up 0.4s ease-out;
}

.gl-animate-pulse {
    animation: gl-pulse 2s infinite;
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */

.dark .gl-video-controls {
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
}

.dark #bulk-actions-container {
    background: linear-gradient(to top, rgba(15,23,42,0.95), rgba(15,23,42,0.9));
    border-color: rgba(55,65,81,0.5);
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    #guided-learning-btn,
    #guided-learning-menu,
    #gl-session-indicator,
    .gl-video-controls {
        display: none !important;
    }
    
    .gl-video-player-container {
        page-break-inside: avoid;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states */
#guided-learning-btn:focus,
.gl-video-controls button:focus,
#gl-path-selector-modal button:focus {
    outline: 2px solid #10B981;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gl-animate-fade-in,
    .gl-animate-slide-up,
    .gl-animate-pulse {
        animation: none;
    }
    
    #guided-learning-btn,
    #guided-learning-menu,
    .gl-video-controls,
    .gl-progress-bar-fill {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    #guided-learning-btn {
        border: 2px solid white;
    }
    
    .gl-progress-bar {
        border: 1px solid white;
    }
}
