/* --------------------------------------------------------------------------
   Phone layout for the back-office forms.

   Loaded after styles.css by header.php and auth/login.php. Every rule sits
   inside the phone media query, so computers and tablets (768px and up) render
   exactly as before. The POS screen has its own phone rules in
   dev/css/custom.css and does not load this file.
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {

    /* A little more room for the form itself on a narrow screen */
    .content {
        padding: 10px 8px;
    }
    .content-header {
        padding: 10px 8px 0;
    }
    .box-body {
        padding: 10px 8px;
    }

    /* Box header buttons (Add / Export / ...) are absolutely positioned at the
       top right, where on a phone they cover the box title. Put them on their
       own line under the title and let them wrap. */
    .box-header > .box-tools {
        position: static;
        float: none !important;
        margin-top: 8px;
    }
    .box-header > .box-tools .btn {
        margin: 0 4px 4px 0;
    }
    .box-header > .box-title {
        line-height: 1.4;
    }

    /* Inputs inside item tables (purchases, adjustments, combo products,
       payments): the table already scrolls sideways, so give each input a
       usable width instead of letting it shrink to a few characters. */
    .table-responsive > .table > tbody > tr > td .form-control,
    .table-responsive > .table > tbody > tr > td .select2-container {
        min-width: 80px;
    }

    /* List tables: tighter cells, and less of the room DataTables reserves
       for its sort arrows, so more columns fit before the table scrolls */
    .table-responsive > .table > thead > tr > th,
    .table-responsive > .table > tbody > tr > td {
        padding: 6px 5px;
    }
    .table-responsive > table.dataTable thead > tr > th.sorting,
    .table-responsive > table.dataTable thead > tr > th.sorting_asc,
    .table-responsive > table.dataTable thead > tr > th.sorting_desc {
        padding-right: 20px;
    }

    /* Users list: the Status / Actions columns carry inline desktop widths
       (100px / 110px); on a phone they only need to fit their buttons */
    #UTable > thead > tr > th {
        width: auto !important;
    }
    /* DataTables fixes the table at the width it measured on load */
    #UTable {
        width: 100% !important;
    }

    /* Never let a select2 box push its column wider than the screen */
    .select2-container {
        max-width: 100%;
    }

    /* Rows of form buttons wrap with a gap instead of touching */
    .form-group > .btn,
    .modal-footer > .btn {
        margin-bottom: 4px;
    }
    .modal-footer .btn + .btn {
        margin-left: 4px;
    }

    /* Modal forms keep a margin so they do not run edge to edge */
    .modal-dialog {
        margin: 8px;
    }
    .modal-body {
        padding: 12px;
    }

    /* Date/time picker popups stay inside the screen */
    .bootstrap-datetimepicker-widget.dropdown-menu {
        max-width: calc(100vw - 16px);
    }

    /* Long labels wrap instead of overflowing */
    .form-group label,
    .control-label {
        white-space: normal;
        word-wrap: break-word;
    }
}

/* Language flag in the top bar: visible on phones, and its menu pops over
   the page instead of collapsing into the header. */
@media (max-width: 767px) {
    .main-header .navbar .navbar-nav.pull-left { margin: 0; float: left !important; }
    .main-header .navbar .lang-switch { float: left; }
    .main-header .navbar .lang-switch > a { padding: 15px 10px; }
    .main-header .navbar .lang-switch > a img { height: 18px; }
    .main-header .navbar .lang-switch.open .dropdown-menu {
        position: absolute; left: 0; right: auto; top: 100%; min-width: 160px;
        background: #fff; border: 1px solid #ddd; box-shadow: 0 6px 12px rgba(0,0,0,.175); }
    .main-header .navbar .lang-switch.open .dropdown-menu > li > a { color: #333 !important; padding: 8px 15px; }
}
