/*
 * Mobile Responsive Styles for Hero Vired Portal
 * Optimized for touch devices and small screens
 */

/* Mobile breakpoints */
/* Small devices (phones, 576px and down) */
@media (max-width: 576px) {
    /* Typography adjustments */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 18px;
    }

    /* Container padding */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Navbar adjustments */
    .navbar {
        padding: 0.75rem 0;
    }

    .navbar-brand img {
        height: 60px !important;
    }

    /* Cards */
    .card {
        margin-bottom: 16px;
        border-radius: 12px;
    }

    .card-header {
        padding: 12px 16px;
        font-size: 16px;
    }

    .card-body {
        padding: 16px;
    }

    /* Buttons */
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 8px;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }

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

    /* Tables - make them scrollable */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    .table {
        font-size: 13px;
        min-width: 600px; /* Force horizontal scroll for large tables */
    }

    .table thead th {
        padding: 10px 8px;
        font-size: 12px;
    }

    .table tbody td {
        padding: 10px 8px;
    }

    /* Stat cards - stack vertically */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .stat-card .value {
        font-size: 24px;
    }

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

    /* Charts - reduce height on mobile */
    .chart-container {
        height: 250px !important;
        margin: 16px 0;
    }

    /* Footer */
    footer {
        padding: 1.5rem 0;
        font-size: 13px;
    }

    .signature {
        text-align: center;
    }

    .signature .name {
        font-size: 16px;
    }

    .signature .title {
        font-size: 13px;
    }

    .signature .contact {
        font-size: 12px;
    }
}

