/* ====================================
   MOBILE RESPONSIVE OPTIMIZATION
   Want My Diamond - Comprehensive Mobile Styles
   ==================================== */

/* ==================== BASE MOBILE STYLES ==================== */

/* Ensure smooth scrolling and prevent horizontal overflow */
html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    font-size: 16px; /* Base font size for mobile readability */
}

/* Touch-friendly tap targets (minimum 44x44px) */
button, .btn, a.btn, .nav-link, .navbar-toggler {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* ==================== NAVIGATION (Mobile) ==================== */

@media (max-width: 991.98px) {
    /* Mobile navbar adjustments */
    .navbar-brand img {
        height: 80px !important; /* Smaller logo on mobile */
        width: auto;
    }
    
    .navbar-nav {
        padding: 1rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        margin: 0.25rem 0;
        font-size: 1.1rem;
    }
    
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    /* Mobile menu toggle button */
    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        font-size: 1.5rem;
        border: 2px solid rgba(0,0,0,0.1);
    }
}

/* ==================== TYPOGRAPHY (Mobile) ==================== */

@media (max-width: 767.98px) {
    h1, .h1 {
        font-size: 1.75rem;
    }
    
    h2, .h2 {
        font-size: 1.5rem;
    }
    
    h3, .h3 {
        font-size: 1.25rem;
    }
    
    h4, .h4 {
        font-size: 1.1rem;
    }
    
    .display-5 {
        font-size: 2rem;
    }
    
    .lead {
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 1.75rem !important;
        margin-bottom: 2rem !important;
    }
}

/* ==================== BUTTONS & FORMS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        width: 100%; /* Full-width buttons on mobile */
        margin-bottom: 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: 0.375rem !important;
        margin-bottom: 0.5rem;
    }
    
    /* Form inputs */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
    }
    
    textarea.form-control {
        min-height: 120px;
    }
}

/* ==================== CARDS & CONTAINERS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Stack columns on mobile */
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
}

/* ==================== GALLERY & IMAGES (Mobile) ==================== */

@media (max-width: 767.98px) {
    .product-image {
        height: 200px;
    }
    
    /* Gallery grid adjustments */
    .gallery-item {
        margin-bottom: 1.5rem;
    }
    
    /* Image carousels */
    .carousel-item img {
        max-height: 300px;
        object-fit: contain;
    }
    
    /* Product detail images */
    .product-detail-image {
        max-height: 350px;
        width: 100%;
        object-fit: contain;
    }
}

/* ==================== TABLES (Mobile) ==================== */

@media (max-width: 767.98px) {
    .table-responsive {
        border: 0;
    }
    
    /* Stack table on very small screens */
    .table-mobile-stack thead {
        display: none;
    }
    
    .table-mobile-stack tbody,
    .table-mobile-stack tr,
    .table-mobile-stack td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-stack tr {
        margin-bottom: 1.5rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 1rem;
    }
    
    .table-mobile-stack td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
        padding: 0.5rem 0;
    }
    
    .table-mobile-stack td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-left: 0.5rem;
        font-weight: bold;
        text-align: left;
    }
}

/* ==================== MODALS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 1rem;
    }
    
    .modal-header, .modal-footer {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* ==================== MESSAGING INTERFACE (Mobile) ==================== */

@media (max-width: 767.98px) {
    .chat-container {
        height: calc(100vh - 250px) !important;
        min-height: 400px;
    }
    
    .message-input-container {
        padding: 1rem;
    }
    
    .message-bubble {
        max-width: 85%;
        word-wrap: break-word;
    }
    
    .conversation-list-item {
        padding: 1rem;
    }
    
    .avatar-circle {
        width: 45px !important;
        height: 45px !important;
        font-size: 1rem !important;
    }
}

/* ==================== FOOTER (Mobile) ==================== */

@media (max-width: 767.98px) {
    .footer {
        padding: 2rem 0 1rem;
        margin-top: 2rem;
    }
    
    .footer .col-md-4 {
        margin-bottom: 2rem;
        text-align: center;
    }
    
    .footer h5 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
}

/* ==================== ADMIN PANEL (Mobile) ==================== */

