/* Mobile Responsive Optimizations - LaraClassificados */

/* Variables CSS para consistência */
:root {
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 992px;
    --touch-target-size: 44px;
    --mobile-padding: 1rem;
    --mobile-margin: 0.5rem;
}

/* Base Mobile-First Approach */
* {
    box-sizing: border-box;
}

/* Touch-friendly interactions */
.btn, .nav-link, .dropdown-item, .card, .form-control {
    min-height: var(--touch-target-size);
    touch-action: manipulation;
}

/* Mobile Navigation Improvements */
@media (max-width: 767.98px) {
    .navbar-brand img {
        height: 28px !important;
        max-width: 150px;
    }
    
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
        background: transparent;
        cursor: pointer;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
        outline: 2px solid rgba(255, 255, 255, 0.5);
    }
    
    .navbar-collapse {
        margin-top: 1rem !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding: 1rem !important;
        background-color: var(--bs-primary) !important;
        border-radius: 0.5rem !important;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
        min-height: 100px !important; /* ALTURA MÍNIMA PARA TESTE */
    }
    
    /* REGRA ULTRA ESPECÍFICA */
    body .navbar .container .navbar-collapse {
        background-color: var(--bs-primary) !important;
        border: none !important;
        min-height: auto !important;
    }
    
    /* FORÇA VISIBILIDADE DO MENU QUANDO ABERTO */
    .navbar-collapse.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        overflow: visible !important;
        position: relative !important;
        z-index: 1050 !important;
    }
    
    .navbar-collapse.show .navbar-nav {
        display: block !important;
    }
    
    .navbar-collapse.show .nav-item {
        display: block !important;
    }
    
    .navbar-collapse.show .nav-link {
        display: block !important;
    }
    
    .navbar-nav .nav-link {
        color: white !important;
        padding: 0.75rem 1rem;
        border-radius: 0.25rem;
        margin-bottom: 0.25rem;
        display: block;
    }
    
    .navbar-nav .nav-link:hover {
        background-color: rgba(255,255,255,0.1);
    }
    
    .dropdown-menu {
        background-color: rgba(255,255,255,0.95);
        border: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        margin-top: 0.5rem;
        position: static !important;
        transform: none !important;
        width: 100%;
        border-radius: 0.5rem;
        display: none; /* Escondido por padrão */
    }
    
    .dropdown-menu.show {
        display: block !important;
    }
    
    /* Dropdown toggle em mobile não deve ter seta */
    .dropdown-toggle::after {
        display: none;
    }
    
    .navbar-nav .nav-item {
        margin-bottom: 0.5rem;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        color: #333;
    }
    
    .dropdown-item:hover {
        background-color: rgba(0,0,0,0.05);
    }
}

/* Container and Layout Improvements */
@media (max-width: 767.98px) {
    .container {
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
    }
    
    .row {
        margin-left: calc(-1 * var(--mobile-margin));
        margin-right: calc(-1 * var(--mobile-margin));
    }
    
    .col, [class*="col-"] {
        padding-left: var(--mobile-margin);
        padding-right: var(--mobile-margin);
    }
}

/* Card Improvements for Mobile */
@media (max-width: 767.98px) {
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-title {
        font-size: 1.1rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }
    
    .card-text {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .card-img-top {
        height: 200px;
        object-fit: cover;
    }
}

/* Form Improvements for Mobile */
@media (max-width: 767.98px) {
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
        border-radius: 0.5rem;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        border-radius: 0.5rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        margin-bottom: 0.5rem;
        border-radius: 0.5rem !important;
    }
}

/* Table Responsiveness */
@media (max-width: 767.98px) {
    .table-responsive {
        border: none;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th, .table td {
        padding: 0.5rem;
        vertical-align: middle;
    }
    
    /* Stack table for very small screens */
    .table-stack {
        display: block;
    }
    
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody, .table-stack tr, .table-stack td {
        display: block;
        width: 100%;
    }
    
    .table-stack tr {
        border: 1px solid #dee2e6;
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        padding: 1rem;
        background: white;
    }
    
    .table-stack td {
        border: none;
        padding: 0.25rem 0;
        text-align: left !important;
    }
    
    .table-stack td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        width: 40%;
    }
}