/* Medium devices (tablets, 768px and down) */
@media (max-width: 768px) {
    /* Grid layouts - 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    /* Navigation improvements */
    .navbar-nav {
        margin-top: 12px;
    }

    .nav-item {
        margin-bottom: 8px;
    }

    /* Dashboard cards */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Chart containers */
    .chart-container {
        height: 300px !important;
    }

    /* Modals - full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
    }

    /* Learner profiling cards */
    .learner-card {
        margin-bottom: 16px;
    }

    .learner-card .learner-info {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Ritzz AI Chat - responsive */
    .chat-container {
        max-height: 60vh;
    }

    .chat-message {
        max-width: 85%;
        font-size: 14px;
        padding: 10px 14px;
    }

    .chat-input-container {
        padding: 12px;
    }

    .chat-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Touch-friendly enhancements */
/* Increase tap targets for touch devices */
@media (hover: none) and (pointer: coarse) {
    /* Minimum 44x44px tap targets (Apple HIG) */
    .btn,
    .nav-link,
    .dropdown-item,
    .form-check-input,
    .form-check-label {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Larger touch areas for important actions */
    .btn-primary,
    .btn-success {
        padding: 14px 24px;
    }

    /* Improve spacing for touch */
    .btn-group .btn {
        margin: 4px;
    }

    /* Better checkbox/radio sizes */
    .form-check-input {
        width: 24px;
        height: 24px;
    }

    .form-check-label {
        padding-left: 8px;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover,
    .nav-link:hover {
        transform: none !important;
    }

    /* Add active states instead */
    .btn:active {
        transform: scale(0.98);
    }

    .card:active {
        transform: scale(0.99);
    }

    /* Smooth scroll on touch */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand img {
        height: 50px !important;
    }

    .card {
        margin-bottom: 12px;
    }

    .chart-container {
        height: 200px !important;
    }

    /* Footer less tall in landscape */
    footer {
        padding: 1rem 0;
    }

    /* Chat interface adjustments */
    .chat-container {
        max-height: 50vh;
    }
}

/* Extra small devices (small phones, 375px and down) */
@media (max-width: 375px) {
    /* Even smaller text for tiny phones */
    body {
        font-size: 13px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    h3 {
        font-size: 16px;
    }

    /* Tighter spacing */
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }

    .card {
        margin-bottom: 12px;
    }

    .card-header,
    .card-body {
        padding: 12px;
    }

    /* Buttons */
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Dark mode toggle - smaller */
    .dark-mode-toggle {
        width: 44px;
        height: 44px;
        bottom: 12px;
        right: 12px;
    }

    .dark-mode-toggle i {
        font-size: 18px;
    }
}

/* Tablet landscape (iPad, etc.) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* 3 columns for stats on tablet landscape */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    /* Optimize charts for tablet */
    .chart-container {
        height: 350px !important;
    }

    /* Better use of space */
    .container-fluid {
        max-width: 960px;
        margin: 0 auto;
    }
}

/* Print styles */
@media print {
    /* Remove navigation, footer, buttons */
    .navbar,
    footer,
    .btn,
    .dark-mode-toggle {
        display: none !important;
    }

    /* Optimize for printing */
    body {
        background: white !important;
        color: black !important;
    }

    .card {
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }

    .chart-container {
        page-break-inside: avoid;
    }

    /* Remove glassmorphism for print */
    .glass,
    .glass-card {
        background: white !important;
        backdrop-filter: none !important;
    }
}

/* Accessibility - reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton,
    .loading-spinner {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .glass,
    .glass-card {
        border: 2px solid rgba(255, 255, 255, 0.5);
    }

    .btn {
        border: 2px solid currentColor;
    }

    .form-control,
    .form-select {
        border: 2px solid rgba(255, 255, 255, 0.5);
    }
}

/* Safe area insets for notched devices (iPhone X, etc.) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .navbar,
    footer {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .dark-mode-toggle {
        right: max(24px, env(safe-area-inset-right));
        bottom: max(24px, env(safe-area-inset-bottom));
    }
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Responsive videos */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-container iframe,
.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Mobile-friendly scrollbars */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-thumb {
        border-radius: 3px;
    }
}


/* =============================================================================
   NAVBAR — MOBILE RESPONSIVE
   Target: base.html navbar (all pages)
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    /* Reduce navbar height and padding */
    .navbar {
        padding: 0.5rem 0 !important;
    }

    /* Override the inline style="height: 100px" on the logo */
    .navbar-brand img {
        height: 56px !important;
        width: auto !important;
    }

    .navbar .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Reduce dropdown-toggle padding */
    .navbar .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 375px) {
    .navbar-brand img {
        height: 44px !important;
    }
}


/* =============================================================================
   PORTAL HOME PAGE — MOBILE RESPONSIVE
   Target: templates/portal.html
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    /* Hero section — reduce padding */
    .hero-section {
        padding: 1.5rem 0 !important;
        margin-top: 0.75rem !important;
        margin-bottom: 1.25rem !important;
    }

    .hero-title {
        font-size: 1.4rem !important;
    }

    .hero-subtitle {
        font-size: 0.875rem !important;
        word-break: break-all;  /* prevent long email from overflowing */
    }

    /* Stack "Welcome, Name!" + Admin badge vertically */
    .hero-section .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .admin-badge {
        align-self: flex-start;
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .hero-title {
        font-size: 1.2rem !important;
    }

    /* Quick info row — stack on very small screens */
    .hero-section + .container .d-flex.align-items-center {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
}


/* =============================================================================
   DEPARTMENT HEADER (ALL DEPARTMENTS) — MOBILE RESPONSIVE
   Target: .dept-header used in all department templates
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    .dept-header {
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    /* Stack title row + back button vertically */
    .dept-header .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.6rem;
        margin-bottom: 0.5rem !important;
    }

    .dept-header h1 {
        font-size: 1.15rem !important;
        line-height: 1.3;
    }

    .dept-header p {
        font-size: 0.8rem !important;
        margin-top: 0.2rem !important;
    }

    /* Back button — compact on mobile */
    .dept-header .d-flex.justify-content-between > a.btn,
    .dept-header .d-flex.justify-content-between > .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
        white-space: nowrap;
        align-self: flex-start;
    }

    /* Tab navigation buttons — wrap and shrink */
    .dept-header .d-flex.gap-2 {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }

    .dept-header .d-flex.gap-2 .btn {
        font-size: 0.78rem !important;
        padding: 0.4rem 0.7rem !important;
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .dept-header h1 {
        font-size: 1rem !important;
    }

    /* On very small phones, stack tab buttons too */
    .dept-header .d-flex.gap-2 .btn {
        flex: 1 1 45%;  /* 2-column wrap */
    }
}


