/* ========================================
   responsive.css - Power Stack Academy
   Mobile-first responsive overrides & fixes
   Load this AFTER the main style.css
   Last updated: sidebar behavior, content overflow fixes,
   track section stacking, apply page cursor/radio,
   full dashboard & admin responsiveness.
   ======================================== */

/* ---------- GLOBAL FIXES ---------- */

/* Prevent horizontal overflow */
html,
body {
    overflow-x: hidden !important;
    width: 100%;
    position: relative;
}

/* Ensure all elements respect box-sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Disable custom cursor on mobile to prevent blocking */
@media (max-width: 768px) {

    .custom-cursor,
    .custom-cursor-follower {
        display: none !important;
    }
}

/* ---------- APPLY PAGE CURSOR FIX ---------- */
/* Ensure default cursor on input fields and textareas (override custom cursor) */
.apply-page input,
.apply-page textarea,
.apply-page select,
.apply-page .choice-item,
.apply-page button {
    cursor: auto !important;
}

/* ---------- RADIO BUTTON SELECTION VISUAL FIX ---------- */
/* Style the label when the hidden radio is checked */
.choice-item:has(input:checked) {
    background: rgba(59, 130, 246, 0.1) !important;
    border-color: var(--accent-color) !important;
}

/* Fallback for browsers without :has (optional) */
@supports not selector(:has(a)) {
    .choice-item.selected {
        background: rgba(59, 130, 246, 0.1);
        border-color: var(--accent-color);
    }
}

/* ---------- TRACK SECTION (COURSES) REFACTOR ---------- */
/* Target the course panels (two tracks) */
.course-panel {
    width: 100%;
    /* Each panel takes full width */
    display: flex;
    flex-direction: row;
    /* Desktop: side-by-side */
    align-items: stretch;
    /* Match heights */
    gap: 2rem;
    /* Space between image and content */
    margin-bottom: 2rem;
    /* Space between panels */
    background: var(--surface);
    /* Keep existing glass effect */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* Keep border radius clean */
}

/* Image container (desktop: fixed width) */
.course-image {
    flex: 0 0 40%;
    /* 40% width, fixed */
    max-width: 40%;
    border-right: 1px solid var(--border-color);
    /* subtle divider */
    overflow: hidden;
}

.course-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content area (desktop: remaining width) */
.course-content {
    flex: 1;
    /* Takes rest of space */
    padding: 2.5rem 2rem;
    /* Comfortable spacing */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* MOBILE / TABLET STACKING */
@media (max-width: 900px) {
    .course-panel {
        flex-direction: column;
        /* Stack vertically */
        gap: 0;
        /* Remove gap – image touches content border */
    }

    .course-image {
        flex: none;
        /* Reset flex */
        max-width: 100%;
        /* Full width */
        width: 100%;
        height: 220px;
        /* Fixed height for image on mobile */
        border-right: none;
        /* Remove side border */
        border-bottom: 1px solid var(--border-color);
        /* Divider below image */
    }

    .course-content {
        padding: 1.5rem;
        /* Reduce padding on mobile */
    }

    .course-title {
        font-size: 1.5rem;
        /* Slightly smaller */
    }
}

/* Small phones (under 480px) */
@media (max-width: 480px) {
    .course-image {
        height: 180px;
        /* Even smaller image height */
    }

    .course-content {
        padding: 1.2rem;
    }
}

/* ---------- SIDEBAR ENHANCEMENTS ---------- */
/* Make logo clickable to index */
.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    color: inherit;
    text-decoration: none;
}

/* On large screens, sidebar is always visible */
@media (min-width: 851px) {
    .sidebar {
        transform: translateX(0) !important;
    }

    /* Ensure main content has correct margin */
    .main-content {
        margin-left: var(--curr-sidebar-width, 280px);
        transition: margin-left 0.5s;
    }

    /* No overlay on desktop */
    .sidebar-overlay {
        display: none !important;
    }
}

/* Mobile sidebar overlay */
@media (max-width: 850px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        transform: translateX(-100%);
        width: 280px !important;
        /* Fixed width on mobile */
        background: rgba(8, 8, 10, 0.98);
        backdrop-filter: blur(20px);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .toggle-sidebar {
        display: flex !important;
        right: -50px;
        background: var(--accent-color);
        border-radius: 0 10px 10px 0;
        transform: rotate(0) !important;
    }

    .sidebar.active .toggle-sidebar {
        transform: rotate(180deg) !important;
    }

    /* Overlay when sidebar is active */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 1040;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Adjust main content margin */
    .main-content {
        margin-left: 0 !important;
    }
}

/* ---------- DASHBOARD MOBILE RESPONSIVENESS (NO OVERFLOW) ---------- */

/* Dashboard container */
.dashboard-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

/* Main content area */
.main-content {
    width: 100%;
    max-width: 100%;
    padding: 2rem 1.5rem;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Dashboard header */
.db-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
}

