﻿/**
 * RESPONSIVE DESIGN & MOBILE
 * ===========================
 * 
 * Mobile and responsive design rules
 * Consolidated mobile optimizations for all components
 */

/* Mobile Top Navigation */
@media (max-width: 768px) {
    .top-nav {
        font-size: 0.8125rem;
    }

        .top-nav .container {
            padding-left: 1rem;
            padding-right: 1rem;
        }

        .top-nav .flex {
            gap: 0.75rem;
        }

    .top-nav-link {
        padding: 0.375rem 0.5rem;
    }

    .top-nav-brand {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .top-nav-brand {
        display: none;
    }
}

/* Mobile Page Headers */
@media (max-width: 768px) {
    .page-header-enhanced {
        margin-bottom: 2rem;
        padding: 1.5rem 0;
    }

    .title-with-accent {
        gap: 1.25rem;
    }

    .title-accent-circle {
        width: 60px;
        height: 60px;
        box-shadow: 0 6px 20px rgba(0,0,0,0.1), 0 0 0 6px var(--bg-tint);
    }

    .section-title {
        font-size: 2.25rem;
    }

    .section-subtitle-enhanced {
        font-size: 1rem;
    }

        .section-subtitle-enhanced::before,
        .section-subtitle-enhanced::after {
            display: none;
        }

    .summary-badge-enhanced {
        padding: 0.5rem 1.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .title-accent-circle {
        width: 50px;
        height: 50px;
    }

    .section-title {
        font-size: 2rem;
    }

    .section-subtitle-enhanced {
        font-size: 0.875rem;
        letter-spacing: 0.1em;
    }
}

/* Mobile Actions */
@media (max-width: 768px) {
    .header-actions {
        gap: 0.75rem;
    }

    .header-action-btn {
        width: 2.75rem;
        height: 2.75rem;
    }

    .bottom-actions-content {
        padding: 1.25rem;
        margin: 0 0.5rem;
    }

    .status-toast {
        right: 0.5rem;
        top: 5rem;
        max-width: calc(100vw - 1rem);
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 0.5rem;
    }

    .header-action-btn {
        width: 2.5rem;
        height: 2.5rem;
    }

        .header-action-btn svg {
            width: 1.25rem;
            height: 1.25rem;
        }

    .bottom-actions {
        margin: 1.5rem 0;
        padding: 0 0.5rem;
    }

    .bottom-actions-content {
        padding: 1rem;
    }

    .bottom-actions-title span {
        font-size: 0.875rem;
    }

    .status-toast {
        right: 0.25rem;
        top: 4rem;
        padding: 0.75rem 1rem;
        max-width: calc(100vw - 0.5rem);
    }

    #status-message {
        font-size: 0.8125rem;
    }
}

/* Mobile Page Navigation */
@media (max-width: 768px) {
    .page-navigation-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 1.5rem;
        align-items: center;
        justify-items: center;
    }

    .nav-section.nav-center {
        grid-column: 1 / -1;
        grid-row: 1;
        justify-self: center;
        width: 100%;
        justify-content: center;
        padding: 1rem 0;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.15);
        margin-bottom: 0.5rem;
        gap: 0.75rem;
    }

    .nav-section.nav-left {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
        width: 100%;
    }

    .nav-section.nav-right {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
        width: 100%;
    }

    .nav-section .btn-outline,
    .nav-section .btn-primary {
        padding: 1rem 1.5rem;
        font-weight: 600;
        border-radius: 2rem;
        min-width: 120px;
        justify-content: center;
    }

    .nav-section .header-action-btn {
        width: 3rem;
        height: 3rem;
        margin: 0 0.5rem;
    }
}

@media (max-width: 480px) {
    .page-navigation {
        padding: 0 0.5rem;
    }

    .page-navigation-content {
        gap: 1.25rem;
    }

    .nav-section.nav-center {
        padding: 0.75rem 0;
        margin-bottom: 0.25rem;
        gap: 0.5rem;
    }

    .nav-section .header-action-btn {
        width: 2.75rem;
        height: 2.75rem;
        margin: 0 0.375rem;
    }

        .nav-section .header-action-btn svg {
            width: 1.25rem;
            height: 1.25rem;
        }

    .nav-section .btn-outline,
    .nav-section .btn-primary {
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
        min-width: 100px;
        border-radius: 1.5rem;
    }
}