/* =============================================================================
   SECTION & SUBSECTION TITLES (ALL DEPARTMENTS) — MOBILE RESPONSIVE
   Target: .section-title-box, .subsection-title, .chart-content
   Breakpoints: 768px
   ============================================================================= */

@media (max-width: 768px) {
    .section-title-box {
        font-size: 0.95rem !important;
        padding: 0.8rem 1rem !important;
    }

    .section-title-box i {
        font-size: 1rem !important;
        margin-right: 0.5rem !important;
    }

    /* Section number circle badge */
    .section-number {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        font-size: 0.78rem !important;
        margin-right: 0.5rem !important;
    }

    .subsection-title {
        font-size: 0.9rem !important;
        padding: 0.65rem 1rem !important;
        margin-bottom: 0.875rem !important;
    }

    .subsection-title i {
        font-size: 0.95rem !important;
        margin-right: 0.4rem !important;
    }

    /* Chart content padding */
    .chart-content {
        padding: 0.875rem !important;
    }

    /* Subsection container (nested inside sections) */
    .subsection-container {
        padding: 0.875rem !important;
        margin-top: 1.25rem !important;
    }
}


/* =============================================================================
   COMPARISON TABS (WEEK / MONTH / QUARTER / YEAR) — MOBILE RESPONSIVE
   Target: .comparison-tabs .tab-button used in both dashboards
   Breakpoints: 576px
   ============================================================================= */

@media (max-width: 576px) {
    .comparison-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.4rem !important;
        margin-bottom: 1rem !important;
    }

    .tab-button {
        padding: 0.45rem 0.4rem !important;
        font-size: 0.78rem !important;
        text-align: center;
        width: 100%;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap;
        gap: 0.2rem;
        min-height: 40px;
    }

    /* Reduce icon margin inside tab buttons */
    .tab-button i,
    .tab-button .me-2 {
        margin-right: 0.2rem !important;
        font-size: 0.75rem !important;
    }
}


/* =============================================================================
   DELIVERY TEAM MAIN DASHBOARD — MOBILE RESPONSIVE
   Target: /delivery-team/dashboard
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    /* Trends chart container — reduce fixed height */
    #trendsContainer > div {
        height: 300px !important;
        min-height: 280px !important;
    }

    #talkTimeChart {
        height: 100% !important;
    }

    /* LRM Date filter row — stack vertically */
    /* Targets the "From: [date] To: [date] [Refresh] [Export]" row */
    .subsection-container > .d-flex.align-items-center.justify-content-between {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.6rem !important;
    }

    /* Inner flex with labels + date inputs */
    .subsection-container .d-flex.align-items-center.gap-3.flex-wrap {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.4rem !important;
    }

    /* Override inline style="width: 160px" on date inputs */
    #arneyoStartDate,
    #arneyoEndDate {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Label text in date filter */
    .subsection-container label.mb-0.fw-semibold {
        font-size: 0.82rem !important;
    }

    /* Export + Refresh buttons — equal width side by side */
    .subsection-container > .d-flex.align-items-center.justify-content-between > .d-flex.gap-2 {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.4rem !important;
    }

    .subsection-container .d-flex.gap-2 .btn {
        justify-content: center !important;
        font-size: 0.82rem !important;
    }

    /* Arneyo table — smaller font inside responsive wrapper */
    #arneyoTable {
        font-size: 0.68rem !important;
    }

    /* Section divider spacing */
    .section-divider {
        margin: 2rem 0 1.25rem 0 !important;
    }
}

@media (max-width: 576px) {
    /* Trends chart further reduced height on very small screens */
    #trendsContainer > div {
        height: 240px !important;
        min-height: 220px !important;
    }

    /* Container padding reduction */
    .container.pb-5 {
        padding-bottom: 2rem !important;
    }
}


/* =============================================================================
   CAREER SERVICES DASHBOARD — SUPPLEMENTAL MOBILE FIXES
   Note: dashboard.html already has an inline @media(max-width:767px) block.
   These are additive — covering elements NOT already in the inline block.
   Target: /career-services/dashboard
   Breakpoints: 767px, 576px
   ============================================================================= */

