/**
 * Global Responsive CSS - Lumon Global Partners
 * Fixes responsive issues across ALL templates
 * Mobile-first approach with progressive enhancement
 */

/* ==========================================
   BASE RESPONSIVE RESETS
   ========================================== */

/* Prevent horizontal overflow on all pages */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Ensure all containers respect viewport width */
* {
    box-sizing: border-box;
}

/* Responsive images and media */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   MOBILE BREAKPOINT (< 768px)
   ========================================== */

@media (max-width: 767px) {

    /* ===== LAYOUT & CONTAINERS ===== */

    /* Main content padding reduction */
    .main-content {
        padding: 1rem !important;
        padding-top: 80px !important; /* Account for fixed header */
    }

    /* Section spacing */
    section {
        padding: 1rem 0 !important;
        margin: 0.5rem 0 !important;
    }

    /* Container max-width */
    .container,
    .content-container,
    .page-container {
        padding: 0.75rem !important;
        margin: 0 auto !important;
        max-width: 100% !important;
    }

    /* ===== GRIDS & CARD LAYOUTS ===== */

    /* Force single column for card grids */
    .candidates-container,
    .clients-grid,
    .vacancies-grid,
    .activities-grid,
    .candidate-grid-card-container {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0.5rem !important;
    }

    /* Individual cards */
    .candidate-grid-card,
    .client-card,
    .vacancy-card,
    .activity-card,
    .card {
        width: 100% !important;
        min-width: unset !important;
        max-width: 100% !important;
        margin: 0 0 1rem 0 !important;
    }

    /* ===== SEARCH & FILTER SECTIONS ===== */

    .search-filter-container {
        padding: 1rem !important;
        margin: 0 !important;
    }

    .search-section {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .search-input-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }

    .search-input {
        width: 100% !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    /* Filter section */
    .filter-section {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-top: 1rem !important;
    }

    .filter-group {
        width: 100% !important;
        margin: 0 !important;
    }

    .filter-select {
        width: 100% !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    /* ===== BUTTONS & ACTIONS ===== */

    /* Button containers */
    .header-actions,
    .section-header .header-actions,
    .button-group,
    .action-buttons {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    /* Individual buttons */
    .btn,
    button:not(.nav__toggle):not(.theme-switch__checkbox),
    .action-btn {
        width: 100% !important;
        min-width: unset !important;
        padding: 0.75rem 1rem !important;
        font-size: 14px !important;
        text-align: center !important;
        justify-content: center !important;
    }

    /* Small icon-only buttons */
    .btn-icon-only,
    .icon-btn,
    .delete-icon {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        padding: 0.5rem !important;
    }

    /* ===== FORMS ===== */

    /* Form containers */
    .form-container,
    .form-wrapper,
    form {
        padding: 1rem !important;
        max-width: 100% !important;
    }

    /* Form rows to single column */
    .form-row,
    .form-group-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* Form groups */
    .form-group {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    /* Form inputs */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        width: 100% !important;
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 0.75rem !important;
    }

    /* Labels */
    label {
        display: block !important;
        margin-bottom: 0.5rem !important;
        font-size: 14px !important;
    }

    /* ===== TABLES ===== */

    /* Make tables scrollable */
    .table-container,
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -1rem !important;
        padding: 0 1rem !important;
    }

    table {
        min-width: 600px !important; /* Prevent extreme squashing */
        font-size: 13px !important;
    }

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

    /* DataTables specific */
    .dataTables_wrapper {
        overflow-x: auto !important;
    }

    .dataTables_filter,
    .dataTables_length {
        margin-bottom: 1rem !important;
    }

    /* ===== MODALS ===== */

    .modal-content,
    .confirmation-modal .delete-modal-container {
        width: 95% !important;
        max-width: 95vw !important;
        margin: 1rem !important;
        padding: 1.5rem !important;
    }

    .modal-header h2,
    .delete-modal-title {
        font-size: 1.25rem !important;
    }

    .modal-body,
    .delete-modal-content {
        font-size: 14px !important;
    }

    .modal-actions,
    .delete-modal-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .modal-actions button,
    .delete-modal-actions button {
        width: 100% !important;
    }

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

    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.25rem !important;
    }

    h4 {
        font-size: 1.1rem !important;
    }

    p, li, span {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }

    /* ===== PAGE HEADERS ===== */

    .page-header,
    .section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    .page-title {
        font-size: 1.5rem !important;
        margin: 0 !important;
    }

    /* ===== STATISTICS / INFO BOXES ===== */

    .stats-container,
    .info-boxes,
    .dashboard-stats {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .stat-box,
    .info-box,
    .metric-card {
        width: 100% !important;
        padding: 1rem !important;
    }

    /* ===== NAVIGATION ADJUSTMENTS ===== */

    /* Hide desktop nav items on mobile (hamburger menu takes over) */
    .nav__center {
        display: none !important;
    }

    .nav__toggle {
        display: flex !important;
    }

    /* ===== CANDIDATE/CLIENT DETAIL PAGES ===== */

    .detail-container,
    .profile-container {
        padding: 1rem !important;
    }

    .detail-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .detail-grid,
    .profile-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .detail-item {
        width: 100% !important;
    }

    /* ===== TABS ===== */

    .tabs-container,
    .tab-buttons {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .tab-button {
        min-width: 100px !important;
        font-size: 13px !important;
        padding: 0.5rem 1rem !important;
    }

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

    .pagination-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }

    .pagination-info {
        text-align: center !important;
        order: 2 !important;
    }

    .pagination-controls {
        order: 1 !important;
        gap: 0.5rem !important;
    }

    .pagination-controls button {
        padding: 0.5rem 0.75rem !important;
        font-size: 13px !important;
    }

    /* ===== SPECIFIC FIXES ===== */

    /* Results info */
    .results-info {
        font-size: 13px !important;
        padding: 0.5rem !important;
        text-align: center !important;
    }

    /* Status badges */
    .status-badge,
    .badge {
        font-size: 11px !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Avatar */
    .candidate-avatar,
    .avatar {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    /* Card actions at bottom */
    .candidate-actions,
    .card-actions {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .candidate-actions .btn,
    .card-actions .btn {
        width: 100% !important;
    }

    /* Dropdown selects */
    .dropdown,
    .select-wrapper {
        width: 100% !important;
    }

    /* ===== UTILITIES ===== */

    /* Hide elements on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: block !important;
    }

    /* Reduce spacing on mobile */
    .spacing-reduce {
        padding: 0.5rem !important;
        margin: 0.5rem 0 !important;
    }

    /* Text alignment */
    .text-center-mobile {
        text-align: center !important;
    }
}

/* ==========================================
   SMALL MOBILE (< 480px)
   ========================================== */

@media (max-width: 479px) {

    /* Extra small screens - even more compact */
    .main-content {
        padding: 0.75rem !important;
    }

    /* Smaller text */
    body {
        font-size: 13px !important;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* ===== CARD OVERFLOW FIXES ===== */

    /* Prevent cards from overflowing */
    .candidate-grid-card,
    .client-card,
    .vacancy-card,
    .activity-card,
    .card {
        padding: 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    /* Ensure all card content respects card width */
    .candidate-grid-card *,
    .client-card *,
    .vacancy-card *,
    .activity-card *,
    .card * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Break long words and text */
    .candidate-grid-card,
    .client-card,
    .vacancy-card,
    .activity-card,
    .card {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }

    /* Card details grid - force single column */
    .candidate-details,
    .client-details,
    .vacancy-details,
    .card-details {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Detail items */
    .detail-item {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .detail-label {
        font-size: 11px !important;
        margin-bottom: 0.25rem !important;
    }

    .detail-value {
        font-size: 13px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }

    /* Card header */
    .candidate-header,
    .card-header {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Card title/name */
    .candidate-info h3,
    .client-name,
    .vacancy-title,
    .card-title {
        font-size: 1rem !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }

    /* Links and emails that can be long */
    a, .email, .url, .link {
        word-break: break-all !important;
        overflow-wrap: break-word !important;
    }

    /* Avatar size reduction */
    .candidate-avatar,
    .avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.9rem !important;
        flex-shrink: 0 !important;
    }

    /* Smaller buttons */
    .btn {
        padding: 0.625rem 0.875rem !important;
        font-size: 13px !important;
        word-wrap: normal !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Card footer */
    .candidate-footer,
    .card-footer {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Status badges */
    .status-badge {
        font-size: 10px !important;
        padding: 0.2rem 0.4rem !important;
        white-space: nowrap !important;
    }

    /* Modal adjustments */
    .modal-content,
    .delete-modal-container {
        padding: 1rem !important;
        max-width: calc(100vw - 2rem) !important;
        word-wrap: break-word !important;
    }

    /* Tables inside cards - make scrollable */
    .card table,
    .candidate-grid-card table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }

    /* Prevent pre/code blocks from overflowing */
    pre, code {
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        overflow-x: auto !important;
    }
}

/* ==========================================
   TABLET (768px - 1023px)
   ========================================== */

@media (min-width: 768px) and (max-width: 1023px) {

    /* Two columns for grids on tablet */
    .candidates-container,
    .clients-grid,
    .vacancies-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.25rem !important;
    }

    /* Form rows can have 2 columns */
    .form-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Button groups can be horizontal */
    .header-actions,
    .button-group {
        flex-direction: row !important;
        flex-wrap: wrap !important;
    }

    .btn {
        flex: 1 1 auto !important;
        min-width: 120px !important;
    }
}

/* ==========================================
   LANDSCAPE MOBILE (e.g. phone rotated)
   ========================================== */

@media (max-width: 767px) and (orientation: landscape) {

    /* Reduce header height in landscape */
    .nav {
        min-height: 50px !important;
    }

    .main-content {
        padding-top: 60px !important;
    }

    /* Two columns in landscape */
    .candidates-container,
    .clients-grid,
    .vacancies-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ==========================================
   DESKTOP VISIBILITY CONTROLS
   ========================================== */

@media (min-width: 768px) {
    /* Hide mobile-only elements on desktop */
    .show-mobile {
        display: none !important;
    }

    /* Show desktop elements */
    .hide-mobile {
        display: block !important;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    /* Hide navigation and non-essential elements */
    .nav,
    .mobile-drawer,
    .mobile-drawer-backdrop,
    .theme-switch-container,
    footer,
    .btn,
    .action-buttons {
        display: none !important;
    }

    /* Optimize layout for printing */
    .main-content {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Force page breaks */
    .page-break {
        page-break-after: always;
    }
}

/* ==========================================
   ACCESSIBILITY ENHANCEMENTS
   ========================================== */

/* Larger touch targets on mobile */
@media (max-width: 767px) {
    a, button, input[type="button"], input[type="submit"] {
        min-height: 44px !important; /* iOS recommended touch target */
        min-width: 44px !important;
    }
}

/* Focus styles for keyboard navigation */
@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }
}
