/* ========================================
   CONCH ADMIN - RESPONSIVE STYLES
   Mobile-First Responsive CSS
   Breakpoints: 480px, 768px, 1024px
   ======================================== */

/* ========================================
   1. MOBILE NAVIGATION (HAMBURGER MENU)
   ======================================== */

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: #6366f1;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    position: relative;
    transition: all 0.3s ease;
}

.mobile-menu-btn span::before,
.mobile-menu-btn span::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background: white;
    transition: all 0.3s ease;
}

.mobile-menu-btn span::before {
    top: -8px;
}

.mobile-menu-btn span::after {
    top: 8px;
}

.mobile-menu-btn.active span {
    background: transparent;
}

.mobile-menu-btn.active span::before {
    top: 0;
    transform: rotate(45deg);
}

.mobile-menu-btn.active span::after {
    top: 0;
    transform: rotate(-45deg);
}

.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding-top: 70px;
    pointer-events: none;
}

.mobile-nav.active {
    right: 0;
    pointer-events: auto;
}

.mobile-nav .nav-links {
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.mobile-nav .nav-link {
    width: 100%;
    padding: 16px 20px;
    border-radius: 0;
    border-bottom: 1px solid #f1f5f9;
    justify-content: flex-start;
}

.mobile-nav .nav-link:hover {
    background: #f8fafc;
}

.mobile-nav .nav-link.active {
    background: #eef2ff;
    border-left: 4px solid #6366f1;
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

body.no-scroll {
    overflow: hidden;
}

/* ========================================
   2. RESPONSIVE BREAKPOINTS
   ======================================== */

/* Mobile: < 768px */
@media (max-width: 767px) {
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    body {
        width: 100% !important;
    }
    
    /* Show mobile navigation */
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .mobile-nav {
        display: block !important;
    }
    
    .nav-overlay {
        display: block !important;
    }
    
    /* Hide desktop navigation */
    .top-nav .nav-links {
        display: none !important;
    }
    
    .nav-container {
        justify-content: center !important;
        padding: 0 1rem !important;
    }
    
    .top-nav {
        padding: 0 1rem !important;
    }
    
    /* Container & Spacing */
    .main-content,
    .container {
        padding: 1rem !important;
    }
    
    .page-header h1 {
        font-size: 22px !important;
    }
    
    .page-header p {
        font-size: 13px !important;
    }
    
    /* Stats Grid - Single Column */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Content Grid - Single Column */
    .content-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Form Grid - Single Column */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .form-group.full-width {
        grid-column: 1;
    }
    
    /* Tables - Scrollable */
    .data-table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
    }
    
    .data-table thead,
    .data-table tbody,
    .data-table tr {
        display: table !important;
        width: 100% !important;
    }
    
    .data-table th,
    .data-table td {
        padding: 12px 8px !important;
        font-size: 13px !important;
    }
    
    /* Table Containers */
    #users-table-container,
    #events-table-container,
    #detail-content {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Buttons - Larger Touch Targets */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .btn i {
        width: 18px;
        height: 18px;
    }
    
    /* Card Actions - Stack Vertically */
    .card-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .card-actions .btn {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Stat Cards */
    .stat-card {
        min-width: 100% !important;
        width: 100% !important;
    }
    
    /* Content Cards */
    .content-card,
    .card {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Card Header */
    .card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    
    .card-title {
        margin-bottom: 0.5rem !important;
    }
    
    /* Modal - Full Width */
    .modal {
        max-width: 95%;
        max-height: 95vh;
        margin: 20px;
    }
    
    .modal-content {
        max-width: 100%;
    }
    
    /* Toggle Groups - Wrap */
    .toggle-group {
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    
    .toggle-btn {
        flex: 1 1 45% !important;
        min-width: 120px !important;
        justify-content: center !important;
        padding: 10px 14px !important;
    }
    
    /* Radio Group - Stack */
    .radio-group {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .radio-option {
        width: 100% !important;
    }
    
    .radio-label {
        width: 100% !important;
    }
    
    /* Location Presets - 1 Column */
    .location-presets {
        grid-template-columns: 1fr !important;
    }
    
    /* Preset Buttons */
    .preset-btn {
        width: 100% !important;
    }
    
    /* User Selection */
    .user-selection {
        padding: 0.75rem !important;
        width: 100% !important;
    }
    
    .user-list {
        max-height: 250px !important;
        width: 100% !important;
    }
    
    .user-item {
        padding: 14px 12px !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .user-checkbox {
        width: 22px !important;
        height: 22px !important;
        flex-shrink: 0 !important;
    }
    
    .user-info {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .user-name,
    .user-email {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    /* Photos Grid - 2 Columns on Mobile */
    .photos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    /* Property Grid - Single Column */
    .property-grid {
        grid-template-columns: 1fr;
    }
    
    /* Search Bar */
    .search-bar {
        margin-bottom: 1rem;
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Detail View */
    .detail-view {
        margin-top: 1rem;
    }
    
    /* Header */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .user-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin: 0;
    }
    
    .danger-zone {
        flex-direction: column;
        width: 100%;
    }
    
    .danger-zone .btn {
        width: 100%;
    }
    
    /* Back Button */
    .back-button {
        padding: 12px 16px;
    }
    
    /* Photo Actions */
    .photo-actions {
        flex-direction: column;
        gap: 6px;
    }
    
    .action-btn {
        width: 100%;
        padding: 10px;
    }
    
    /* Toast */
    .toast-container {
        right: 12px;
        left: 12px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    /* Nav Brand - Smaller on Mobile */
    .nav-brand {
        font-size: 18px !important;
    }
    
    /* Prevent any element from causing horizontal scroll */
    * {
        max-width: 100vw;
    }
    
    .main-content > *,
    .container > * {
        max-width: 100% !important;
    }
    
    /* User table row actions */
    .data-table td:last-child {
        white-space: normal !important;
    }
    
    /* Make action buttons wrap */
    .data-table td .btn {
        margin-bottom: 4px;
        font-size: 12px !important;
        padding: 8px 12px !important;
        min-height: auto !important;
    }
    
    /* Table links should not have forced min sizes */
    .data-table a,
    .data-table button {
        min-height: auto !important;
        min-width: auto !important;
    }
    
    /* Quick links grid */
    .quick-links {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .quick-link {
        padding: 1rem 1.25rem !important;
    }
}

/* Small Mobile: < 480px */
@media (max-width: 479px) {
    /* Even more compact */
    .main-content,
    .container {
        padding: 0.75rem !important;
    }
    
    .page-header h1 {
        font-size: 20px !important;
    }
    
    .card,
    .content-card {
        padding: 1rem !important;
    }
    
    .card-header,
    .card-body {
        padding: 1rem !important;
    }
    
    /* Single column photo grid */
    .photos-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Smaller stat cards */
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-value {
        font-size: 28px !important;
    }
    
    /* Modal footer buttons stack */
    .modal-footer {
        flex-direction: column !important;
    }
    
    .modal-footer .btn {
        width: 100% !important;
    }
    
    /* Toggle buttons full width */
    .toggle-btn {
        flex: 1 1 100% !important;
        min-width: 100% !important;
    }
    
    /* Force single column for everything */
    .stats-grid,
    .content-grid,
    .form-grid,
    .location-presets,
    .photos-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Tablet: 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Stats Grid - 2 Columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Content Grid - 2 Columns */
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Photos Grid - 3 Columns */
    .photos-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Location Presets - 2 Columns */
    .location-presets {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: > 1024px */
@media (min-width: 1024px) {
    /* Hide mobile menu on desktop */
    .mobile-menu-btn,
    .mobile-nav,
    .nav-overlay {
        display: none !important;
    }
}

/* ========================================
   3. TABLE SCROLL WRAPPER
   ======================================== */

.table-scroll-wrapper {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

@media (max-width: 767px) {
    .table-scroll-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    .table-scroll-wrapper::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.05));
        pointer-events: none;
    }
}

/* ========================================
   4. ACCESSIBILITY & TOUCH IMPROVEMENTS
   ======================================== */

@media (max-width: 767px) {
    /* Touch target sizes - only for standalone interactive elements, NOT inline links/buttons */
    .btn,
    .mobile-menu-btn,
    .nav-link,
    .toggle-btn,
    .preset-btn,
    .action-btn {
        min-height: 44px;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-height: 20px;
        min-width: 20px;
    }
    
    select {
        min-height: 44px;
    }
    
    /* Larger form inputs - prevent iOS zoom */
    .form-input,
    .form-select,
    .form-textarea,
    .search-input {
        font-size: 16px;
        padding: 12px 14px;
    }
    
    /* Better tap targets for nav links */
    .mobile-nav .nav-link {
        min-height: 48px;
        padding: 14px 16px;
    }
}

/* ========================================
   5. PRINT STYLES
   ======================================== */

@media print {
    .mobile-menu-btn,
    .mobile-nav,
    .nav-overlay,
    .top-nav,
    .danger-zone,
    .btn-danger,
    .action-btn.delete {
        display: none !important;
    }
    
    .main-content,
    .container {
        padding: 0;
    }
    
    .card,
    .content-card {
        page-break-inside: avoid;
    }
}

/* ========================================
   6. LANDSCAPE ORIENTATION FIXES
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .mobile-nav {
        padding-top: 60px;
    }
    
    .mobile-menu-btn {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}