@media (max-width: 767px) {
    /* CR Performance Cards — force single column */
    .cr-card-wrapper {
        grid-template-columns: 1fr !important;
    }

    .cr-perf-card .placement-count {
        font-size: 2rem !important;
    }

    /* CR performance card metrics row — allow wrapping */
    .cr-perf-card .metrics {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Filter section month/year selects */
    .filter-section select,
    .filter-section .form-select {
        font-size: 0.9rem !important;
    }
}

@media (max-width: 576px) {
    /* KPI value — reduce on tiny screens */
    .kpi-value {
        font-size: 1.5rem !important;
    }

    .kpi-label {
        min-height: auto !important;
        font-size: 0.6rem !important;
    }
}


/* =============================================================================
   CAREER SERVICES PERFORMANCE TRACKER — MOBILE RESPONSIVE
   Target: /career-services/performance-tracker
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    /* Override large padding in Performance Tracker dept-header */
    /* (template uses padding: 2rem 2.5rem 1.5rem inline) */
    .dept-header[class*="dept-header"] {
        padding: 1rem 1.25rem !important;
    }

    /* Gauge cards — reduce canvas size on mobile */
    .gauge-card .gauge-canvas-wrap {
        width: 90px !important;
        height: 90px !important;
    }

    .gauge-card .gauge-center-text {
        font-size: 1.15rem !important;
    }

    .gauge-card .gauge-label {
        font-size: 0.65rem !important;
    }

    .gauge-card .gauge-subtitle {
        font-size: 0.7rem !important;
    }

    /* Scorecard — reduce padding */
    .scorecard {
        padding: 1rem !important;
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 576px) {
    .gauge-card .gauge-canvas-wrap {
        width: 80px !important;
        height: 80px !important;
    }

    .gauge-card .gauge-center-text {
        font-size: 1rem !important;
    }
}


/* =============================================================================
   SESSION FEEDBACKS (DELIVERY TEAM) — MOBILE RESPONSIVE
   Target: /delivery-team/session-feedbacks
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* Filter section header — stack title + badge vertically on mobile */
    .filter-section .d-flex.align-items-center.justify-content-between.mb-3 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
    }

    .last-updated-badge {
        font-size: 0.72rem !important;
        padding: 0.25rem 0.65rem !important;
        word-break: break-all;
    }

    /* Global export bar — stack left (icon+text) above right (buttons) */
    .global-export-bar,
    #globalExportBar {
        flex-direction: column !important;
        gap: 0.6rem !important;
        align-items: stretch !important;
        padding: 0.75rem 1rem !important;
    }

    /* geb-right buttons container — stretch full width */
    .global-export-bar .geb-right,
    #globalExportBar .geb-right {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
        width: 100%;
    }

    /* geb-btn (CSV/Excel/PDF) — equal-width in a 3-column grid */
    .global-export-bar .geb-btn,
    #globalExportBar .geb-btn,
    .global-export-bar .btn,
    #globalExportBar .btn {
        flex: 1 1 0 !important;
        justify-content: center !important;
        text-align: center;
        white-space: nowrap;
        font-size: 0.7rem !important;
        padding: 0.45rem 0.5rem !important;
    }

    /* AI section — stack generate button + description vertically */
    .card-body-pad .d-flex.align-items-center.gap-3.mb-3 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }

    /* Stats KPI2 grid — 2 columns on mobile (was 3) */
    .kpi2-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .kpi2-card {
        padding: 0.75rem !important;
    }

    .kpi2-value {
        font-size: 1.5rem !important;
    }

    /* Quick insights strip — stack vertically */
    .quick-insights-strip {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    /* Batch/Faculty summary tables — reduce font */
    #batchSummaryTable,
    #facultySummaryTable {
        font-size: 0.78rem !important;
    }

    /* Feedback details table */
    #feedbackTableBody td {
        font-size: 0.78rem !important;
        padding: 0.5rem 0.5rem !important;
    }

    /* Section export buttons — full width */
    .section-export-btn {
        width: 100% !important;
        margin-top: 0.5rem !important;
    }

    /* Section title box export button group — wrap on mobile */
    .export-btn-group {
        flex-wrap: wrap !important;
        gap: 0.3rem !important;
    }

    /* Pagination bar — stack on very small screens */
    .pagination-bar {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: center !important;
    }
}

