/* ================================================
   MOBILE UX ENHANCEMENTS
   ================================================ */

/* === DESKTOP KONSPEKTAS HEADER === */
.konspektas-header {
    padding: 20px 20px 24px;
    margin-bottom: 32px;
}

.konspektas-header #header-title {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 4px !important;
    /* Artimesnis tarpas tarp h1 ir h2 */
    max-width: none !important;
}

.konspektas-header #header-subtitle {
    text-align: left !important;
    margin-left: 0 !important;
    margin-top: 0 !important;
    color: var(--accent-color) !important;
    /* Mėlyna accent spalva */
    font-weight: 500 !important;
    /* Lengvesnis font */
    opacity: 0.9;
    /* Subtilus fade effect */
}

/* === 1. STICKY HEADER FOR MOBILE === */
@media (max-width: 768px) {
    .konspektas-header {
        position: sticky;
        top: 0;
        z-index: 40;
        background-color: var(--card-bg-color);
        backdrop-filter: blur(40px) saturate(180%);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        border-bottom: 1px solid var(--border-color);
        padding: 16px 20px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
        transition: all 0.3s ease;
    }

    .konspektas-header.scrolled {
        padding: 12px 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }

    /* Breadcrumb Navigation */
    .breadcrumb-nav {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin-bottom: 8px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .breadcrumb-nav::-webkit-scrollbar {
        display: none;
    }

    .breadcrumb-nav a {
        color: var(--accent-color);
        text-decoration: none;
        transition: opacity 0.2s;
    }

    .breadcrumb-nav a:hover {
        opacity: 0.7;
    }

    .breadcrumb-separator {
        color: var(--text-secondary);
        opacity: 0.5;
    }

    .breadcrumb-current {
        color: var(--text-primary);
        font-weight: 500;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Compact header titles */
    #header-title {
        font-size: 1.3rem;
        margin: 0;
        line-height: 1.2;
        color: var(--text-headline);
    }

    #header-subtitle {
        font-size: 0.9rem;
        margin: 4px 0 0 0;
        color: var(--text-secondary);
        font-weight: 400;
    }

    /* Adjust back button for sticky header */
    .back-button {
        top: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
        z-index: 50;
    }
}

/* === 2. BOTTOM NAVIGATION TOOLBAR === */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 45;
    background-color: var(--card-bg-color);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    transition: transform 0.3s ease;
}

.mobile-bottom-nav.hidden {
    transform: translateY(100%);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    /* Add padding to main content to account for bottom nav */
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    min-width: 60px;
}