@media (max-width: 991.98px) {
    /* Sidebar mobile toggle */
    #sidebar-wrapper {
        position: fixed;
        z-index: 1000;
        transition: margin 0.3s ease-in-out;
    }
    
    #wrapper.toggled #sidebar-wrapper {
        box-shadow: 2px 0 5px rgba(0,0,0,0.3);
    }
    
    #page-content-wrapper {
        width: 100%;
    }
    
    /* Admin cards */
    .admin-card {
        margin-bottom: 1rem;
    }
    
    /* Admin tables */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stats cards */
    .stats-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 767.98px) {
    /* Compact admin header */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .btn-toolbar {
        margin-top: 1rem;
        width: 100%;
    }
    
    .btn-toolbar .btn-group {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-toolbar .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ==================== JEWELRY DETAILS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .jewelry-details {
        padding: 1rem;
        margin: 0.5rem 0;
    }
    
    .detail-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    .detail-value {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }
    
    .price {
        font-size: 1.5rem;
        margin: 1rem 0;
    }
}

/* ==================== ALERTS & TOASTS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .alert {
        font-size: 0.95rem;
        padding: 0.75rem 1rem;
    }
    
    .toast {
        max-width: calc(100vw - 2rem);
        font-size: 0.9rem;
    }
}

/* ==================== CUSTOM REQUEST FORM (Mobile) ==================== */

@media (max-width: 767.98px) {
    .custom-request-form .form-group {
        margin-bottom: 1.5rem;
    }
    
    .file-upload-area {
        padding: 2rem 1rem;
        min-height: 150px;
    }
    
    .uploaded-file-preview {
        max-width: 100%;
        height: auto;
    }
}

/* ==================== GALLERY FILTERS (Mobile) ==================== */

@media (max-width: 767.98px) {
    .filter-group {
        margin-bottom: 1rem;
    }
    
    .filter-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-buttons .btn {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: auto;
    }
    
    .gallery-search-bar {
        width: 100% !important;
        margin-bottom: 1rem;
    }
}

/* ==================== PAGINATION (Mobile) ==================== */

@media (max-width: 767.98px) {
    .pagination {
        font-size: 0.9rem;
    }
    
    .page-item .page-link {
        padding: 0.5rem 0.75rem;
    }
    
    /* Show fewer page numbers on mobile */
    .pagination .page-item:not(.active):not(:first-child):not(:last-child):nth-child(n+5) {
        display: none;
    }
}

/* ==================== HERO SECTION (Mobile) ==================== */

@media (max-width: 767.98px) {
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .hero-image {
        max-height: 250px;
        object-fit: cover;
    }
}

/* ==================== PERFORMANCE OPTIMIZATIONS ==================== */

/* Reduce animations on mobile for better performance */
@media (max-width: 767.98px) {
    .card:hover {
        transform: none;
    }
    
    * {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
}

/* ==================== LANDSCAPE ORIENTATION ==================== */

@media (max-width: 767.98px) and (orientation: landscape) {
    .navbar-brand img {
        height: 60px !important;
    }
    
    .modal-body {
        max-height: 50vh;
    }
    
    .chat-container {
        height: calc(100vh - 200px) !important;
    }
}

/* ==================== VERY SMALL DEVICES (<375px) ==================== */

@media (max-width: 374.98px) {
    body {
        font-size: 14px;
    }
    
    .navbar-brand img {
        height: 60px !important;
    }
    
    h1, .h1 {
        font-size: 1.5rem;
    }
    
    h2, .h2 {
        font-size: 1.25rem;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

/* ==================== ACCESSIBILITY IMPROVEMENTS ==================== */

/* Improve touch targets for better accessibility */
@media (max-width: 767.98px) {
    a, button, input, select, textarea {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    /* Ensure sufficient color contrast on mobile */
    .text-muted {
        color: #6c757d !important;
    }
    
    /* Better focus indicators for keyboard navigation */
    a:focus, button:focus, input:focus, select:focus, textarea:focus {
        outline: 3px solid rgba(0, 123, 255, 0.5);
        outline-offset: 2px;
    }
}

/* ==================== LOADING & SKELETON SCREENS ==================== */

@media (max-width: 767.98px) {
    .loading-skeleton {
        animation: pulse 1.5s ease-in-out infinite;
    }
    
    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .navbar, .footer, .btn, .sidebar, #sidebar-wrapper {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .container {
        width: 100%;
        max-width: 100%;
    }
}