@media (max-width: 480px) {
    /* KPI2 grid — single column on very small screens */
    .kpi2-grid {
        grid-template-columns: 1fr !important;
    }

    /* Distribution bars */
    .dist2-bar-row {
        font-size: 0.72rem !important;
    }
}


/* =============================================================================
   LEARNER PROFILING — MOBILE RESPONSIVE
   Target: /career-services/learner-profiling
   Breakpoints: 768px
   ============================================================================= */

@media (max-width: 768px) {
    /* Learner cards stack properly */
    .learner-card {
        margin-bottom: 0.875rem;
    }

    .learner-card .learner-info {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    /* Search and filter controls */
    .learner-search-bar,
    #learnerSearch {
        width: 100% !important;
    }
}


/* =============================================================================
   FOOTER — MOBILE RESPONSIVE
   Target: base.html footer (all pages)
   Breakpoints: 768px
   ============================================================================= */

@media (max-width: 768px) {
    footer {
        padding: 1.25rem 0 !important;
    }

    .signature {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }

    .signature .name {
        font-size: 0.95rem !important;
    }

    .signature .title {
        font-size: 0.82rem !important;
    }

    .signature .contact {
        font-size: 0.75rem !important;
    }

    /* Prevent long email from overflowing in footer */
    .signature .contact a {
        word-break: break-all;
    }
}


/* =============================================================================
   JD ANALYSIS — MOBILE RESPONSIVE
   Target: /career-services/jd-analysis
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* CRITICAL: skill-name has min-width:170px which causes overflow on phones.
       Reduce to a reasonable size so the progress bar still has room.          */
    .skill-name {
        min-width: 90px !important;
        max-width: 130px !important;
        font-size: 0.72rem !important;
    }

    /* skill-bar-wrap: allow wrap so bar goes below name on very small screens */
    .skill-bar-wrap {
        flex-wrap: wrap;
        gap: 0.3rem !important;
    }

    .skill-bar-bg {
        min-width: 80px;
    }

    /* JD table wrapper — ensure horizontal scroll */
    .jd-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Inline tags (domain / skill) — allow wrap, reduce padding */
    .tag-domain,
    .tag-skill {
        font-size: 0.68rem !important;
        padding: 1px 6px !important;
    }

    /* Chart card body — reduce padding */
    .chart-card-body {
        padding: 0.875rem !important;
    }

    /* KPI cards — 2 per row (Bootstrap col-6 already handles this) */
    .kpi-value {
        font-size: 1.6rem !important;
    }

    .kpi-icon {
        font-size: 1.3rem !important;
    }
}

@media (max-width: 480px) {
    .skill-name {
        min-width: 70px !important;
        max-width: 100px !important;
        font-size: 0.68rem !important;
    }

    /* On very small screens stack name above bar */
    .skill-bar-wrap {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .skill-bar-bg {
        width: 100% !important;
    }
}


/* =============================================================================
   PLACEMENT ANALYSIS — MOBILE RESPONSIVE
   Target: /career-services/placement-analysis
   Breakpoints: 768px, 576px
   ============================================================================= */

@media (max-width: 768px) {
    /* Summary/KPI strip — wrap and reduce gap */
    .pa-summary-strip,
    .summary-strip {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Records table wrapper — force horizontal scroll */
    .pl-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        max-height: 340px !important;
    }

    /* Filter section — Bootstrap col-6 gives 2 per row; acceptable on mobile.
       On tablet reduce to 3 per row (col-md-3 already handles ≥768px).       */

    /* Chart card shimmer + body */
    .chart-card-body {
        padding: 0.875rem !important;
        min-height: 220px;
    }

    /* Chart card — reduce fixed heights */
    .chart-card {
        margin-bottom: 1rem !important;
    }

    /* Anomaly badge — stay in top-right of card header */
    .anomaly-badge {
        font-size: 0.68rem !important;
        padding: 2px 6px !important;
    }
}

@media (max-width: 576px) {
    /* Filter dropdowns — full width on small phones */
    .filter-section .col-6 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* KPI counter values */
    .kpi-value {
        font-size: 1.4rem !important;
    }
}


/* =============================================================================
   SEGMENT ANALYTICS — MOBILE RESPONSIVE
   Target: /career-services/segment-analytics
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* Filter bar — stack controls vertically */
    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    /* Filter selects — override min-width: 120px, go full width */
    .filter-bar select,
    .filter-bar .filter-select {
        min-width: 0 !important;
        width: 100% !important;
    }

    /* KPI strip — auto-fit already responsive; just tighten tile padding */
    .kpi-tile {
        padding: 0.75rem 0.875rem !important;
    }

    .kpi-tile .kpi-value {
        font-size: 1.5rem !important;
    }

    .kpi-tile .kpi-label {
        font-size: 0.65rem !important;
    }

    /* Chart cards — reduce body padding */
    .chart-card-body {
        padding: 0.875rem !important;
    }
}

