/* ============================================
   NexHire — Responsive Styles v2.0
   Mobile-first, no horizontal scrolling
   Professional senior-level implementation
   ============================================ */

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

*,
*::before,
*::after {
    box-sizing: border-box;
    min-width: 0;
}

img, video, svg, canvas, iframe {
    max-width: 100%;
    height: auto;
}

/* ============================================
   VISIBILITY HELPERS (global)
   ============================================ */
.hide-on-mobile { display: inherit; }
.hide-on-desktop { display: none !important; }

/* ============================================
   PROFILE TABS (global base)
   ============================================ */
.profile-tabs {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-tab {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.profile-tab:hover {
    background: rgba(108, 99, 255, 0.08);
    color: var(--primary);
}

.profile-tab.active {
    background: rgba(108, 99, 255, 0.12);
    color: var(--primary);
    border: 1px solid rgba(108, 99, 255, 0.2);
    font-weight: 600;
}

.profile-tab i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ============================================
   TEXT OVERFLOW SAFETY
   ============================================ */
.dashboard-subtitle,
.dashboard-title,
.page-title,
.section-title {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.dashboard-header {
    max-width: 100%;
    flex-wrap: wrap;
}

/* ============================================
   TABLE: safe internal scroll only
   ============================================ */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: var(--radius-md);
}

/* ============================================
   FORMS
   ============================================ */
input, textarea, select {
    max-width: 100%;
    box-sizing: border-box;
}

/* ============================================
   /* ============================================
   Tablet & Mobile Navbar Collapse (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .hero-title { font-size: 2.5rem; }
    .hero-search {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px !important;
        border-radius: 20px !important;
        gap: 8px !important;
    }
    .hero-search .search-input-wrapper {
        width: 100% !important;
        border-bottom: 1px solid var(--border-color) !important;
    }
    .hero-search .search-input {
        width: 100% !important;
        padding: 12px 16px 12px 42px !important;
    }
    .hero-search .location-autocomplete {
        width: 100% !important;
        flex: none !important;
        border-left: none !important;
        border-top: none !important;
    }
    .hero-search .location-autocomplete .location-input {
        width: 100% !important;
        padding: 12px 36px 12px 14px !important;
    }
    .hero-search .search-btn {
        width: 100% !important;
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 14px !important;
        padding: 0 24px !important;
        font-size: 15px !important;
        font-weight: 700 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 6px !important;
        box-shadow: 0 4px 15px var(--primary-glow) !important;
    }
    .hero-stats { gap: 40px; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 30px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stepper { flex-wrap: wrap; gap: 8px; }
    .step-line { width: 30px; }
    .location-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* --- Visibility Helpers --- */
    .hide-on-mobile { display: none !important; }
    .hide-on-desktop { display: block !important; }
    .hide-on-desktop.flex { display: flex !important; }

    /* --- Public Navbar Collapse --- */
    .nav-toggle { display: flex !important; }

    .nav-menu {
        display: flex !important;
        position: fixed;
        top: var(--header-height, 70px);
        left: 0;
        width: 100vw;
        height: calc(100vh - var(--header-height, 70px));
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        flex-direction: column;
        align-items: stretch;
        padding: 24px 20px;
        gap: 6px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 10005;
        visibility: hidden;
        pointer-events: none;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    }

    .nav-menu.active {
        transform: translateX(0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .nav-link {
        padding: 14px 16px;
        font-size: 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-link.active::after { display: none; }

    .nav-actions {
        margin-left: auto !important;
        margin-top: 0 !important;
        flex-direction: row !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
    }
}

/* ============================================
   Mobile (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    .section { padding: 50px 0; }

    /* Prevent horizontal overflow from layout containers only */
    .container,
    .dashboard-content,
    main,
    .page-body {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Cards can overflow internally for tabs — just ensure they don't expand page width */
    .dashboard-card,
    .glass-card,
    .card {
        max-width: 100%;
        min-width: 0;
    }

    /* --- Profile/Settings Tabs → Horizontal Pill Bar --- */
    .profile-tabs {
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        gap: 6px !important;
        padding: 4px 0 10px !important;
        border-bottom: 1px solid var(--border-color);
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }

    .profile-tabs::-webkit-scrollbar { display: none; }

    .profile-tab {
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
        padding: 8px 16px !important;
        font-size: 13px !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 20px !important;
        white-space: nowrap !important;
        background: var(--bg-card) !important;
    }

    .profile-tab.active {
        background: var(--primary) !important;
        color: white !important;
        border-color: var(--primary) !important;
        font-weight: 600;
    }

    /* --- Grid: sidebar layout stacks vertically on mobile --- */
    .grid.grid-3 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .grid-col-1,
    .grid-col-2 {
        grid-column: span 1 !important;
    }

    /* Tab nav card compact on mobile */
    .grid-col-1 .dashboard-card {
        padding: 10px !important;
        margin-bottom: 12px;
    }

    /* --- Dashboard Header --- */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .dashboard-title {
        font-size: 1.4rem;
        line-height: 1.3;
        word-break: break-word;
    }

    .dashboard-subtitle {
        font-size: 0.85rem;
        line-height: 1.5;
        word-break: break-word;
    }

    /* --- Hero section --- */
    .hero { padding: calc(var(--header-height) + 40px) 0 60px; }
    
    /* Override inline font-size styles on hero elements */
    .hero-title,
    .hero-premium-section h1 {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        max-width: 100% !important;
    }
    
    /* Hero grid: stack on mobile */
    .hero-premium-section .grid-2,
    .hero-premium-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
    
    /* Hide decorative hero right column on mobile to save space */
    .hero-right-column {
        display: none !important;
    }
    
    /* Hero stats: horizontal on mobile with flex wrap */
    .hero-stats {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 20px !important;
        justify-content: flex-start !important;
    }
    
    .hero-stat-value {
        font-size: 1.8rem !important;
    }

    /* --- Generic Grids --- */
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .grid-col-2 { grid-column: span 1; }

    /* --- Dashboard Sidebar --- */
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }

    .dashboard-content {
        margin-left: 0 !important;
        padding: 16px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar-toggle-btn { display: flex; align-items: center; justify-content: center; }

    /* --- Stats Grid --- */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

    /* --- Footer --- */
    .footer-grid { grid-template-columns: 1fr; gap: 30px; }

    /* --- Auth --- */
    .auth-card { padding: 28px 20px; }
    .otp-input { width: 44px; height: 48px; font-size: 1.2rem; }

    /* --- Pipeline --- */
    .pipeline { flex-direction: column; }
    .pipeline-stage { border-radius: var(--radius-sm) !important; }

    /* --- Stepper --- */
    .step-label { display: none; }
    .step-line { width: 24px; }

    /* --- Job Card --- */
    .job-card-meta { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* --- Applicant Card --- */
    .applicant-card { flex-direction: column; text-align: center; }
    .applicant-actions { justify-content: center; }

    /* --- Modal --- */
    .modal-overlay .modal,
    .modal {
        width: 95vw !important;
        max-width: 95vw !important;
        border-radius: var(--radius-xl);
        max-height: 90vh;
        overflow-y: auto;
    }

    /* --- Contact messages tab wrapper --- */
    .profile-tabs-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 4px;
        padding: 4px 12px 0;
    }

    .profile-tabs-wrapper::-webkit-scrollbar { display: none; }

    /* --- Chatbot FAB --- */
    #chatbotToggle,
    .chatbot-fab {
        bottom: 16px !important;
        right: 16px !important;
        width: 52px !important;
        height: 52px !important;
        font-size: 20px !important;
    }

    /* --- Jobs filter layout --- */
    .jobs-layout { flex-direction: column; }
    .jobs-filter-sidebar { width: 100%; position: static; }
    .jobs-main { width: 100%; }

    /* --- Notification bell --- */
    .notification-bell { flex-shrink: 0; }

    /* --- Nav brand --- */
    .nav-brand span { font-size: 1.1rem; }
    
    /* --- Job posting location grid --- */
    .location-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   Phone (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }

    .container { padding: 0 14px; }

    .hero-title { font-size: 1.6rem; }
    .hero-search {
        padding: 10px !important;
        border-radius: 18px !important;
        gap: 6px !important;
    }
    .hero-search .search-input {
        padding: 12px 14px 12px 42px !important;
        font-size: 14px !important;
    }
    .hero-search .location-autocomplete .location-input {
        padding: 12px 34px 12px 14px !important;
        font-size: 14px !important;
    }
    .hero-search .search-btn {
        width: 100% !important;
        height: 48px !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        padding: 0 20px !important;
        font-size: 15px !important;
        font-weight: 700 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 4px !important;
    }

    .glass-card, .card { padding: 14px; }
    .stat-card { padding: 14px; }
    .stat-card-value { font-size: 1.5rem; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .btn-lg { padding: 14px 24px; font-size: 14px; }

    .auth-container { max-width: 100%; }
    .auth-card { border-radius: var(--radius-xl); padding: 22px 16px; }

    .otp-inputs { gap: 6px; }
    .otp-input { width: 40px; height: 44px; font-size: 1.1rem; }

    .role-selector { grid-template-columns: 1fr; }

    .modal { width: 96vw; border-radius: var(--radius-lg); }

    .footer { padding: 40px 0 0; }

    .hero-stat-value { font-size: 2rem; }

    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { white-space: nowrap; }

    .profile-tab {
        padding: 7px 12px !important;
        font-size: 12px !important;
    }

    .dashboard-card { padding: 14px; }
    .dashboard-content { padding: 12px; }
    .dashboard-title { font-size: 1.25rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ============================================
   Very small phones (max-width: 360px)
   ============================================ */
@media (max-width: 360px) {
    .auth-card { padding: 18px 12px; }
    .hero-title { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .container { padding: 0 12px; }
    .profile-tab {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
}

/* ============================================
   Large screens (min-width: 1400px)
   ============================================ */
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
    .hero-title { font-size: 4rem; }
}

/* ============================================
   Print
   ============================================ */
@media print {
    .navbar, .sidebar, .footer, .btn, .nav-toggle { display: none !important; }
    .dashboard-content { margin-left: 0 !important; }
    body { background: white; color: black; }
    .glass-card, .card, .stat-card { border: 1px solid #ddd; background: white; }
}
