/*
 * CJG Transfer Hub - Comprehensive Mobile Styles
 * This file contains all mobile-specific optimizations
 */

/* ==========================================================================
   Mobile Base - Touch Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    /* Improve touch targets */
    button, .btn, a, input, select, textarea {
        min-height: 44px;
    }

    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }

    /* Better spacing */
    .site-main {
        padding-bottom: 80px;
    }
}

/* ==========================================================================
   Admin Layout - Sidebar + Content
   ========================================================================== */

@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    .admin-sidebar {
        display: none !important;
    }

    .admin-content {
        padding: 16px !important;
        min-height: auto !important;
    }

    .admin-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
        padding: 16px !important;
    }

    .admin-header h1 {
        font-size: 24px !important;
    }

    /* Top navigation bar */
    .top-nav {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 12px 16px !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .top-nav::-webkit-scrollbar {
        display: none;
    }

    .top-nav a {
        padding: 10px 16px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
}

/* ==========================================================================
   Dashboard Page
   ========================================================================== */

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .dashboard-card {
        padding: 20px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-value {
        font-size: 28px !important;
    }

    .stat-label {
        font-size: 13px !important;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .quick-action-btn {
        padding: 16px 12px !important;
        font-size: 13px !important;
    }

    .quick-action-icon {
        font-size: 24px !important;
    }
}

/* ==========================================================================
   Clients Page
   ========================================================================== */

@media (max-width: 768px) {
    .clients-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .client-card {
        padding: 16px !important;
    }

    .client-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .client-avatar {
        width: 50px !important;
        height: 50px !important;
        font-size: 18px !important;
    }

    .client-name {
        font-size: 18px !important;
    }

    .client-stats {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .client-stat {
        font-size: 12px !important;
        padding: 4px 10px !important;
    }

    .client-actions {
        width: 100% !important;
        justify-content: flex-start !important;
        margin-top: 12px !important;
    }
}

/* ==========================================================================
   Transfers Page
   ========================================================================== */

@media (max-width: 768px) {
    .transfers-grid {
        grid-template-columns: 1fr !important;
    }

    .transfer-card {
        padding: 16px !important;
    }

    .transfer-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .transfer-title {
        font-size: 16px !important;
    }

    .transfer-meta {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .transfer-actions {
        width: 100% !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .transfer-actions .btn {
        width: 100% !important;
    }

    /* Collapsible transfer items */
    .transfer-dropdown-header {
        padding: 16px !important;
    }

    .transfer-dropdown-content {
        padding: 12px 16px !important;
    }

    .file-list-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 12px !important;
    }

    .file-list-item .file-actions {
        width: 100% !important;
        justify-content: flex-start !important;
    }
}

/* ==========================================================================
   Upload Page
   ========================================================================== */

@media (max-width: 768px) {
    .upload-container {
        padding: 20px !important;
    }

    .upload-zone {
        padding: 30px 20px !important;
    }

    .upload-zone-icon {
        font-size: 48px !important;
    }

    .upload-zone-text {
        font-size: 16px !important;
    }

    .upload-zone-subtext {
        font-size: 13px !important;
    }

    .file-queue {
        gap: 12px !important;
    }

    .file-queue-item {
        padding: 12px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .file-info {
        width: 100% !important;
    }

    .file-name {
        font-size: 14px !important;
        word-break: break-all !important;
    }

    .file-progress {
        width: 100% !important;
    }
}

/* ==========================================================================
   Timesheet Page
   ========================================================================== */

@media (max-width: 768px) {
    .timesheet-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
        padding: 16px !important;
    }

    .timesheet-header h1 {
        font-size: 22px !important;
    }

    .timesheet-controls {
        width: 100% !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .timesheet-controls .btn {
        width: 100% !important;
    }

    .view-toggle {
        width: 100% !important;
    }

    .view-toggle .btn {
        flex: 1 !important;
    }

    .week-navigation {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .week-navigation span {
        font-size: 14px !important;
        text-align: center !important;
    }

    /* Day sections */
    .day-section {
        margin-bottom: 12px !important;
    }

    .day-header {
        padding: 12px 16px !important;
    }

    .day-name {
        font-size: 15px !important;
    }

    .day-date {
        font-size: 13px !important;
    }

    .day-total {
        font-size: 13px !important;
    }

    .day-entries {
        padding: 0 12px 12px !important;
    }

    /* Entry cards */
    .entry-card {
        padding: 12px !important;
    }

    .entry-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .entry-time {
        font-size: 13px !important;
    }

    .entry-description {
        font-size: 14px !important;
    }

    .entry-actions {
        width: 100% !important;
        margin-top: 12px !important;
    }

    /* Add entry modal */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 10px !important;
        padding: 20px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .modal-content h2 {
        font-size: 20px !important;
    }

    .form-row {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .form-row > * {
        width: 100% !important;
    }
}

/* ==========================================================================
   Galleries Page
   ========================================================================== */

@media (max-width: 768px) {
    .galleries-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .gallery-card {
        padding: 16px !important;
    }

    .gallery-preview {
        height: 150px !important;
    }

    .gallery-title {
        font-size: 16px !important;
    }

    .gallery-meta {
        font-size: 13px !important;
    }
}

/* ==========================================================================
   Single Gallery Page
   ========================================================================== */

@media (max-width: 768px) {
    .gallery-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
        padding: 16px !important;
    }

    .gallery-header h1 {
        font-size: 22px !important;
    }

    .gallery-actions {
        width: 100% !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .gallery-actions .btn {
        width: 100% !important;
    }

    .images-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .gallery-image-item {
        aspect-ratio: 1 !important;
    }

    /* Lightbox */
    .lightbox-content {
        padding: 10px !important;
    }

    .lightbox-image {
        max-height: 70vh !important;
    }

    .lightbox-nav {
        width: 40px !important;
        height: 40px !important;
        font-size: 20px !important;
    }

    .lightbox-close {
        top: 10px !important;
        right: 10px !important;
        width: 36px !important;
        height: 36px !important;
    }

    /* Upload modal */
    .upload-modal-content {
        width: 95% !important;
        padding: 20px !important;
        max-height: 85vh !important;
    }

    .preview-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .preview-item {
        height: 100px !important;
    }
}

/* ==========================================================================
   Client Portal Page
   ========================================================================== */

@media (max-width: 768px) {
    /* Hero section */
    .portal-hero {
        padding: 30px 16px !important;
        min-height: 200px !important;
    }

    .portal-hero h1 {
        font-size: 24px !important;
    }

    .portal-logo {
        max-width: 120px !important;
    }

    /* Info cards grid */
    .info-cards-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .info-card {
        padding: 16px !important;
    }

    .info-card-label {
        font-size: 12px !important;
    }

    .info-card-value {
        font-size: 15px !important;
    }

    /* Portal sections */
    .portal-section {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }

    .portal-section h2 {
        font-size: 18px !important;
    }

    /* Social media planner table */
    .social-table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px !important;
        padding: 0 16px !important;
    }

    .social-table {
        min-width: 800px !important;
        font-size: 13px !important;
    }

    .social-table th,
    .social-table td {
        padding: 8px !important;
    }

    .social-date-input,
    .social-type-select {
        font-size: 13px !important;
        padding: 6px 8px !important;
    }

    .social-table textarea {
        font-size: 13px !important;
        min-height: 60px !important;
    }

    .media-preview img,
    .media-placeholder {
        width: 40px !important;
        height: 40px !important;
    }

    /* Month accordion */
    .social-month-header-bar {
        padding: 14px 16px !important;
    }

    .social-month-header-bar h3 {
        font-size: 16px !important;
    }

    .social-month-content {
        padding: 12px !important;
    }

    /* Calendar mini */
    .calendar-mini {
        display: none !important;
    }

    /* QA buttons row */
    .qa-button-group {
        flex-wrap: wrap !important;
    }

    .qa-button-group .btn {
        font-size: 13px !important;
        padding: 8px 14px !important;
    }

    /* QA Review section */
    .qa-post-card {
        padding: 12px !important;
    }

    .qa-post-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .qa-post-status {
        font-size: 11px !important;
    }

    .qa-media-preview img,
    .qa-media-preview video {
        max-height: 200px !important;
    }

    /* Client view banner */
    .client-view-banner {
        padding: 10px 16px !important;
    }

    .client-view-banner-content {
        flex-direction: column !important;
        gap: 10px !important;
        text-align: center !important;
    }

    .client-view-banner span {
        font-size: 13px !important;
    }

    /* QA Lightbox */
    .qa-lightbox-container {
        width: 95% !important;
        max-width: none !important;
        margin: 10px !important;
        padding: 16px !important;
        max-height: 90vh !important;
    }

    .qa-lightbox-media {
        max-height: 40vh !important;
    }

    .qa-lightbox-nav {
        width: 36px !important;
        height: 36px !important;
    }

    /* Passwords section */
    .passwords-grid {
        grid-template-columns: 1fr !important;
    }

    /* Actions table */
    .actions-table {
        display: block !important;
        overflow-x: auto !important;
    }

    /* Key dates */
    .key-dates-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   Todo Lists (Company & My Todos)
   ========================================================================== */

@media (max-width: 768px) {
    .todos-container {
        padding: 16px !important;
    }

    .todo-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .todo-filters {
        width: 100% !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .todo-filters select,
    .todo-filters input {
        width: 100% !important;
    }

    .todo-item {
        padding: 12px !important;
    }

    .todo-item-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .todo-checkbox {
        order: -1 !important;
    }

    .todo-title {
        font-size: 15px !important;
    }

    .todo-meta {
        font-size: 12px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .todo-actions {
        width: 100% !important;
        margin-top: 12px !important;
        justify-content: flex-start !important;
    }
}

/* ==========================================================================
   Mobile Menu (Inside Admin Pages)
   ========================================================================== */

@media (max-width: 768px) {
    /* Mobile menu toggle button - keep in header position */
    .mobile-menu-toggle {
        display: block !important;
    }

    .mobile-menu {
        display: flex !important;
    }

    .mobile-menu-overlay {
        position: fixed !important;
        inset: 0 !important;
        background: rgba(0, 0, 0, 0.5) !important;
        z-index: 1003 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.3s ease !important;
    }

    .mobile-menu-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ==========================================================================
   Tables - General Mobile Handling
   ========================================================================== */

@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    table th,
    table td {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
}

/* ==========================================================================
   Forms - Mobile Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    /* Prevent iOS zoom on focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    textarea,
    select {
        font-size: 16px !important;
    }

    .form-group {
        margin-bottom: 16px !important;
    }

    .form-label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
    }

    .form-control {
        padding: 12px 14px !important;
    }

    .form-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .form-actions .btn {
        width: 100% !important;
    }
}

/* ==========================================================================
   Modals - Mobile Optimizations
   ========================================================================== */

@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px !important;
        align-items: flex-start !important;
        padding-top: 20px !important;
    }

    .modal-content,
    .modal-container {
        width: 100% !important;
        max-width: none !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        border-radius: 16px !important;
    }

    .modal-header {
        padding: 16px !important;
        position: sticky !important;
        top: 0 !important;
        background: white !important;
        z-index: 10 !important;
    }

    .modal-body {
        padding: 16px !important;
    }

    .modal-footer {
        padding: 16px !important;
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        border-top: 1px solid var(--gray-200) !important;
    }

    .modal-close {
        width: 36px !important;
        height: 36px !important;
        font-size: 24px !important;
    }
}

/* ==========================================================================
   Buttons - Touch Friendly
   ========================================================================== */

@media (max-width: 768px) {
    .btn {
        padding: 12px 20px !important;
        font-size: 15px !important;
        min-height: 44px !important;
    }

    .btn-small {
        padding: 8px 14px !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }

    .btn-large {
        padding: 14px 24px !important;
        font-size: 16px !important;
    }

    .btn-icon {
        width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
    }

    /* Button groups stack on mobile */
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }

    .btn-group .btn {
        width: 100% !important;
    }
}

/* ==========================================================================
   Utility Classes - Mobile Specific
   ========================================================================== */

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .text-center-mobile {
        text-align: center !important;
    }

    .full-width-mobile {
        width: 100% !important;
    }

    .stack-mobile {
        flex-direction: column !important;
    }

    .gap-sm-mobile {
        gap: 8px !important;
    }

    .p-sm-mobile {
        padding: 12px !important;
    }

    .mt-md-mobile {
        margin-top: 16px !important;
    }
}

/* ==========================================================================
   Fix iOS Safari Issues
   ========================================================================== */

@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    .modal-content,
    .mobile-menu-panel {
        -webkit-overflow-scrolling: touch;
    }

    input, textarea, select {
        -webkit-appearance: none;
        border-radius: 0;
    }

    /* Fix for iOS bottom bar */
    .site-main {
        padding-bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* ==========================================================================
   Small Mobile (< 480px)
   ========================================================================== */

@media (max-width: 480px) {
    h1 {
        font-size: 26px !important;
    }

    h2 {
        font-size: 22px !important;
    }

    h3 {
        font-size: 18px !important;
    }

    .container,
    .container-wide {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .images-grid {
        grid-template-columns: 1fr !important;
    }

    .preview-grid {
        grid-template-columns: 1fr !important;
    }

    .card {
        padding: 16px !important;
    }

    /* Stack everything */
    .flex-row,
    [style*="display: flex"] {
        flex-wrap: wrap !important;
    }
}
