/**
 * @version     4.2.2
 * @package     com_rucourses
 * @subpackage  mod_rucourses
 * @copyright   2022 The Joomla Project
 */

/* ==========================================================================
   1. GLOBAL & DESKTOP STYLES
   ========================================================================== */
.ruCourses.table { font-size: 15px; font-weight: 600; }
.ru_courses_header h3 { margin: 15px 0 2px !important; font-size: 27px; }
.helper_info { margin: 10px 0 3px; }

.ru_courses_content table.dataTable select {
    width: 90px; margin-bottom: 0; display: inline-block;
    height: 25px; border-radius: 2px; font-size: 12px; font-weight: bold;
}

.ru_courses_content input { width: inherit; }
.ru_courses_content table.dataTable .thead-dark th,
.ru_courses_content table.dataTable .thead-dark th a { color: #fff !important; font-weight: bold; }
.ru_courses_content table.dataTable .thead-dark th { background-color: #565656; border: none; }

.ru_courses_content table.dataTable thead th { padding: 4px 6px; text-align: left; border: none; }
.ru_courses_content table.dataTable tbody td { padding: 7px 5px 1px 5px; }

/* DataTables Controls & Search */
.dataTables_wrapper { width: 100%; overflow-x: hidden; } 
.dataTables_wrapper .dataTables_filter { float: right; text-align: right; }
.dataTables_wrapper .dataTables_filter input {
    margin-left: 10px; border: 1px solid #ced4da; border-radius: 4px; padding: 4px 8px;
}
.dataTables_wrapper:after { content: ""; display: table; clear: both; }

/* Rutgers Button Group (+/-) */
.rut-btn-group { display: inline-flex; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; }
.rucourses_btn { 
    background-color: #f8f9fa; border: none; color: #444; padding: 0 10px; 
    cursor: pointer; transition: all 0.2s ease; font-size: 14px;
    height: 30px; display: flex; align-items: center; justify-content: center;
    line-height: 1 !important;
}
.rucourses_btn:hover { background-color: #e2e6ea; }
.rucourses_btn.active { background-color: #cc0033 !important; color: #ffffff !important; }

/* ==========================================================================
   2. TABLET & DESKTOP (Large Screens)
   ========================================================================== */
@media only screen and (min-width: 1024px) {
    .dataTables_wrapper .dataTables_filter { 
        margin: 5px 0 10px 0; /* Changed from -25px to 5px */
    }
    .ru_courses_content .table_controls { 
        margin: 3px 0 10px 40px; 
    } 
}

/* ==========================================================================
   3. MOBILE & SMALL TABLET (Final Alignment & Header Fix)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 1. Force the table to behave */
    .ru_courses_content table.dataTable.ru-mobile-collapse { 
        table-layout: fixed !important;
        width: 100% !important;
    }

    /* 2. Hide Yr, Term, and Cr columns in the main rows */
    /* Column 2=Yr, 3=Term, 5=Cr */
    .ru-mobile-collapse tbody tr td:nth-child(2),
    .ru-mobile-collapse tbody tr td:nth-child(3),
    .ru-mobile-collapse tbody tr td:nth-child(5),
    .ru-mobile-collapse thead th:nth-child(2),
    .ru-mobile-collapse thead th:nth-child(3),
    .ru-mobile-collapse thead th:nth-child(5) {
        display: none !important;
    }

    /* 3. Fix the Header (Ensure Title is visible) */
    .ru-mobile-collapse thead th:nth-child(4) { width: 30% !important; display: table-cell !important; }
    .ru-mobile-collapse thead th:nth-child(6) { width: 60% !important; display: table-cell !important; }

    /* 4. Fix Main Row alignment */
    .ru-mobile-collapse tbody tr td:nth-child(4),
    .ru-mobile-collapse tbody tr td:nth-child(6) {
        display: table-cell !important; /* Changed from block to keep them side-by-side if you prefer, or keep block for stacking */
        text-align: left !important;
        vertical-align: top !important;
        padding: 10px 5px !important;
        white-space: normal !important;
    }

    /* 5. THE CENTERING KILLER (Final Version) */
    
    /* Force the cell container to be left-aligned */
    .ru_courses_content .ru-mobile-collapse tr.child td.child {
        text-align: left !important;
        padding-left: 15px !important;
    }

    /* Target the details list that DataTables injects */
    .ru-mobile-collapse tr.child ul.dtr-details {
        display: block !important;
        width: 100% !important;
        margin: 0 !important; /* Removes the centering margin */
        padding: 0 !important;
        text-align: left !important;
    }

    /* Target every element inside the expanded area */
    .ru-mobile-collapse tr.child td.child *,
    .ru-mobile-collapse tr.child ul.dtr-details li {
        text-align: left !important;
        display: block !important; 
        width: 100% !important;
        margin-left: 0 !important; /* Forces it to the left wall */
        margin-right: 0 !important;
        white-space: normal !important;
    }

    /* Force the title/data spans to stay left */
    .ru-mobile-collapse tr.child span.dtr-title,
    .ru-mobile-collapse tr.child span.dtr-data {
        display: block !important;
        text-align: left !important;
        width: 100% !important;
    }

    /* Add space above the search box on mobile */
    .dataTables_wrapper .dataTables_filter {
        margin-top: 20px !important;
        margin-bottom: 10px !important;
        float: none !important;
        text-align: left !important;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        margin-left: 0 !important;
        width: 100% !important; /* Optional: makes the search box full-width on small screens */
        box-sizing: border-box;
    }

    /* Align "Show entries" to the left */
    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
        float: none !important;
        margin-bottom: 10px;
    }

    /* Ensure the label and dropdown stay inline and left-aligned */
    .dataTables_wrapper .dataTables_length label {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 5px; /* Adds a tiny space between the word 'Show' and the dropdown */
    }

    /* Forces the Search container to behave as a row */
    .dataTables_wrapper .dataTables_filter {
        display: flex !important;
        align-items: center !important;
        margin-top: 25px !important; /* This adds the top white space */
        margin-bottom: 15px !important;
    }

    /* This adds the space between the text and the box */
    .dataTables_wrapper .dataTables_filter input {
        margin-left: 15px !important; /* The 'Manual' white space */
        width: auto !important;
        flex-grow: 1;
        border: 1px solid #ced4da !important;
        padding: 4px 8px !important;
    }
}