/* ====================================================
   Scholars Connect — Responsive / Mobile-First CSS
   Breakpoints:
     xs  : max 480px  (small phones)
     sm  : max 640px  (large phones)
     md  : max 768px  (tablets / large phones landscape)
     lg  : max 1024px (small laptops / tablets landscape)
   ==================================================== */

/* ====================================================
   0. BASE MOBILE GUARD — prevent horizontal scroll
   ==================================================== */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
video,
iframe,
svg {
    max-width: 100%;
}

/* ====================================================
   1. NAVBAR / HEADER
   ==================================================== */

/* ---- Large tablet: hide desktop nav, show hamburger ---- */
@media (max-width: 1024px) {
    .navbar {
        padding: 0 20px;
        gap: 12px;
    }

    .navbar-nav {
        display: none !important;
    }

    .nav-actions {
        display: none !important;
    }

    .navbar-mobile-toggle {
        display: flex !important;
        margin-left: auto;
    }

    .navbar-brand {
        font-size: 1rem;
    }
}

/* ---- Mobile Nav Overlay Panel ---- */
.mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.mobile-menu.open {
    display: block;
    animation: fadeInOverlay .2s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.mobile-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(300px, 85vw);
    height: 100%;
    background: #fff;
    padding: 24px 20px;
    overflow-y: auto;
    animation: slideInRight .25s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

/* ====================================================
   2. TYPOGRAPHY — Clamp headings
   ==================================================== */
@media (max-width: 768px) {
    h1 {
        font-size: clamp(1.5rem, 5vw, 2.4rem);
    }

    h2 {
        font-size: clamp(1.25rem, 4.5vw, 2rem);
    }

    h3 {
        font-size: clamp(1rem, 3.5vw, 1.5rem);
    }

    .section-title {
        font-size: clamp(1.3rem, 4vw, 2rem) !important;
    }

    .hero h1 {
        font-size: clamp(1.7rem, 6vw, 2.8rem);
    }
}

/* ====================================================
   3. HERO SECTION — single column, less padding
   ==================================================== */
@media (max-width: 1024px) {
    .hero>.container {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }

    /* Hide hero right-side floating cards on small screens */
    .hero>.container>div:last-child {
        display: none;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 160px 0 !important;
        min-height: auto !important;
    }

    .hero-content {
        text-align: center;
    }

    .hero-stats {
        justify-content: center;
        flex-wrap: wrap;
        gap: 16px;
    }

    .search-bar {
        flex-direction: column !important;
        border-radius: var(--radius) !important;
        overflow: hidden;
    }

    .search-field {
        border-bottom: 1px solid var(--gray-200) !important;
        padding: 14px 16px !important;
        width: 100%;
    }

    .search-divider {
        display: none !important;
    }

    .search-bar-btn {
        border-radius: 0 0 var(--radius) var(--radius) !important;
        width: 100%;
        padding: 14px !important;
    }

    .hero-eyebrow {
        font-size: .78rem;
    }
}

/* ====================================================
   4. SECTION / CONTAINER
   ==================================================== */
@media (max-width: 768px) {
    .section {
        padding: 40px 0 !important;
    }

    .container {
        padding: 0 16px !important;
    }

    .section-header {
        margin-bottom: 24px;
    }

    .section-sub {
        font-size: .88rem;
    }
}

/* ====================================================
   5. GRIDS — collapse to fewer columns
   ==================================================== */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* Jobs grid stays 1-col on small phones */
    .grid-jobs {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .grid-3 {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   6. JOB CARDS
   ==================================================== */
@media (max-width: 480px) {
    .job-card {
        padding: 16px;
    }

    .job-card-header {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .job-card-logo {
        width: 42px;
        height: 42px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    .job-card-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .job-card-salary {
        font-size: .82rem;
    }

    .job-card-meta {
        gap: 6px;
    }

    .job-card-tag {
        font-size: .72rem;
    }
}

/* ====================================================
   7. CARDS / INSTITUTION CARDS
   ==================================================== */
@media (max-width: 768px) {
    .card-body {
        padding: 18px !important;
    }

    .inst-card-body {
        padding: 32px 16px 16px;
    }
}

/* ====================================================
   8. FORMS — full width
   ==================================================== */
@media (max-width: 768px) {

    /* All inputs full width */
    .form-control,
    .form-select,
    select.form-control {
        width: 100% !important;
        font-size: .95rem;
        padding: 12px 14px;
    }

    /* Side-by-side form rows stack */
    .form-row,
    [style*="display:grid"][style*="grid-template-columns: 1fr 1fr"],
    [style*="display:grid"][style*="grid-template-columns:1fr 1fr"],
    [style*="display:grid"][style*="1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Buttons full width in forms */
    .btn-form-submit,
    form .btn-primary:not(.btn-sm) {
        width: 100%;
        justify-content: center;
    }

    .step-indicator {
        gap: 2px;
    }

    .step-label {
        display: none;
    }

    .step-circle {
        width: 28px;
        height: 28px;
        font-size: .75rem;
    }
}

/* ====================================================
   9. JOBS PAGE — filter sidebar
   ==================================================== */
@media (max-width: 768px) {

    /* Jobs page grid: sidebar + content → stack to 1 col */
    .container[style*="grid-template-columns:260px"],
    .container[style*="grid-template-columns: 260px"] {
        display: flex !important;
        flex-direction: column !important;
        padding-top: 16px !important;
    }

    /* Filter aside becomes a collapsible row on mobile */
    .container[style*="grid-template-columns:260px"] aside,
    .container[style*="grid-template-columns: 260px"] aside {
        width: 100% !important;
    }
}

/* ====================================================
   10. PANEL / DASHBOARD LAYOUT
   ==================================================== */
@media (max-width: 1024px) {

    /* Panel layout: sidebar becomes a fixed drawer */
    .panel-layout,
    .admin-panel-layout {
        flex-direction: column;
    }

    /* Sidebar: hidden by default, fixed overlay on mobile */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        height: 100vh !important;
        width: 260px !important;
        z-index: 700 !important;
        transition: left .3s cubic-bezier(.4, 0, .2, 1) !important;
        overflow-y: auto;
    }

    .sidebar.mobile-open {
        left: 0 !important;
        box-shadow: var(--shadow-xl);
    }

    /* Sidebar overlay backdrop */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 699;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .sidebar-overlay.open {
        display: block;
        animation: fadeInOverlay .2s ease;
    }

    .panel-main {
        padding: 16px !important;
        width: 100% !important;
    }

    /* Stat grid: 2 columns on tablet */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }

    .panel-topbar {
        margin-bottom: 16px;
        flex-wrap: wrap;
    }

    /* Admin topbar hamburger button */
    .panel-mobile-menu-btn {
        display: flex !important;
    }
}

@media (max-width: 480px) {

    /* Stat grid: 1 column on phone */
    .stat-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-card-value {
        font-size: 1.6rem;
    }

    .panel-main {
        padding: 12px !important;
    }

    .p-card-header {
        padding: 14px 16px;
    }

    .p-card-body {
        padding: 16px !important;
    }

    .panel-topbar-left h1 {
        font-size: 1.2rem;
    }
}

/* Add a hamburger button style for dashboard */
.panel-mobile-menu-btn {
    display: none;
    background: rgba(255, 255, 255, .1);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: background .2s;
}

.panel-mobile-menu-btn:hover {
    background: rgba(255, 255, 255, .2);
}

/* ====================================================
   11. DATA TABLES — horizontal scroll on mobile
   ==================================================== */
@media (max-width: 768px) {

    .p-card-body.no-pad,
    .table-responsive-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Wrap any data-table parent with overflow */
    .data-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .data-table {
        min-width: 560px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 14px;
        white-space: nowrap;
    }

    /* p-card no-pad tables need a scroll wrapper */
    .p-card .p-card-body.no-pad {
        overflow-x: auto;
    }
}

/* ====================================================
   12. FOOTER — stack columns
   ==================================================== */
@media (max-width: 768px) {
    .footer {
        padding: 40px 0 24px !important;
    }

    .footer .grid,
    .footer .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 28px !important;
    }

    .footer-bottom {
        flex-direction: column !important;
        gap: 12px !important;
        text-align: center !important;
    }

    .footer-bottom>div {
        justify-content: center !important;
    }
}

/* ====================================================
   13. INSTITUTION / JOB DETAIL PAGES
   ==================================================== */
@media (max-width: 768px) {

    /* job.html: main + sidebar → stack */
    [style*="grid-template-columns:1fr 340px"],
    [style*="grid-template-columns: 1fr 340px"],
    [style*="grid-template-columns:2fr 1fr"],
    [style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* institution.html: stats row wrap */
    [style*="grid-template-columns:repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ====================================================
   14. AUTH PAGES (login/signup) — 2-col → 1-col
   ==================================================== */
@media (max-width: 768px) {

    /* Full-height auth grid splits to just form, hide hero panel */
    [style*="grid-template-columns:1fr 460px"],
    [style*="grid-template-columns: 1fr 460px"],
    [style*="grid-template-columns:420px 1fr"],
    [style*="grid-template-columns: 420px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Hide auth hero panel on very small screens */
    .auth-hero-panel {
        display: none !important;
    }

    /* Make first child (form side) take full height */
    .auth-form-side {
        min-height: 100vh;
        padding: 24px 20px;
    }
}

/* ====================================================
   15. PRICING PAGE — cards
   ==================================================== */
@media (max-width: 780px) {

    [style*="grid-template-columns:repeat(3,1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"],
    [style*="grid-template-columns:1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   16. CHAT / MESSAGES — hide list, show window
   ==================================================== */
@media (max-width: 768px) {
    .chat-layout {
        grid-template-columns: 1fr !important;
        height: auto !important;
        min-height: auto;
    }

    .chat-list {
        display: none;
    }

    .chat-window {
        height: calc(100vh - 120px);
    }
}

/* ====================================================
   17. BLOG / ABOUT / CONTACT PAGE SPECIFIC
   ==================================================== */
@media (max-width: 768px) {

    /* Blog: hero text */
    .blog-hero h1 {
        font-size: 1.6rem;
    }

    /* Contact: 2-col → 1-col */
    [style*="grid-template-columns:1fr 380px"],
    [style*="grid-template-columns: 1fr 380px"],
    [style*="grid-template-columns:360px 1fr"],
    [style*="grid-template-columns: 360px 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   18. MISCELLANEOUS UTILS
   ==================================================== */
@media (max-width: 768px) {

    /* Stack inline flex rows that have gap */
    .mobile-stack {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .mobile-stack .btn {
        width: 100%;
        justify-content: center;
    }

    /* Hide on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Show only on mobile */
    .show-mobile {
        display: flex !important;
    }

    /* Text align */
    .mobile-center {
        text-align: center !important;
    }

    /* Badges don't wrap weirdly */
    .badge {
        white-space: nowrap;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Reduce toast width on mobile */
    .toast-mobile {
        right: 12px !important;
        left: 12px !important;
        max-width: calc(100vw - 24px) !important;
    }
}

/* ====================================================
   19. PANEL TOPBAR — add hamburger slot
   ==================================================== */
@media (max-width: 1024px) {
    .admin-topbar {
        padding: 0 16px;
        gap: 12px;
    }

    .panel-topbar-right {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .admin-topbar {
        padding: 0 12px;
    }

    .notif-dropdown {
        width: calc(100vw - 24px);
        right: -12px;
    }
}

/* ====================================================
   20. FORM STEPS (post vacancy / multi-step)
   ==================================================== */
@media (max-width: 640px) {

    /* Label of steps hide, show only circles */
    .step-indicator {
        justify-content: center;
    }

    .step-label {
        display: none;
    }

    /* Two-column vacancy form grids become 1 col */
    .vacancy-form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   21. PROFILE PAGES
   ==================================================== */
@media (max-width: 768px) {

    /* Profile cover + avatar */
    .profile-cover {
        height: 120px !important;
    }

    .profile-avatar-wrap {
        bottom: -32px !important;
        left: 16px !important;
        width: 64px !important;
        height: 64px !important;
    }

    .profile-body-offset {
        padding-top: 48px !important;
    }

    /* Profile two-col layout */
    [style*="grid-template-columns:260px 1fr"],
    [style*="grid-template-columns: 260px 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   22. INSTITUTIONS GRID
   ==================================================== */
@media (max-width: 640px) {

    /* Institution grid on institutions.html */
    [id="inst-grid"] {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================
   END responsive.css
   ==================================================== */

/* ====================================================
   23. NAMED GRID CLASSES — hero, AI features, contact
   ==================================================== */

/* Hero grid: reduce gap on tablets */
@media (max-width: 1024px) {
    .hero-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
    .hero-grid > div:last-child {
        display: none;
    }
}

/* AI features 2-col: stack on tablet/mobile */
@media (max-width: 900px) {
    .ai-features-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
}

/* Contact / job-alerts 2-col sidebar grids */
@media (max-width: 768px) {
    .contact-grid {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
}

/* Hero mobile padding fix — keep compact on small screens */
@media (max-width: 768px) {
    .hero {
        padding: 40px 0 !important;
    }
    .hero-grid {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .hero-grid {
        padding-left: 24px !important;
        padding-right: 24px !important;
    }
}

/* Desktop: lg (1025–1279px) */
@media (min-width: 1025px) and (max-width: 1279px) {
    .hero-grid {
        max-width: 1280px !important;
        padding-left: 80px !important;
        padding-right: 80px !important;
    }
    .hero {
        padding: 32px 0 !important;
    }
}

/* Desktop: xl (1280–1535px) */
@media (min-width: 1280px) and (max-width: 1535px) {
    .hero-grid {
        max-width: 1400px !important;
        padding-left: 112px !important;
        padding-right: 112px !important;
    }
    .hero {
        padding: 32px 0 !important;
    }
}

/* Desktop: 2xl (1536px+) */
@media (min-width: 1536px) {
    .hero-grid {
        max-width: 1500px !important;
        padding-left: 140px !important;
        padding-right: 140px !important;
    }
    .hero {
        padding: 32px 0 !important;
    }
}