@media (max-width: 480px) {
    /* KPI strip — 2-column grid on very small screens */
    .kpi-strip {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
}


/* =============================================================================
   COMMAND CENTER — MOBILE RESPONSIVE (supplemental)
   Note: command_center.html already has @media 768px + 480px inline blocks.
   These are additive overrides for elements not covered by the inline block.
   Target: /career-services/command-center
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* Pipeline name — reduce fixed 80px width so bar has more room */
    .cc-pipeline-name {
        width: 64px !important;
        font-size: 0.72rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Pipeline segment — reduce font */
    .cc-pipeline-seg {
        font-size: 0.68rem !important;
    }

    /* CC header — ensure nav buttons wrap on mobile */
    .cc-nav {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }

    .cc-nav a,
    .cc-nav button {
        font-size: 0.78rem !important;
        padding: 6px 10px !important;
    }

    /* AI panel — reduce padding */
    .cc-ai-panel {
        padding: 1rem !important;
    }

    /* Person card grid — ensure min card width is respected on narrow screens */
    .cc-cards {
        gap: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    /* Pipeline name even narrower on very small screens */
    .cc-pipeline-name {
        width: 52px !important;
        font-size: 0.65rem !important;
    }
}


/* =============================================================================
   BOARD REPORT — MOBILE RESPONSIVE
   Target: /career-services/board-report
   Breakpoints: 768px
   ============================================================================= */

@media (max-width: 768px) {
    /* Wrapper is max-width:900px centered — fine on mobile, just add padding */
    .board-report-wrapper {
        padding: 1rem 0.75rem !important;
    }

    /* Toolbar buttons (month/year selects + Print button) — wrap on mobile */
    .no-print.d-flex,
    .board-report-wrapper .d-flex.gap-2 {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }

    /* Month/year select — full width on mobile */
    #monthSel,
    #yearSel {
        width: 100% !important;
        min-width: 0 !important;
    }
}


/* =============================================================================
   JD ANALYSIS — SEARCH BOX (inline width:220px override)
   Target: /career-services/jd-analysis  #tableSearch input
   Breakpoints: 768px
   ============================================================================= */

@media (max-width: 768px) {
    /* The All-JDs table search box is hardcoded to width:220px inline — override it */
    #tableSearch {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.5rem !important;
        display: block !important;
    }
    /* chart-card-header needs to wrap when search moves below title */
    .chart-card-header {
        flex-wrap: wrap !important;
        row-gap: 0.4rem !important;
    }
}


/* =============================================================================
   LEARNING STRATEGY & FACULTY DASHBOARDS — MOBILE RESPONSIVE
   Target: /learning-strategy, /faculty
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* Stack header title + back-button vertically */
    .dept-header .d-flex.justify-content-between.align-items-center {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    /* Back-to-dashboard button stretches full width */
    .dept-header .btn.btn-light {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }

    /* Reduce header padding */
    .dept-header {
        padding: 1rem 1.25rem !important;
    }

    /* Tab nav buttons: smaller text on mobile */
    .dept-header .nav-btn {
        font-size: 0.82rem !important;
        padding: 0.4rem 0.9rem !important;
    }

    /* Info / coming-soon card padding reduction */
    .info-card {
        padding: 1.5rem 1rem !important;
    }
}

@media (max-width: 480px) {
    .dept-header h1,
    .dept-header .h3 {
        font-size: 1.15rem !important;
    }

    /* Tab nav fills the row with wrap */
    .dept-header .d-flex.gap-2.flex-wrap {
        gap: 0.4rem !important;
    }
}


