/* ============================================================
   Acharya ERP - responsive / mobile-friendly overrides
   Loaded LAST so it can safely override the base theme.
   Scope: layout, tables, forms, filters, modals, login.
   ============================================================ */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Footer: was absolutely positioned with width:100%
   which caused a 220px horizontal overflow on desktop. Put it
   back into normal flow. ---------------------------------- */
footer.footer,
#page-wrapper > .footer {
    position: static !important;
    left: auto !important;
    bottom: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 15px;
    background: #fff;
    border-top: 1px solid #e4e7ea;
    font-size: 13px;
    line-height: 1.5;
    z-index: 1;
}

/* ---------- Brand / logo ---------- */
.navbar-header {
    min-height: 60px;
}
.top-left-part .logo img,
.top-left-part img {
    max-height: 44px;
    width: auto !important;
    height: auto !important;
    vertical-align: middle;
}

/* ---------- Content wrappers ---------- */
/* The theme uses a 250px sidebar but only offsets the page by 220px,
   so the first 30px of every page sat underneath the sidebar. Align them. */
@media (min-width: 768px) {
    #page-wrapper {
        margin-left: 250px;
    }
    body.content-wrapper #page-wrapper,
    .content-wrapper #page-wrapper {
        margin-left: 60px;
    }
}

/* Neutralise the theme's odd hard-coded header bleed margins */
.bg-title {
    margin-left: 0;
    margin-right: 0;
}

#page-wrapper .container-fluid {
    padding-left: 15px;
    padding-right: 15px;
}

.page-title {
    margin: 6px 0 0;
}

/* Buttons keep their label readable when wrapped */
.btn {
    white-space: normal;
}
.actionbtn {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.actionbtn .btn {
    margin-bottom: 4px;
}

/* ---------- Wide tables ---------- */
.table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-responsive > .table,
.table-responsive > table.dataTable {
    margin-bottom: 0;
}

/* Keep the checkbox / select column compact (it used to
   stretch to ~268px and push every other column off screen). */
#tblstudentinfo th:first-child,
#tblstudentinfo td:first-child,
#tblPreStudentInfo th:first-child,
#tblPreStudentInfo td:first-child {
    width: 42px !important;
    min-width: 42px;
    max-width: 42px;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}

/* Give the row-actions column enough room so buttons don't spill
   over the neighbouring cell. */
#tblstudentinfo th:nth-child(2),
#tblstudentinfo td:nth-child(2),
#tblPreStudentInfo th:nth-child(2),
#tblPreStudentInfo td:nth-child(2) {
    min-width: 225px;
}

/* DataTables controls: allow wrapping on narrow screens */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dt-buttons {
    margin-bottom: 8px;
}

/* ---------- Modals ---------- */
.modal-dialog {
    max-width: calc(100% - 24px);
}

/* ---------- Filter panel ---------- */
.panel .panel-heading .panel-title {
    font-size: 16px;
}

/* ============================================================
   PHONES  (<= 767px)
   ============================================================ */