@media (max-width: 600px) {
    .db-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .db-header>div:last-child {
        width: 100%;
        text-align: left !important;
    }
}

/* Dashboard grid */
.db-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    width: 100%;
}

@media (max-width: 900px) {
    .db-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Cards - prevent overflow */
.db-card {
    width: 100%;
    padding: 1.5rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
}

/* Profile hero section */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    width: 100%;
}

@media (max-width: 600px) {
    .profile-hero {
        flex-direction: column;
        text-align: center;
    }

    .profile-pic-db {
        width: 100px;
        height: 100px;
        margin: 0 auto;
    }

    .hero-info {
        width: 100%;
    }
}

/* Profile stats */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}

@media (max-width: 600px) {
    .profile-stats {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .p-stat-item {
        padding: 1rem;
    }
}

/* Course track card */
.course-track-card {
    padding: 1.5rem;
    width: 100%;
}

.track-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

@media (max-width: 600px) {
    .track-info {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Details list */
.details-list {
    margin-top: 1rem;
    width: 100%;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

@media (max-width: 600px) {
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Student Card Form Section */
.card-form-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.card-form-container .db-card {
    padding: 1.5rem;
    width: 100%;
}

@media (max-width: 600px) {
    .card-form-container .db-card {
        padding: 1rem;
    }
}

/* Success overlay */
.success-overlay {
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 600px) {
    .success-overlay {
        padding: 1.5rem 1rem;
    }

    .success-overlay h2 {
        font-size: 1.5rem;
    }
}

/* Student card mobile overrides removed to maintain pixel-perfect desktop design on all devices */


/* ---------- ADMIN PAGE MOBILE RESPONSIVENESS (NO OVERFLOW) ---------- */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
}

@media (max-width: 600px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-header>div:last-child {
        width: 100%;
        text-align: left !important;
    }
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
        width: 100%;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    .stat-info {
        min-width: 0;
        flex: 1;
    }

    .stat-info h2 {
        font-size: 1.4rem;
        word-break: break-word;
    }

    .stat-info .secondary-text {
        white-space: normal;
        word-break: break-word;
    }
}

/* Cards grid (requests) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

@media (max-width: 600px) {
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .request-card {
        padding: 1.2rem;
        width: 100%;
    }

    .req-pfp {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }

    .request-header {
        flex-wrap: wrap;
    }
}

/* Table container */
.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
    border-radius: var(--radius-md);
    background: var(--panel-bg);
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

table {
    min-width: 700px;
    /* Allow horizontal scroll on small screens */
    width: 100%;
    border-collapse: collapse;
}

@media (max-width: 600px) {
    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 1rem 0.75rem;
        font-size: 0.85rem;
        word-break: break-word;
    }
}

/* Modal adjustments */
.modal {
    padding: 1rem;
    box-sizing: border-box;
}

.modal-body {
    max-width: 100%;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    width: 100%;
}

@media (max-width: 900px) {
    .modal-content-grid {
        grid-template-columns: 1fr;
    }

    .modal-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1.5rem;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-sidebar>div {
        min-width: 200px;
        flex-shrink: 0;
    }

    .modal-main {
        padding: 2rem;
    }
}

@media (max-width: 600px) {
    .modal-sidebar {
        padding: 1rem;
    }

    .modal-main {
        padding: 1.5rem;
    }

    .modal-main h2 {
        font-size: 2rem;
        word-break: break-word;
    }

    .lv-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .lv-item {
        width: 100%;
    }

    .lv-item .lv-value {
        word-break: break-word;
    }

    .close-modal {
        top: 1rem;
        right: 1rem;
        width: 35px;
        height: 35px;
    }

    .image-lightbox {
        padding: 1rem;
    }

    .lightbox-close {
        top: 1rem;
        right: 1rem;
        font-size: 2rem;
    }
}

/* ---------- ADDITIONAL SAFEGUARDS ---------- */
/* Ensure all images and media are responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* For any flex/grid children that might overflow */
.flex-child,
.grid-child {
    min-width: 0;
    /* Allows flex/grid items to shrink below content size */
    overflow-wrap: break-word;
}

/* Buttons and links should wrap if needed */
.btn-primary,
.btn-secondary,
.btn-nav,
.btn-outline-small,
.btn-tertiary {
    white-space: normal;
    word-break: break-word;
    text-align: center;
    max-width: 100%;
}

/* ---------- FIX FOR LOCOSCROLL MOBILE SCROLLING ---------- */
/* Force locoscroll to not interfere */
.has-scroll-smooth {
    overflow: visible !important;
}

.has-scroll-scrolling {
    overflow: visible !important;
}

.c-scrollbar {
    display: none !important;
}

/* ---------- END OF RESPONSIVE.CSS ---------- */

/* Redundant student card rules removed - consolidated into dashboard.php for better control */