@import "../components/navbar/navbar-dropdowns.css";
@import "../components/sidebar/sidebar-default.css";

/* ── Fonts ────────────────────────────────────────────────────────────── */
@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../font/Lato-Regular.eot");
    src: url("../font/Lato-Regular.eot?#iefix") format("embedded-opentype"),
         url("../font/Lato-Regular.woff") format("woff"),
         url("../font/Lato-Regular.ttf") format("truetype");
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    width: 100%;
    min-height: 100vh;
    background: linear-gradient(160deg, #eef2fb 0%, #e4eaf8 100%);
    background-attachment: fixed;
    font-family: "Lato", "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-size: 1rem;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a, a:hover, a:focus {
    color: inherit;
    text-decoration: none;
    transition: all .25s;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    overflow-x: hidden;
}

#body {
    width: 100%;
    min-height: 100vh;
    transition: all .28s;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Top navbar ───────────────────────────────────────────────────────── */
#body > .navbar,
#topNavbar .navbar {
    background: #fff !important;
    min-height: 54px;
    padding: 0 1.5rem;
    box-shadow: none;
    border-bottom: 1px solid rgba(101,109,119,.16);
    position: sticky;
    top: 0;
    z-index: 1030;
}

#topNavbar .nav-link {
    color: #444 !important;
    font-size: .92rem;
    padding: .4rem .6rem !important;
}

#topNavbar .dropdown-menu {
    border: 1px solid rgba(0,0,0,.1);
    box-shadow: 0 6px 24px rgba(30,60,130,.12);
    border-radius: 8px;
    font-size: .9rem;
    min-width: 160px;
}

/* ── Content area ─────────────────────────────────────────────────────── */
#body > .content {
    flex: 1;
    padding: .75rem 1rem 1.5rem;
}

#body .content .page-title {
    margin-bottom: .25rem;
}

#body .content .page-title h3 {
    margin: .75rem 0 .5rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a3a7c;
}

/* ── Boxes / Cards ────────────────────────────────────────────────────── */
.box {
    position: relative;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(30,60,130,.08);
    margin-bottom: 1.25rem;
    width: 100%;
    box-shadow: 0 2px 16px rgba(30,60,130,.07);
    overflow: hidden;
}

.box-body {
    padding: 1rem;
}

.box-footer {
    border-top: 1px solid #f0f4fb;
    padding: .75rem 1rem;
    background: #fafcff;
    text-align: right;
    border-radius: 0 0 10px 10px;
}

.box-primary {
    border-top: 3px solid #3b82f6;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table td, .table th {
    vertical-align: middle;
}

.table-hover tbody tr:hover td {
    background: #f5f8ff;
}

table.dataTable thead .sorting:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_desc:after {
    font-size: .8rem;
    bottom: .9rem;
}

.dataTables_info { visibility: hidden; }