.nav-item i {
    font-size: 1.3rem;
    transition: transform 0.2s ease;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item:active i {
    transform: scale(1.1);
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item.active i {
    color: var(--accent-color);
}

/* === 3. TOUCH-FRIENDLY IMPROVEMENTS === */
@media (max-width: 768px) {

    /* Larger touch targets */
    .derivation-card,
    .topic-card {
        padding: 28px 20px;
        min-height: 100px;
    }

    /* Better spacing for touch */
    .topic-grid {
        gap: 16px;
        grid-template-columns: 1fr;
    }

    /* Larger buttons */
    button,
    .btn-primary,
    .btn-secondary {
        min-height: 48px;
        padding: 14px 24px;
        font-size: 1rem;
    }

    /* Quiz options - larger touch targets */
    .quiz-option {
        padding: 18px 16px;
        min-height: 56px;
        font-size: 1rem;
    }

    /* Modal close button - larger */
    #close-modal,
    .floating-close-btn {
        width: 44px;
        height: 44px;
        padding: 12px;
    }

    /* Remove hover effects on mobile, use active states */
    .topic-card:hover,
    .derivation-card:hover {
        transform: none;
        box-shadow: var(--glass-shadow);
    }

    .topic-card:active,
    .derivation-card:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* === 4. SWIPE GESTURE INDICATORS === */
.swipe-indicator {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    font-size: 3rem;
    color: var(--accent-color);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .swipe-indicator {
        display: block;
    }
}

.swipe-indicator.left {
    left: 20px;
}

.swipe-indicator.right {
    right: 20px;
}

.swipe-indicator.show {
    opacity: 0.7;
}

/* === 5. MODAL IMPROVEMENTS FOR MOBILE === */
@media (max-width: 768px) {
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-height: 95vh;
        border-radius: 24px 24px 0 0;
        width: 100%;
        max-width: 100%;
    }

    .modal.is-open .modal-content {
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .modal-header {
        padding: 20px 20px 16px;
        border-bottom: 1px solid var(--border-color);
    }

    #modal-content-container {
        padding: 20px;
        /* Add extra padding for safe area */
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* === 6. IMPROVED SCROLLING === */
@media (max-width: 768px) {

    /* Smooth momentum scrolling */
    .modal-content,
    #modal-content-container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Hide scrollbar on mobile for cleaner look */
    #modal-content-container {
        scrollbar-width: none;
    }

    #modal-content-container::-webkit-scrollbar {
        display: none;
    }
}

/* === 7. FLOATING ACTION BUTTON (Quick Navigation) === */
.fab-container {
    display: none;
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
    z-index: 40;
}

@media (max-width: 768px) {
    .fab-container {
        display: block;
    }
}

.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-color-hover) 100%);
    border: none;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.fab-button:active {
    transform: scale(0.9);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    background-color: var(--card-bg-color);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-menu.open {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.fab-menu-item:active {
    background-color: rgba(0, 122, 255, 0.1);
}

.fab-menu-item i {
    color: var(--accent-color);
    font-size: 1.1rem;
    width: 20px;
}

/* === 8. PULL-TO-REFRESH INDICATOR === */
.pull-to-refresh {
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    padding: 12px 24px;
    background-color: var(--card-bg-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0 0 16px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    .pull-to-refresh {
        display: flex;
        align-items: center;
        gap: 8px;
    }
}

.pull-to-refresh.show {
    opacity: 1;
}

.pull-to-refresh i {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* === 9. RESPONSIVE PRICING MODAL === */
@media (max-width: 768px) {
    .pricing-modal-content {
        border-radius: 24px 24px 0 0;
    }

    .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
        padding: 0 4px;
    }

    .pricing-card {
        margin: 0;
    }
}

/* === 10. SAFE AREA SUPPORT (iOS notch, etc.) === */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* === 11. HAPTIC FEEDBACK VISUAL CUE === */
@media (max-width: 768px) {
    .haptic-feedback {
        position: relative;
    }

    .haptic-feedback::after {
        content: '';
        position: absolute;
        inset: -4px;
        border-radius: inherit;
        background: var(--accent-color);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.1s ease;
    }

    .haptic-feedback.active::after {
        opacity: 0.2;
        animation: pulse 0.3s ease;
    }

    @keyframes pulse {

        0%,
        100% {
            opacity: 0;
            transform: scale(1);
        }

        50% {
            opacity: 0.2;
            transform: scale(1.05);
        }
    }
}

/* === 12. IMPROVED FORM INPUTS ON MOBILE === */
@media (max-width: 768px) {

    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        min-height: 48px;
        padding: 12px 16px;
    }

    select {
        font-size: 16px !important;
        min-height: 48px;
        padding: 12px 16px;
    }
}

/* === 13. LANDSCAPE MODE OPTIMIZATIONS === */
@media (max-width: 768px) and (orientation: landscape) {
    .konspektas-header {
        padding: 8px 16px;
    }

    #header-title {
        font-size: 1.1rem;
    }

    #header-subtitle {
        display: none;
    }

    .mobile-bottom-nav {
        padding: 4px 0 4px;
    }

    .nav-item {
        padding: 6px 8px;
        font-size: 0.65rem;
    }

    .nav-item i {
        font-size: 1.1rem;
    }
}

/* === 14. REDUCED MOTION SUPPORT === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .modal.is-open .modal-content {
        animation: none;
    }

    .swipe-indicator {
        display: none !important;
    }
}