/* static/css/responsive.css */

/* Desktop view: Default sidebar behavior is handled in style.css */

/* Tablet and below (max-width: 768px) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px !important;
        left: 0;
        top: 0;
        height: 100dvh;
        z-index: 2000;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 0;
    }

    .main-content.expanded {
        margin-left: 0 !important;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    .mobile-sidebar-close {
        display: flex !important;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        font-size: 1.5rem;
    }

    .content-header {
        padding: 0.75rem 1rem !important;
    }

    .page-title {
        font-size: 1.1rem !important;
        margin-bottom: 0 !important;
    }

    .page-subtitle {
        display: none !important;
    }

    .board-container {
        padding: 1rem !important;
    }

    .breadcrumb {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    /* Course Details Page */
    .course-banner {
        margin: 1rem auto;
    }

    .course-info {
        padding: 0 1rem;
    }

    .course-meta {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .lesson-list {
        padding: 0 1rem;
    }

    .lesson-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .lesson-info {
        margin-left: 0;
        width: 100%;
    }

    .lesson-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color);
        margin-top: 0.25rem;
    }

    /* Lesson View Playlist Scroll */
    .lesson-view-container {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        padding: 1rem;
        gap: 1rem;
    }

    .lesson-content-area {
        height: 80vh !important;
        min-height: 400px !important;
        margin-bottom: 2rem;
    }

    .lesson-playlist-area {
        width: 100%;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
        /* Remove flex column constraint if needed */
    }

    .playlist-items {
        height: auto !important;
        overflow: visible !important;
        flex: none !important;
        /* specific override */
    }

    .content-header-tabs {
        display: flex;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        gap: 0.5rem;
    }

    .content-tab {
        flex: 1;
        white-space: nowrap;
        justify-content: center;
    }

    /* Toolbar & Filter Bar */
    .toolbar,
    .filter-bar {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
        flex-direction: column;
        align-items: stretch !important;
    }

    /* New Mobile Lesson Layout Strategy */
    .lesson-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        /* Top align for column of controls */
        flex-wrap: nowrap !important;
        /* Prevent wrapping of main columns */
    }

    .lesson-item {
        display: grid !important;
        grid-template-columns: auto 1fr !important;
        grid-template-areas:
            "controls info"
            "controls actions";
        align-items: start !important;
    }

    /* CSS Grid Approach for "Controls" | "Content" */
    .lesson-item {
        display: grid !important;
        grid-template-columns: min-content 1fr !important;
        grid-template-rows: auto auto !important;
        column-gap: 0.5rem !important;
    }

    .lesson-handle {
        grid-column: 1;
        grid-row: 1 / span 2;
        margin-right: 0 !important;
        justify-self: center;
        align-self: center;
    }

    .lesson-info {
        grid-column: 2;
        grid-row: 1 / span 2;
        /* Span both rows of controls if needed, or just flow */
        width: 100% !important;
        margin-left: 0 !important;
    }

    .lesson-actions {
        grid-column: 1 / span 2;
        /* Full width below */
        grid-row: 3;
    }

    .lesson-info {
        margin-left: 0;
        flex: 1 1 auto;
        /* Allow grow */
        width: auto !important;
        min-width: 200px;
        /* Force wrap if too small */
    }

    .lesson-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
        margin-top: 0.25rem;
    }

    /* Lesson Exam Mobile Optimization */
    .lesson-exam-item {
        margin-left: 1rem !important;
        /* Reduce indent */
        padding: 0.5rem !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .lesson-exam-item .small.fw-bold.text-dark {
        /* Hide "Lesson Exam: " text part if possible, but pure CSS can't strip text easily without span wrapper. 
           Assuming user wants single line. We will enforce single line. */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
        font-size: 0.8rem !important;
    }

    .lesson-exam-item iconify-icon {
        font-size: 1.2rem !important;
        /* Smaller icon */
    }

    .search-wrapper,
    .search-input {
        width: 100% !important;
    }

    .filter-chip,
    .toggle-filter-btn {
        width: 100%;
        justify-content: center;
    }

    .custom-select-trigger {
        width: 100%;
        justify-content: space-between;
    }

    /* Dashboard Title & Progress same row */
    .content-header .d-flex.justify-content-between.flex-wrap {
        flex-wrap: nowrap !important;
        gap: 10px !important;
    }

    .header-right-content {
        gap: 10px !important;
    }

    .overall-progress-wrapper {
        padding: 4px 8px !important;
    }

    .circular-progress-lg {
        width: 40px !important;
        height: 40px !important;
    }

    .circular-progress-lg::before {
        width: 32px !important;
        height: 32px !important;
    }

    .circular-progress-lg .circular-progress-value {
        font-size: 0.7rem !important;
    }

    /* User Cards Grid & One Column Layout for Mobile */
    .user-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        /* Force 1 column on mobile */
        gap: 1rem !important;
    }

    .user-grid .card .card-body {
        padding: 1rem !important;
        /* Restore padding */
    }

    .lesson-item {
        padding: 0.5rem !important;
    }

    .user-grid .card .course-card-empty-placeholder iconify-icon {
        width: 48px;
        /* Restore icon size */
        height: 48px;
    }

    .user-grid .card .card-title {
        font-size: 1.1rem;
        /* Better title size */
        margin-bottom: 0.75rem !important;
    }

    /* Restore visibility of description and other elements */
    .user-grid .card .small.text-muted.line-clamp-2,
    .user-grid .card .d-flex.justify-content-between.align-items-center.mt-auto.border-top.pt-3 {
        display: flex !important;
        /* Restore Flex layout */
    }

    .user-grid .card .btn-primary-custom,
    .user-grid .card .btn-light-custom {
        padding: 0.5rem 1rem;
        /* Restore button padding */
        font-size: 0.9rem;
        margin-top: 0.5rem;
    }

    /* Pagination */
    .table-footer {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.5rem;
        padding-top: 0.75rem;
    }

    .pagination-controls {
        gap: 4px;
        flex-wrap: nowrap !important;
        justify-content: flex-end;
    }

    .pagination-btn {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .pagination-info-wrapper {
        font-size: 0.8rem;
        flex-wrap: nowrap !important;
        white-space: nowrap;
    }

    /* Hide Pagination Info Text on Mobile */
    .pagination-info-wrapper>span:first-child,
    .pagination-separator,
    .rows-per-page-wrapper>span:first-child {
        display: none !important;
    }

    .course-card-header-bg {
        /* background-size: contain !important; */
        background-size: cover !important;
        /* Restore cover for better visuals */
        background-repeat: no-repeat !important;
        background-position: center !important;
        background-color: #f8f9fa;
    }

    /* Mobile Text Styling */
    .custom-select-trigger {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }

    .custom-option {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    /* Table Responsiveness */
    .table-container {
        overflow-x: auto;
    }

    /* Hide some table columns on tablet if needed */
    .custom-table th:nth-child(4),
    .custom-table td:nth-child(4) {
        /* Example: hide level/role on smaller screens */
        display: none;
    }
}

/* Phones (max-width: 480px) */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.1rem;
    }

    .course-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .meta-item {
        font-size: 0.8rem;
    }

    /* Video controls stack for tiny screens */
    .controls {
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }

    .progress {
        order: -1;
        flex: 0 0 100%;
        margin-bottom: 5px;
    }

    .time {
        font-size: 11px;
        min-width: 35px;
    }

    .control-btn iconify-icon {
        width: 20px;
        height: 20px;
    }

    .btn-primary-custom,
    .btn-light-custom {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
    }

    .custom-modal-header,
    .custom-modal-body,
    .custom-modal-footer {
        padding: 1rem;
    }
}

/* Log Management Mobile Overrides */
@media (max-width: 768px) {
    .desktop-filters {
        display: none !important;
    }

    .desktop-only-btn {
        display: none !important;
    }

    .fab-filter {
        display: flex !important;
    }

    /* Compact Pagination Dropdown */
    .rows-per-page-wrapper .custom-select-trigger {
        width: auto !important;
        min-width: unset !important;
        padding: 4px 8px !important;
    }

    .rows-per-page-wrapper .custom-select-wrapper {
        width: auto !important;
    }

    /* Ensure pagination controls stay in one line */
    .pagination-controls {
        flex-wrap: nowrap !important;
    }
}

/* User & Course Management Mobile View Restriction */
@media (max-width: 768px) {
    .view-tabs {
        display: none !important;
    }

    /* Force Table view over others on mobile */
    #boardView,
    #listView {
        display: none !important;
    }

    #tableView {
        display: block !important;
    }
}

.user-info-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info-wrapper img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}