/* Modal Improvements for Mobile */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    .modal-content {
        border-radius: 1rem;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 1rem;
        border-top: 1px solid #dee2e6;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Pagination Mobile Improvements */
@media (max-width: 767.98px) {
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-item .page-link {
        padding: 0.5rem 0.75rem;
        margin: 0.125rem;
        border-radius: 0.5rem;
        min-width: var(--touch-target-size);
        text-align: center;
    }
    
    /* Hide some pagination items on very small screens */
    .pagination .page-item:not(.active):not(.disabled):nth-child(n+6):nth-last-child(n+6) {
        display: none;
    }
}

/* Search and Filter Improvements */
@media (max-width: 767.98px) {
    .search-form {
        margin-bottom: 1rem;
    }
    
    .search-form .input-group {
        flex-direction: column;
    }
    
    .search-form .form-control {
        border-radius: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .search-form .btn {
        border-radius: 0.5rem;
        width: 100%;
    }
    
    .filter-section {
        background: #f8f9fa;
        padding: 1rem;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .filter-section .row > div {
        margin-bottom: 1rem;
    }
}

/* Breadcrumb Mobile Improvements */
@media (max-width: 767.98px) {
    .breadcrumb {
        background: transparent;
        padding: 0.5rem 0;
        margin-bottom: 1rem;
        font-size: 0.875rem;
        flex-wrap: wrap;
    }
    
    .breadcrumb-item {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Alert Improvements */
@media (max-width: 767.98px) {
    .alert {
        border-radius: 0.5rem;
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .alert-dismissible .btn-close {
        padding: 1rem;
        margin: -1rem -1rem -1rem auto;
    }
}

/* Loading States for Mobile */
.mobile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    flex-direction: column;
}

.mobile-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 1rem;
}

/* Accessibility Improvements */
@media (max-width: 767.98px) {
    /* Focus states for touch devices */
    .btn:focus, .form-control:focus, .nav-link:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    /* Skip link for screen readers */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 6px;
        background: #000;
        color: #fff;
        padding: 8px;
        text-decoration: none;
        border-radius: 4px;
        z-index: 1000;
    }
    
    .skip-link:focus {
        top: 6px;
    }
}

/* Specific Module Improvements */

/* Classifieds Mobile */
@media (max-width: 767.98px) {
    .classified-card {
        margin-bottom: 1rem;
    }
    
    .classified-card .card-img-top {
        height: 180px;
        object-fit: cover;
    }
    
    .classified-price {
        font-size: 1.25rem;
        font-weight: bold;
        color: #28a745;
    }
    
    .classified-location {
        font-size: 0.875rem;
        color: #6c757d;
    }
}

/* News Mobile */
@media (max-width: 767.98px) {
    .news-card {
        margin-bottom: 1rem;
    }
    
    .news-card .card-img-top {
        height: 160px;
        object-fit: cover;
    }
    
    .news-meta {
        font-size: 0.8rem;
        color: #6c757d;
        margin-bottom: 0.5rem;
    }
}

/* Videos Mobile */
@media (max-width: 767.98px) {
    .video-card {
        margin-bottom: 1rem;
    }
    
    .video-thumbnail {
        position: relative;
        height: 180px;
        overflow: hidden;
        border-radius: 0.5rem;
    }
    
    .video-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .video-play-btn {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        border: none;
        border-radius: 50%;
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}

/* Radio Mobile */
@media (max-width: 767.98px) {
    .radio-player {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #dee2e6;
        padding: 1rem;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .radio-controls {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .radio-controls .btn {
        width: auto;
        margin: 0 0.25rem;
        padding: 0.5rem 1rem;
    }
    
    .program-schedule {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 1rem;
    }
    
    .program-item {
        display: inline-block;
        min-width: 200px;
        margin-right: 1rem;
        padding: 1rem;
        background: white;
        border-radius: 0.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* Utility Classes for Mobile */
@media (max-width: 767.98px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-only {
        display: block !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .mobile-p-2 {
        padding: 0.5rem !important;
    }
}

/* Desktop-only utilities */
@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
    
    .desktop-hidden {
        display: none !important;
    }
}

/* Print Styles */
@media print {
    .navbar, .btn, .pagination, .modal, .alert-dismissible .btn-close {
        display: none !important;
    }
    
    .container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
}