@media (max-width: 375px) {
    .nav-section .header-action-btn {
        width: 2.5rem;
        height: 2.5rem;
        margin: 0 0.25rem;
    }

    .nav-section .btn-outline,
    .nav-section .btn-primary {
        font-size: 0.875rem;
        padding: 0.75rem 0.875rem;
        min-width: 85px;
    }
}

/* Mobile Section Numbers */
@media (max-width: 768px) {
    .section-number {
        width: 45px;
        height: 45px;
        font-size: 1.375rem;
        margin-right: 0.875rem;
    }
    
    /* Center section numbers when stacked vertically on mobile */
    .section-card .flex-col .section-number {
        margin-right: 0;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 480px) {
    .section-number {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
        margin-right: 0.75rem;
        border-width: 2px;
    }
    
    /* Ensure proper spacing for stacked layout on small mobile */
    .section-card .flex-col .section-number {
        margin-right: 0;
        margin-bottom: 0.75rem;
    }
}

/* Mobile Book Lightbox */
@media (max-width: 767px) {
    /* Fix navigation buttons positioning on mobile */
    .book-lightbox-nav {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 50px !important;
        height: 50px !important;
        z-index: 2002 !important;
    }

    .book-lightbox-prev {
        left: 10px !important; /* Move inside viewport */
    }

    .book-lightbox-next {
        right: 10px !important; /* Move inside viewport */
    }

    /* Fix counter positioning on mobile */
    .book-lightbox-counter {
        position: absolute !important;
        top: 20px !important; /* Move down from top */
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 2002 !important;
        background: rgba(0,0,0,0.8) !important;
        color: white !important;
        padding: 0.5rem 1rem !important;
        border-radius: 1rem !important;
        font-size: 0.875rem !important;
        font-weight: 600 !important;
    }

    /* Ensure lightbox content is properly positioned */
    .book-lightbox-content {
        position: relative !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        max-width: 90vw !important;
        max-height: 90vh !important;
        padding: 60px 20px 20px 20px !important; /* Add padding for counter */
    }

    /* Ensure image doesn't overlap with controls */
    .book-lightbox-image {
        max-width: calc(100vw - 120px) !important; /* Account for nav buttons */
        max-height: calc(90vh - 100px) !important; /* Account for counter and caption */
    }

    /* Make sure caption is visible and positioned correctly */
    .book-lightbox-caption {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        max-width: calc(100vw - 40px) !important;
        background: rgba(0,0,0,0.9) !important;
        padding: 1rem !important;
        border-radius: 0.75rem !important;
        z-index: 2002 !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .book-lightbox-nav {
        width: 40px !important;
        height: 40px !important;
    }

    .book-lightbox-prev {
        left: 5px !important;
    }

    .book-lightbox-next {
        right: 5px !important;
    }

    .book-lightbox-counter {
        top: 10px !important;
        font-size: 0.75rem !important;
        padding: 0.375rem 0.75rem !important;
    }

    .book-lightbox-image {
        max-width: calc(100vw - 90px) !important;
    }
}

@media (max-width: 375px) {
    .book-lightbox-image {
        max-width: 180px;
        max-height: 30vh;
    }

    .book-lightbox-caption {
        padding: 1.25rem;
        margin: 1rem 0.25rem 0;
    }

        .book-lightbox-caption h4 {
            font-size: 1.25rem;
        }

        .book-lightbox-caption p {
            font-size: 0.9375rem;
        }
}

@media (max-width: 768px) and (min-width: 481px) {
    .book-lightbox-image {
        max-width: 280px;
        max-height: 45vh;
    }

    .book-lightbox-caption {
        padding: 1.25rem 1.75rem;
        max-width: 85%;
    }

        .book-lightbox-caption h4 {
            font-size: 1.5rem;
        }

        .book-lightbox-caption p {
            font-size: 1.0625rem;
        }
}

/* Landscape mobile orientation */
@media (max-width: 812px) and (max-height: 480px) and (orientation: landscape) {
    .book-lightbox-overlay {
        flex-direction: row;
        align-items: center;
        padding: 1rem;
    }

    .book-lightbox-content {
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
        max-width: 100%;
        max-height: 100%;
    }

    .book-lightbox-image {
        max-width: 200px;
        max-height: 60vh;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .book-lightbox-caption {
        position: static;
        transform: none;
        margin: 0;
        max-width: 50%;
        flex-grow: 1;
    }

    .book-lightbox-nav {
        display: none;
    }

    .book-lightbox-prev,
    .book-lightbox-next {
        display: none;
    }

    .book-lightbox-counter {
        display: none;
    }
}

/* Mobile Carousel Responsive */
@media (max-width: 768px) {
    .carousel-wrapper {
        padding: 1rem;
        gap: 0.5rem;
    }

    .carousel-nav {
        width: 40px;
        height: 40px;
    }

    .carousel-caption {
        padding: 2rem 1rem 1rem;
    }

        .carousel-caption h4 {
            font-size: 1.125rem;
        }

        .carousel-caption p {
            font-size: 0.75rem;
        }

    .lightbox-content {
        max-height: 70vh;
    }

    .lightbox-nav {
        width: 50px;
        height: 50px;
    }

    .lightbox-prev {
        left: -60px;
    }

    .lightbox-next {
        right: -60px;
    }

    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .lightbox-counter {
        top: 15px;
        left: 15px;
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .lightbox-caption {
        bottom: 15px;
        padding: 0.75rem 1.5rem;
        max-width: 90%;
    }

        .lightbox-caption h4 {
            font-size: 1.25rem;
        }

        .lightbox-caption p {
            font-size: 0.875rem;
        }
}

@media (max-width: 480px) {
    .carousel-track {
        aspect-ratio: 4/3;
    }

    .carousel-nav {
        width: 35px;
        height: 35px;
    }

        .carousel-nav svg {
            width: 18px;
            height: 18px;
        }

    .carousel-dots {
        gap: 0.375rem;
        margin-top: 1rem;
    }

    .carousel-dot {
        width: 10px;
        height: 10px;
    }

    .lightbox-overlay {
        padding: 1rem;
    }

    .lightbox-content {
        max-height: 60vh;
        flex-direction: column;
    }

    .lightbox-nav {
        position: static;
        transform: none;
        margin: 0.5rem;
    }

    .lightbox-caption {
        position: static;
        transform: none;
        margin-top: 1rem;
        max-width: 100%;
    }
}

/* Mobile Audio Panel */
@media (max-width: 768px) {
    .audio-panel-content {
        padding: 1rem;
    }

    .audio-title {
        font-size: 0.875rem;
    }

        .audio-title svg {
            width: 1rem;
            height: 1rem;
        }

    .audio-player-wrapper {
        padding: 0.75rem;
    }

    .audio-player {
        height: 2rem;
    }

    .voice-selection {
        width: 100%;
        justify-content: space-between;
    }

    .audio-select {
        flex: 1;
        max-width: none;
        margin-left: 0.5rem;
    }

    .audio-action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .audio-panel-content {
        padding: 0.75rem;
    }

    .audio-controls .flex {
        gap: 0.75rem;
    }

    .audio-action-btn {
        font-size: 0.8125rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Mobile Profile Page */
@media (max-width: 768px) {
    .profile-avatar {
        width: 3rem;
        height: 3rem;
        font-size: 1.125rem;
    }

    .bookmark-link {
        padding: 0.625rem;
    }

    .quick-action {
        padding: 0.625rem;
        font-size: 0.875rem;
    }

    .form-section-header h3 {
        font-size: 1.125rem;
    }

    .profile-form-actions {
        flex-direction: column;
    }

        .profile-form-actions .btn-primary,
        .profile-form-actions .btn-outline {
            width: 100%;
            justify-content: center;
        }
}

/* Mobile Font Size Overrides */
@media (max-width: 480px) {
    :root {
        --text-xl: 1.125rem; /* Reduced from 1.25rem for tablets */
        --text-lg: 1.05rem;     /* Reduced from 1.125rem for tablets */
        --text-2xl: 1.475rem; /* Reduced from 1.5rem for tablets */
        --text-3xl: 1.625rem; /* Reduced from 1.875rem for tablets */
        --text-4xl: 2rem;    /* Reduced from 2.25rem for tablets */
    }
}

/* Mobile UI Card Conversation Layout */
@media (max-width: 768px) {
    /* Change conversation lines from horizontal to vertical layout on mobile */
    .ui-card .flex.gap-3, .alert.alert-warning .flex.gap-3 {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    /* Remove minimum width constraint on labels for mobile */
    .ui-card .flex.gap-3 .min-w-16m, .alert.alert-warning  .flex.gap-3 .min-w-16m {
        min-width: unset;
        margin-bottom: 0.25rem;
    }



}

