/**
 * Additional Mobile-Specific CSS Fixes
 * Applies to common mobile viewport issues
 */

/* ===== MOBILE NAVBAR ENHANCEMENTS ===== */

/* Hide navbar on scroll (mobile only) */
.navbar {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}

@media (max-width: 767px) {
    .navbar {
        padding: 0.75rem 0 !important;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    /* Stack navigation items */
    .navbar-nav {
        display: flex;
        flex-direction: column;
        padding-top: 0.5rem;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    /* Language selector dropdown */
    #languageDropdown {
        width: 100%;
        text-align: left;
    }

    .dropdown-menu {
        width: 100%;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* ===== MAIN CONTENT AREA ===== */

main {
    margin-top: 80px; /* Account for fixed navbar */
}

@media (max-width: 767px) {
    main {
        margin-top: 70px;
        padding: 0 0.75rem;
    }
}

/* ===== FOOTER MOBILE ===== */

@media (max-width: 767px) {
    footer {
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
    }

    footer .row > div {
        margin-bottom: 1.5rem;
    }

    footer .row > div:last-child {
        margin-bottom: 0;
    }

    /* Footer text alignment */
    .footer-section h4 {
        font-size: 1.1rem;
    }

    .footer-section p {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    /* Social links sizing */
    .social-links .btn {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===== BUTTON AND FORM ENHANCEMENTS ===== */

@media (max-width: 767px) {
    .btn {
        font-size: 0.95rem;
        padding: 0.6rem 1.2rem;
        min-height: 44px; /* Touch target */
        border-radius: 8px;
    }

    .btn-lg {
        padding: 0.8rem 1.5rem;
        min-height: 48px;
    }

    .btn-sm {
        padding: 0.4rem 0.8rem;
        min-height: 40px;
    }

    /* Full-width buttons */
    .btn-block {
        width: 100%;
        display: block;
    }

    /* Ensure form controls are touch-friendly */
    .form-control,
    .form-select,
    textarea {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.75rem;
        min-height: 44px;
        border-radius: 8px;
    }

    /* Label sizing */
    label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
        font-weight: 500;
    }

    /* Form group spacing */
    .form-group,
    .mb-3 {
        margin-bottom: 1.5rem !important;
    }

    /* Input group on mobile */
    .input-group {
        flex-wrap: wrap;
    }

    .input-group > .form-control,
    .input-group > .form-select {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ===== CARD LAYOUTS ===== */

@media (max-width: 767px) {
    .card {
        margin-bottom: 1.25rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .card-body {
        padding: 1.25rem;
    }

    .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .card-text {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    /* Image cards */
    .card-img-top {
        height: 200px;
        object-fit: cover;
        border-radius: 12px 12px 0 0;
    }
}

/* ===== GRID LAYOUTS ===== */

@media (max-width: 767px) {
    /* Bootstrap grid fixes */
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* All columns full width on mobile */
    .col-sm-6,
    .col-md-6,
    .col-lg-4,
    .col-lg-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Custom grid containers */
    .grid-container,
    .grid-2,
    .grid-3,
    .grid-4 {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 1rem;
        width: 100%;
    }
}

/* ===== HERO SECTIONS ===== */

@media (max-width: 767px) {
    .hero,
    .hero-section {
        padding: 2rem 1rem !important;
        min-height: auto;
        background-size: cover;
        background-position: center;
    }

    .hero h1,
    .hero-section h1 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 1rem;
    }

    .hero p,
    .hero-section p {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    /* Hero search */
    .hero-search {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .hero-search input,
    .hero-search select {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px;
    }

    .hero-search button {
        width: 100%;
        padding: 0.75rem 1.5rem;
    }
}

/* ===== MODAL MOBILE ===== */

@media (max-width: 767px) {
    .modal-dialog {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
    }

    .modal-content {
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }

    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    .modal-body {
        padding: 1.5rem 1rem;
        max-height: calc(100vh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 1rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
}

/* ===== ALERT BOXES ===== */

@media (max-width: 767px) {
    .alert {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
        font-size: 0.95rem;
    }

    .alert-icon {
        margin-right: 0.75rem;
    }
}

/* ===== PAGINATION MOBILE ===== */

@media (max-width: 767px) {
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* Hide page numbers, show only prev/next */
    .page-item:not(.prev):not(.next):not(.active) .page-link {
        display: none;
    }
}

/* ===== TABLE MOBILE ===== */

@media (max-width: 767px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }

    table {
        width: 100%;
        font-size: 0.85rem;
        border-collapse: collapse;
    }

    table thead {
        background: rgba(0, 0, 0, 0.05);
    }

    table th,
    table td {
        padding: 0.75rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    table th {
        font-weight: 600;
        text-align: left;
    }

    /* Stack table cells on very small screens */
    @media (max-width: 480px) {
        table {
            font-size: 0.8rem;
        }

        table th,
        table td {
            padding: 0.5rem;
        }
    }
}

/* ===== BACK TO TOP BUTTON ===== */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.back-to-top.show {
    display: flex;
}

@media (max-width: 480px) {
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }
}

/* ===== BREADCRUMB MOBILE ===== */

@media (max-width: 767px) {
    .breadcrumb {
        padding: 0.5rem 0;
        margin-bottom: 1rem;
    }

    .breadcrumb-item {
        font-size: 0.85rem;
    }

    .breadcrumb-item::before {
        content: '/';
        margin: 0 0.25rem;
    }
}

/* ===== BADGE SIZING ===== */

@media (max-width: 767px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .badge-lg {
        font-size: 0.9rem;
        padding: 0.5rem 0.8rem;
    }
}

/* ===== SPACING UTILITIES MOBILE ===== */

@media (max-width: 767px) {
    /* Reduce large spacing on mobile */
    .py-5,
    .py-md-5 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }

    .px-5,
    .px-md-5 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .m-5,
    .m-md-5 {
        margin: 1.5rem !important;
    }

    .my-5,
    .my-md-5 {
        margin-top: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Reduce gaps */
    .gap-4,
    .gap-5 {
        gap: 1rem !important;
    }
}

/* ===== TYPOGRAPHY MOBILE ===== */

@media (max-width: 767px) {
    h1 {
        font-size: 1.5rem;
        line-height: 1.2;
    }

    h2 {
        font-size: 1.25rem;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.1rem;
        line-height: 1.4;
    }

    h4,
    h5,
    h6 {
        font-size: 1rem;
    }

    p {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    small,
    .small {
        font-size: 0.85rem;
    }

    .lead {
        font-size: 1.1rem;
    }
}

/* ===== LOADING STATES ===== */

@media (max-width: 767px) {
    .spinner-border,
    .spinner-grow {
        width: 2rem;
        height: 2rem;
    }

    .spinner-border-sm,
    .spinner-grow-sm {
        width: 1.5rem;
        height: 1.5rem;
    }
}

/* ===== TOUCH FEEDBACK ===== */

@media (max-width: 767px) {
    button,
    a.btn,
    .btn,
    input[type="button"],
    input[type="submit"] {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        transition: background-color 0.2s ease, transform 0.2s ease;
    }

    button:active,
    a.btn:active,
    .btn:active {
        transform: scale(0.98);
    }
}

/* ===== SAFE AREA SUPPORT (for notch devices) ===== */

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

        .navbar {
            padding-left: max(0, env(safe-area-inset-left));
            padding-right: max(0, env(safe-area-inset-right));
        }

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