/* Mobile Optimization CSS for HAROFA Website */
/* Enhances visibility and usability on mobile devices */

/* ===========================
   1. Base Mobile Improvements
   =========================== */

/* Improve tap targets - minimum 44px for touch */
@media (max-width: 767.98px) {
    /* Increase base font size for better readability */
    html {
        font-size: 16px;
    }

    body {
        -webkit-text-size-adjust: 100%;
        line-height: 1.6;
    }

    /* Improve paragraph readability */
    p {
        font-size: 1rem;
        line-height: 1.7;
    }

    /* Headings - scale down appropriately */
    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    h3, .h3 {
        font-size: 1.25rem;
    }

    h4, .h4 {
        font-size: 1.125rem;
    }

    h5, .h5 {
        font-size: 1rem;
    }

    h6, .h6 {
        font-size: 0.9rem;
    }
}

/* ===========================
   2. Header & Navigation
   =========================== */

@media (max-width: 1199.98px) {
    /* Logo size adjustment */
    .navbar-brand-item {
        max-height: 35px;
        width: auto;
    }

    /* Mobile menu improvements */
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
    }

    /* Improve navbar toggle button */
    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        min-width: 44px;
        min-height: 44px;
    }
}

@media (max-width: 767.98px) {
    /* Smaller logo for phones */
    .navbar-brand-item {
        max-height: 28px;
    }

    /* Header padding reduction */
    header .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Mobile navigation items */
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    [data-bs-theme="dark"] .navbar-nav .nav-link {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    /* Dropdown items touch-friendly */
    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    /* Hide language selector text on very small screens */
    #languageSwitcher .fa-globe + span,
    #languageSwitcher i + span:not(.visually-hidden) {
        display: none;
    }

    /* Compact header buttons */
    .nav .btn-sm {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
}

/* ===========================
   3. Buttons & Interactive Elements
   =========================== */

@media (max-width: 767.98px) {
    /* Ensure minimum touch target size */
    .btn {
        min-height: 44px;
        padding: 0.625rem 1rem;
        font-size: 0.95rem;
    }

    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
    }

    .btn-lg {
        min-height: 50px;
        padding: 0.75rem 1.25rem;
    }

    /* Full-width buttons on mobile */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Icon buttons */
    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===========================
   4. Cards & Content Blocks
   =========================== */

@media (max-width: 767.98px) {
    /* Card padding adjustment */
    .card-body {
        padding: 1rem;
    }

    /* Reduce card margins */
    .card {
        margin-bottom: 1rem;
    }

    /* Image cards */
    .card-img, .card-img-top {
        max-height: 200px;
        object-fit: cover;
    }
}

/* ===========================
   5. Tables - Horizontal Scroll
   =========================== */

@media (max-width: 767.98px) {
    /* Make tables horizontally scrollable */
    .table-responsive-mobile {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
        white-space: nowrap;
    }

    /* Table images */
    .table img {
        max-width: 60px;
        height: auto;
    }
}

/* ===========================
   6. Modals
   =========================== */

@media (max-width: 767.98px) {
    /* Full-screen modals on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.75rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    /* Modal close button */
    .modal-header .btn-close,
    .modal-header .btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ===========================
   7. Forms
   =========================== */

@media (max-width: 767.98px) {
    /* Form inputs touch-friendly */
    .form-control {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.625rem 0.75rem;
    }

    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    /* Form labels */
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.375rem;
    }

    /* Checkbox and radio larger */
    .form-check-input {
        width: 1.25em;
        height: 1.25em;
    }

    .form-check-label {
        padding-left: 0.25rem;
        font-size: 0.95rem;
    }
}

/* ===========================
   8. Footer
   =========================== */

@media (max-width: 767.98px) {
    footer {
        padding-top: 2rem;
    }

    footer .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Footer logo */
    footer .navbar-brand-item {
        max-height: 32px;
    }

    /* Contact info list */
    footer .list-group-item,
    footer li {
        font-size: 0.9rem;
        padding: 0.5rem 0;
    }

    /* Footer columns stack */
    footer .col-lg-5,
    footer .col-lg-6 {
        margin-bottom: 1.5rem;
    }

    /* Copyright text */
    footer .text-body {
        font-size: 0.85rem;
    }
}

/* ===========================
   9. Docs Pages Sidebar
   =========================== */

@media (max-width: 575.98px) {
    /* Hide only the "Doc nav" text and hamburger toggle */
    .page-wrapper > nav.navbar > .navbar-brand {
        display: none !important;
    }

    .page-wrapper > nav.navbar > .navbar-toggler {
        display: none !important;
    }

    /* Remove navbar styling but keep content */
    .page-wrapper > nav.navbar {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    /* Force show the collapsed content */
    .page-wrapper > nav.navbar .navbar-collapse {
        display: block !important;
    }

    /* Page wrapper layout */
    .page-wrapper {
        flex-direction: column;
    }

    /* Style the left-sidebar as horizontal navigation strip */
    .page-wrapper .left-sidebar {
        display: block !important;
        width: 100%;
        min-width: 100%;
        position: relative;
        top: 0;
        height: auto !important;
        border-right: none;
        border-bottom: 2px solid var(--bs-primary);
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        background-color: #f8f9fa;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }

    [data-bs-theme="dark"] .page-wrapper .left-sidebar {
        border-bottom-color: var(--bs-primary);
        background-color: #1a1a2e;
    }

    .left-sidebar .content {
        height: auto !important;
        padding: 0 !important;
    }

    /* Add "문서" label before pills */
    .left-sidebar .list-group::before {
        content: "문서";
        display: flex;
        align-items: center;
        padding: 0.4rem 0.5rem 0.4rem 0;
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--bs-primary);
        white-space: nowrap;
        flex-shrink: 0;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .left-sidebar .list-group {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center;
        gap: 0.375rem;
        padding: 0.5rem 0.75rem !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .left-sidebar .list-group::-webkit-scrollbar {
        display: none;
    }

    /* Hide category titles on mobile horizontal view */
    .left-sidebar b.text-uppercase {
        display: none !important;
    }

    /* Sidebar items as compact horizontal pills */
    .left-sidebar .list-group-item {
        padding: 0.35rem 0.625rem !important;
        font-size: 0.7rem !important;
        white-space: nowrap;
        border-radius: 0.75rem !important;
        background-color: white !important;
        border: 1px solid rgba(0, 0, 0, 0.12) !important;
        margin-bottom: 0 !important;
        flex-shrink: 0;
        color: #333;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
        transition: all 0.15s ease;
    }

    [data-bs-theme="dark"] .left-sidebar .list-group-item {
        background-color: rgba(255, 255, 255, 0.1) !important;
        border-color: rgba(255, 255, 255, 0.2) !important;
        color: rgba(255, 255, 255, 0.9);
    }

    .left-sidebar .list-group-item:hover,
    .left-sidebar .list-group-item.active {
        background-color: var(--bs-primary) !important;
        border-color: var(--bs-primary) !important;
        color: white !important;
    }

    /* Main content area */
    .main-content {
        padding: 1rem;
        max-width: 100%;
    }

    .main-content h1.h2 {
        font-size: 1.25rem;
    }

    /* Remove extra top margin from content */
    .main-content .mt-5 {
        margin-top: 1rem !important;
    }
}

/* ===========================
   10. Hero Sections
   =========================== */

@media (max-width: 767.98px) {
    /* Hero section padding */
    .hero-section,
    section.pt-lg-8,
    section.pt-xl-9 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    /* Hero text */
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    /* Hero images */
    .hero-image {
        max-width: 100%;
        height: auto;
    }
}

/* ===========================
   11. Product Dropdown (Navigation)
   =========================== */

@media (max-width: 1199.98px) {
    /* Product dropdown improvements */
    .dropdown-menu-size-xl {
        max-width: 100%;
        padding: 1rem;
    }

    /* Hide product images in dropdown on mobile */
    .dropdown-menu .col-xl-7.d-none.d-xl-block {
        display: none !important;
    }

    /* Product list full width */
    .dropdown-menu .col-xl-5 {
        width: 100%;
    }
}

/* ===========================
   12. Spacing Utilities Mobile
   =========================== */

@media (max-width: 767.98px) {
    /* Reduce excessive padding/margins */
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .py-6 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }

    .my-5 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }

    /* Section spacing */
    section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    /* Container padding */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ===========================
   13. Images & Media
   =========================== */

@media (max-width: 767.98px) {
    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* SVG decorations - hide or reduce */
    .position-absolute svg,
    .position-absolute img[src*="decoration"],
    .position-absolute img[src*="pattern"] {
        opacity: 0.3;
        transform: scale(0.5);
    }

    /* Video containers */
    .video-container {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 */
        height: 0;
        overflow: hidden;
    }

    .video-container iframe,
    .video-container video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

/* ===========================
   14. Accordion (Presentation Modal)
   =========================== */

@media (max-width: 767.98px) {
    .accordion-button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .accordion-body {
        padding: 0.75rem;
    }

    /* VOD buttons in accordion */
    .accordion .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
        margin: 0.125rem;
    }

    /* List items in accordion */
    .list-group-item {
        padding: 0.625rem 0.75rem;
        flex-wrap: wrap;
    }

    .list-group-item > div {
        margin-top: 0.5rem;
        width: 100%;
    }
}

/* ===========================
   15. Touch Scroll Improvements
   =========================== */

@media (max-width: 767.98px) {
    /* Smooth scrolling for overflowing content */
    .overflow-auto,
    .overflow-scroll {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Hide horizontal scroll bar but keep functionality */
    .hide-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .hide-scrollbar::-webkit-scrollbar {
        display: none;
    }
}

/* ===========================
   16. Print Styles (Mobile Share)
   =========================== */

@media print {
    /* Hide non-essential elements */
    header,
    footer,
    .navbar,
    .btn,
    .modal {
        display: none !important;
    }

    /* Ensure content prints well */
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
}

/* ===========================
   17. Dark Mode Mobile Adjustments
   =========================== */

@media (max-width: 767.98px) {
    [data-bs-theme="dark"] {
        /* Slightly brighter text for readability on mobile */
        --bs-body-color: #d0d0d0;
    }

    [data-bs-theme="dark"] .card {
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* ===========================
   18. Landscape Phone Adjustments
   =========================== */

@media (max-width: 767.98px) and (orientation: landscape) {
    /* Reduce header height in landscape */
    header {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .navbar-brand-item {
        max-height: 24px;
    }

    /* Modal max height in landscape */
    .modal-body {
        max-height: 50vh;
    }
}

/* ===========================
   19. Safe Area (Notch) Support
   =========================== */

@supports (padding: max(0px)) {
    @media (max-width: 767.98px) {
        body {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }

        header {
            padding-top: max(0.5rem, env(safe-area-inset-top));
        }

        footer {
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
    }
}

/* ===========================
   20. Loading & Skeleton States
   =========================== */

@media (max-width: 767.98px) {
    /* Skeleton loading animation */
    .skeleton {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: skeleton-loading 1.5s infinite;
    }

    @keyframes skeleton-loading {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }

    [data-bs-theme="dark"] .skeleton {
        background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
        background-size: 200% 100%;
    }
}