@media (max-width: 767px) {
    #page-wrapper .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .bg-title {
        margin-left: -10px !important;
        margin-right: -10px !important;
        padding: 10px 10px 6px;
    }
    .bg-title .breadcrumb {
        float: none !important;
        margin: 4px 0 0;
    }
    .page-title {
        font-size: 18px;
    }

    /* DataTables control bar stacks vertically */
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        width: 100%;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
    .dataTables_wrapper .dataTables_length {
        float: none !important;
        text-align: left;
    }
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 8px;
    }
    .dt-buttons {
        display: block;
        width: 100%;
    }
    .dt-buttons .btn {
        margin-bottom: 6px;
    }
    .dataTables_wrapper table.dataTable,
    .dataTables_wrapper table {
        font-size: 12px;
    }
    .dataTables_wrapper table.dataTable th,
    .dataTables_wrapper table.dataTable td {
        padding: 6px 6px;
        white-space: nowrap;
    }

    /* Student list: keep only the essential columns on phones.
       1 checkbox, 2 Actions, 7 Gen Reg No, 8 Name, 9 Standard, 10 Division.
       Hide Ad Date(3), QR(4), Photo(5), Ad Year(6) and 11+. */
    #tblstudentinfo th:nth-child(3),
    #tblstudentinfo td:nth-child(3),
    #tblstudentinfo th:nth-child(4),
    #tblstudentinfo td:nth-child(4),
    #tblstudentinfo th:nth-child(5),
    #tblstudentinfo td:nth-child(5),
    #tblstudentinfo th:nth-child(6),
    #tblstudentinfo td:nth-child(6),
    #tblstudentinfo th:nth-child(n + 11),
    #tblstudentinfo td:nth-child(n + 11) {
        display: none !important;
    }

    /* Pending-admission list: keep checkbox, Actions, Ad Status,
       Name, Standard, Division. */
    #tblPreStudentInfo th:nth-child(3),
    #tblPreStudentInfo td:nth-child(3),
    #tblPreStudentInfo th:nth-child(5),
    #tblPreStudentInfo td:nth-child(5),
    #tblPreStudentInfo th:nth-child(6),
    #tblPreStudentInfo td:nth-child(6),
    #tblPreStudentInfo th:nth-child(7),
    #tblPreStudentInfo td:nth-child(7),
    #tblPreStudentInfo th:nth-child(n + 11),
    #tblPreStudentInfo td:nth-child(n + 11) {
        display: none !important;
    }

    .modal-dialog {
        margin: 8px;
    }
    .modal-body {
        padding: 12px;
    }

    h3.box-title,
    h4.box-title {
        font-size: 18px;
    }

    /* Compact row-action buttons to icon-only so table columns fit */
    #tblstudentinfo th:nth-child(2),
    #tblstudentinfo td:nth-child(2),
    #tblPreStudentInfo th:nth-child(2),
    #tblPreStudentInfo td:nth-child(2) {
        min-width: 120px;
    }
    #tblstudentinfo td .btn,
    #tblPreStudentInfo td .btn,
    #tbldocument td .btn {
        font-size: 0 !important;
        line-height: 1;
        padding: 8px 9px !important;
        margin: 0 1px 0 0;
    }
    #tblstudentinfo td .btn i,
    #tblPreStudentInfo td .btn i,
    #tbldocument td .btn i {
        font-size: 14px !important;
        margin: 0 !important;
    }

    /* Stack form labels above inputs in horizontal forms */
    .form-horizontal .control-label,
    .form-material .control-label {
        text-align: left !important;
        margin-bottom: 4px;
    }

    /* Inputs / selects are comfortable to tap */
    .form-control,
    .select2-container,
    .btn {
        font-size: 14px;
    }
    select.form-control:not([size]):not([multiple]) {
        height: auto;
        min-height: 38px;
    }

    .login-box {
        width: 100%;
    }
    .login-sidebar {
        position: relative !important;
        height: auto;
        min-height: 100vh;
    }
}

/* ============================================================
   TABLETS  (768px - 991px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 991px) {
    #page-wrapper .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    .dataTables_wrapper .dataTables_filter input {
        width: 180px;
    }
    /* On tablets drop the noisiest columns but keep more than mobile */
    #tblstudentinfo th:nth-child(4),
    #tblstudentinfo td:nth-child(4),
    #tblstudentinfo th:nth-child(21),
    #tblstudentinfo td:nth-child(21),
    #tblstudentinfo th:nth-child(24),
    #tblstudentinfo td:nth-child(24),
    #tblstudentinfo th:nth-child(25),
    #tblstudentinfo td:nth-child(25),
    #tblstudentinfo th:nth-child(28),
    #tblstudentinfo td:nth-child(28),
    #tblstudentinfo th:nth-child(29),
    #tblstudentinfo td:nth-child(29) {
        display: none !important;
    }
}