table.dataTable > tbody > tr.child ul.dtr-details { display: block; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.svg-inline--fa { min-width: 15px; }

.page-pretitle {
    font-size: .78rem;
    text-transform: uppercase;
    color: #6b7a99;
    letter-spacing: .5px;
}

.btn.focus, .btn:focus { box-shadow: none; }
.btn.btn-square { border-radius: 0; }

.nav-tabs { border-bottom: 2px solid #dee2e6; }
.nav-tabs .nav-item { margin-bottom: -2px; }
.nav-tabs .nav-link { border: none; color: inherit; transition: color .15s; }
.nav-tabs .nav-item.show .nav-link,
.nav-tabs .nav-link.active {
    color: #1a56db;
    background: transparent;
    border-bottom: 2px solid #3b82f6;
}
.tab-content { padding: 1rem; }

.bg-lighter-grey { background: #fafcff; }
.line { border-bottom: 1px solid #e8edf8; }

/* ── Default light menu ───────────────────────────────────────────────── */
.default-light-menu {
    border: none !important;
    color: #fff;
}
.default-light-menu:hover {
    background: #2196F3 !important;
    color: #fff;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

/* Mobile: full-width content, tighter padding */
@media (max-width: 768px) {
    #body > .content { padding: .5rem .6rem 1.5rem; }
    #body .content .page-title h3 { font-size: 1.15rem; margin: .5rem 0 .25rem; }
    .box-body { padding: .75rem; }

    /* Stack tables horizontally on small screens */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modal full-width on mobile */
    .modal-dialog { margin: .5rem; }
    .modal-dialog.modal-lg { max-width: calc(100vw - 1rem); }
}

@media (max-width: 576px) {
    #body > .content { padding: .4rem .4rem 1.5rem; }
    .box-body { padding: .6rem; }

    /* Hide less-important table columns via data-attrs if needed */
    .col-hide-xs { display: none !important; }

    /* Buttons: icon-only on very small */
    .btn-sm .btn-label-hide-xs { display: none; }
}

/* Large screens: more breathing room */
@media (min-width: 1400px) {
    #body > .content { padding: 1rem 1.5rem 2rem; }
}

/* Form controls */
.form-control:focus, .form-select:focus {
    border-color: #7baff0;
    box-shadow: 0 0 0 .2rem rgba(59,130,246,.15);
}

/* Bootstrap table-light header */
.table-light th {
    background: #f0f4fb !important;
    color: #334;
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* Badge tweaks */
.badge { font-weight: 600; letter-spacing: .2px; }

/* Scrollbar (webkit) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f4fb; }
::-webkit-scrollbar-thumb { background: #b8c8e8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #8aaad4; }

/* ═══════════════════════════════════════════════════════════════
   MANAGEMENT PAGE COMPONENTS
   Applies to: customers, optometry, stores, staffs, user-roles
   ═══════════════════════════════════════════════════════════════ */

/* ── Page title row ─────────────────────────────────────────── */
.page-title h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a3a7c;
    margin: .6rem 0 .75rem;
    padding-bottom: .6rem;
    border-bottom: 2px solid #e8edf8;
}
.page-title h3 .float-end { float: none !important; }

/* ── Toolbar (search row) ───────────────────────────────────── */
.input-group .form-control:first-child { border-radius: 8px 0 0 8px; }
.input-group .form-control:only-child  { border-radius: 8px; }
.input-group > .btn:last-child         { border-radius: 0 8px 8px 0; }
.input-group > .btn:first-child        { border-radius: 8px 0 0 8px; }
.input-group > .form-select:last-child { border-radius: 0 8px 8px 0; }

/* ── DataTables Responsive control ─────────────────────────────── */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    background-color: #1a3a7c;
    border-color: #1a3a7c;
    box-shadow: none;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control::before {
    background-color: #198754;
    border-color: #198754;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom-color: #eef0f8;
    font-size: .88rem;
    padding: .35rem 0;
}
table.dataTable > tbody > tr.child span.dtr-title {
    font-size: .78rem;
    font-weight: 700;
    color: #6b7a99;
    text-transform: uppercase;
    letter-spacing: .3px;
    min-width: 110px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
    font-size: .9rem;
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    padding: .55rem .75rem;
}
.table td:last-child, .table th:last-child { white-space: nowrap; }

/* Empty / loading state rows */
.table tbody tr td.text-center.py-3,
.table tbody tr td.text-center.py-4,
.table tbody tr td.text-center.py-5 {
    color: #8a9bc0;
    font-style: italic;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(13,27,62,.22), 0 4px 20px rgba(0,0,0,.1);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, #f5f8ff 0%, #edf1fc 100%);
    border-bottom: 1px solid #dce7f8;
    padding: .875rem 1.25rem;
    align-items: center;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1a3a7c;
}

.modal-body { padding: 1.25rem 1.25rem 1rem; }

.modal-footer {
    background: #f8faff;
    border-top: 1px solid #e8edf8;
    padding: .75rem 1.25rem;
    gap: .5rem;
}

/* Form labels inside modals */
.modal .form-label {
    font-size: .76rem;
    font-weight: 700;
    color: #5a6a8a;
    text-transform: uppercase;
    letter-spacing: .45px;
    margin-bottom: .28rem;
}

/* Form controls inside modals */
.modal .form-control,
.modal .form-select {
    border-radius: 7px;
    border-color: #d0daf0;
    font-size: .92rem;
    transition: border-color .18s, box-shadow .18s;
}
.modal .form-control:focus,
.modal .form-select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(59,130,246,.13);
}
.modal .form-control[readonly] {
    background: #f5f8ff;
    color: #6b7a99;
}

/* Delete confirm modal */
.modal-sm .modal-body {
    text-align: center;
    padding: 1.75rem 1.25rem 1rem;
}
.modal-sm .modal-body .text-danger {
    font-size: 2.2rem;
    opacity: .75;
    display: block;
    margin-bottom: .5rem;
}

/* ── Table placeholder (empty / loading / error state) ─────── */
.tbl-placeholder {
    display: none;
    text-align: center;
    padding: 2.75rem 1rem 2.25rem;
    color: #9aa4b5;
    border: 1px solid #e8edf5;
    border-radius: 8px;
    background: #fafbff;
}
.tbl-placeholder.show { display: block; }
.tbl-placeholder .tbl-ph-icon {
    font-size: 2rem;
    opacity: .2;
    display: block;
    margin-bottom: .6rem;
}
.tbl-placeholder .tbl-ph-msg {
    font-size: .88rem;
}
.tbl-placeholder .tbl-ph-spinner {
    display: flex;
    justify-content: center;
    margin-bottom: .5rem;
}

/* ── Customer info panel (optometry) ───────────────────────── */
.customer-info-table {
    border-radius: 8px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8faff, #f0f5ff) !important;
    border: 1px solid #dce7f8 !important;
    font-size: .88rem;
}
.customer-info-table td {
    padding: .45rem .75rem !important;
    border-color: #e8edf8 !important;
}
.customer-info-table td:first-child,
.customer-info-table td:nth-child(3) {
    color: #6b7a99;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
    background: rgba(255,255,255,.5);
}

/* Mobile: bảng 4 cột wrap thành 2 cột (label+value / label+value) */
@media (max-width: 575px) {
    .customer-info-table,
    .customer-info-table tbody,
    .customer-info-table tr {
        display: block;
    }
    .customer-info-table tr {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 1px solid #e8edf8;
    }
    .customer-info-table tr:last-child { border-bottom: none; }
    .customer-info-table td {
        flex: 0 0 50%;
        max-width: 50%;
        border-top: none !important;
        border-left: none !important;
        padding: .4rem .6rem !important;
    }
    .customer-info-table td:nth-child(even) {
        border-right: none !important;
    }
    .customer-info-table td:first-child,
    .customer-info-table td:nth-child(3) {
        white-space: normal;
    }
}

/* ── No-customer empty state ────────────────────────────────── */
#noCustomerState {
    padding: 3.5rem 1rem;
    background: linear-gradient(135deg, #f8faff, #f0f4fb);
    border-radius: 10px;
    border: 2px dashed #cdd8ee;
    color: #8a9bc0;
}
#noCustomerState .fas {
    font-size: 3rem;
    color: #c4d2ea;
    display: block;
    margin-bottom: .75rem;
}

/* ── Vote list section header ───────────────────────────────── */
#recordsSection .d-flex.justify-content-between {
    background: #f5f8ff;
    border-radius: 8px;
    padding: .5rem .875rem;
    border: 1px solid #e0e8f8;
}
#recordsSection .text-muted {
    font-size: .88rem;
}

/* ── Eye measurement form (optometry modal) ─────────────────── */
#modalVote .table-responsive {
    border-radius: 8px;
    border: 1px solid #e0e8f8;
    overflow: hidden;
}
#modalVote .table-bordered {
    margin-bottom: 0;
}
#modalVote .table-bordered td[rowspan] {
    font-size: .82rem;
    letter-spacing: .3px;
    background: #f8faff;
}
#modalVote .table td[rowspan].text-danger { background: #fff5f5; color: #c0392b !important; }
#modalVote .table td[rowspan].text-primary { background: #f0f5ff; color: #1a56db !important; }