/* =============================================================================
   ACCESS CONTROL CENTER — MOBILE RESPONSIVE
   Target: /admin/access-control
   Breakpoints: 768px, 576px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* ACC page header */
    .acc-header {
        padding: 1rem 1.25rem !important;
    }

    /* Stat strip → 2-column grid (5 pills × 140px > 412px, so must shrink) */
    .stat-strip {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.75rem !important;
    }
    .stat-pill {
        min-width: 0 !important;
        padding: 0.75rem 1rem !important;
    }
    .stat-pill .stat-val {
        font-size: 1.5rem !important;
    }

    /* User-table header row: stack title + search box */
    .acc-card .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.6rem !important;
    }

    /* Search box full width (inline style="width:200px" override) */
    #userSearch {
        width: 100% !important;
        min-width: 0 !important;
    }
    .search-box {
        width: 100% !important;
    }

    /* Dept bar chart label — narrower so bar track has room */
    .dept-bar-label {
        width: 100px !important;
        font-size: 0.76rem !important;
    }

    /* Role donut chart — allow it to fill column width */
    #roleChart {
        max-width: 160px !important;
        width: 100% !important;
    }

    /* Charts row: stack both columns full-width */
    .acc-card .row > [class*="col-md"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Dept checkbox grid → 2 cols */
    .dept-check-grid {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 576px) {
    /* Stat strip → single column on small phones */
    .stat-strip {
        grid-template-columns: 1fr !important;
    }
    .stat-pill {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        text-align: left !important;
        gap: 0.75rem !important;
    }
    .stat-pill .stat-val {
        font-size: 1.35rem !important;
    }
}

@media (max-width: 480px) {
    /* Dept bar label even tighter */
    .dept-bar-label {
        width: 75px !important;
        font-size: 0.7rem !important;
    }

    /* Dept checkbox grid → 1 col on very small screens */
    .dept-check-grid {
        grid-template-columns: 1fr !important;
    }

    /* Confirm modal — reduce padding */
    .confirm-box {
        padding: 1.25rem !important;
    }
}


/* =============================================================================
   GLOBAL CHART HEIGHT CAPS — ALL PAGES (412px / 480px)
   Overrides inline style="height:280px|350px|420px" on chart wrapper divs.
   Uses div[style] to target only inline-styled wrappers, not table wrappers.
   ============================================================================= */

@media (max-width: 480px) {
    /* Cap all inline-height chart containers at 200px on small phones */
    .chart-card-body > div[style] {
        height: 200px !important;
        min-height: 0 !important;
    }

    /* Ensure canvases inside respect container */
    .chart-card-body > div[style] > canvas {
        max-height: 200px !important;
    }

    /* Placement analysis large bar chart is often taller */
    #topCompaniesChart {
        max-height: 300px !important;
    }
}

@media (max-width: 375px) {
    .chart-card-body > div[style] {
        height: 180px !important;
        min-height: 0 !important;
    }
    .chart-card-body > div[style] > canvas {
        max-height: 180px !important;
    }
}


/* =============================================================================
   SESSION FEEDBACKS — ADDITIONAL MOBILE FIXES (shared template)
   Target: /session-feedbacks (all departments)
   Breakpoints: 768px, 480px
   ============================================================================= */

@media (max-width: 768px) {
    /* KPI2 grid — 2 columns (already 3 on desktop) */
    .kpi2-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.6rem !important;
    }

    /* Quick insights strip — stack vertically */
    .quick-insights-strip {
        flex-direction: column !important;
        gap: 0.4rem !important;
    }
    .quick-insights-strip > div {
        width: 100% !important;
    }

    /* Filter bar: label + dropdown stack on each row */
    .filter-bar-row {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
}

@media (max-width: 480px) {
    /* KPI2 grid — single column on very small phones */
    .kpi2-grid {
        grid-template-columns: 1fr !important;
    }

    /* Batch / faculty summary tables: reduce font */
    .summary-table {
        font-size: 0.75rem !important;
    }
    .summary-table th,
    .summary-table td {
        padding: 0.4rem 0.5rem !important;
    }
}