/* Compact inputs in measurement table */
#modalVote .form-control-sm {
    min-width: 52px;
    padding: .25rem .35rem;
    font-size: .85rem;
    text-align: center;
    border-radius: 5px;
    border-color: #d0daf0;
}
#modalVote .form-control-sm:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}
#modalVote hr { border-color: #e8edf8; margin: 1rem 0; }

/* Customer info in vote modal */
#voteCustomerInfo {
    background: linear-gradient(135deg, #f0f5ff, #e8f0fe) !important;
    border: 1px solid #cdd8f0 !important;
    border-radius: 8px !important;
    font-size: .87rem !important;
}

/* ── Vote preview modal ─────────────────────────────────────── */
#modalVotePreview .modal-body { padding: 1.25rem; }

/* ── Action buttons in table rows ───────────────────────────── */
.btn-outline-info.btn-sm,
.btn-outline-danger.btn-sm,
.btn-outline-success.btn-sm,
.btn-outline-secondary.btn-sm,
.btn-outline-dark.btn-sm,
.btn-outline-primary.btn-sm {
    border-radius: 6px;
    padding: .25rem .5rem;
    font-size: .8rem;
    transition: all .15s;
}
.btn-outline-info.btn-sm:hover    { background: #0dcaf0; color: #fff; border-color: #0dcaf0; }
.btn-outline-danger.btn-sm:hover  { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-outline-success.btn-sm:hover { background: #198754; color: #fff; border-color: #198754; }
.btn-outline-dark.btn-sm:hover    { background: #333; color: #fff; border-color: #333; }

/* ── Box header with add button ─────────────────────────────── */
.box .box-body > .row:first-child {
    margin-bottom: .75rem;
}

/* ── Responsive: Mobile ─────────────────────────────────────── */
@media (max-width: 768px) {
    /* Stack search bar + heading vertically */
    .page-title h3 { font-size: 1.1rem; padding-bottom: .4rem; }

    /* Full-width modals */
    .modal-dialog { margin: .4rem; }
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl { max-width: calc(100vw - .8rem); }
    .modal-body { padding: 1rem .875rem .875rem; }

    /* Eye measurement table — horizontal scroll */
    #modalVote .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    #modalVote .form-control-sm  { min-width: 46px; }

    /* Customer info table — stack columns */
    .customer-info-table { font-size: .82rem; }
    .customer-info-table td:first-child,
    .customer-info-table td:nth-child(3) { font-size: .72rem; }

    /* Action buttons — tighter */
    .btn-outline-info.btn-sm, .btn-outline-danger.btn-sm,
    .btn-outline-success.btn-sm, .btn-outline-secondary.btn-sm,
    .btn-outline-dark.btn-sm, .btn-outline-primary.btn-sm {
        padding: .2rem .4rem;
    }

    /* Form columns — full width on mobile */
    .modal .row > [class*="col-md-"] { margin-bottom: .1rem; }
}

@media (max-width: 576px) {
    .modal-dialog { margin: .25rem; }
    .modal-content { border-radius: 10px; }
    .modal-header { padding: .75rem 1rem; }
    .modal-body { padding: .875rem .75rem .75rem; }
    .modal-footer { padding: .6rem .75rem; }

    /* Hide less critical table columns */
    .table .col-hide-sm { display: none; }

    /* Stack the measurement form row items */
    #modalVote .row.g-3 > [class*="col-md-"] { width: 100% !important; }
}
