/*
 * LiveSales – Custom UI/UX Overrides
 * Extends the Vito Template with app-specific responsive rules.
 *
 * Load order: after variable.css, style.css, responsive.css
 */

/* ─── 1. Typography & Base ──────────────────────────────────────────── */

body {
    font-size: 14px;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--iq-title-text);
}

a {
    color: var(--iq-primary);
    transition: color 150ms ease;
}

/* ─── 2. Card Enhancements ──────────────────────────────────────────── */

.iq-card {
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 16px var(--iq-card-shadow-1);
    transition: box-shadow 200ms ease, transform 200ms ease;
    background: var(--iq-card-bg);
    margin-bottom: 24px;
}

.iq-card:hover {
    box-shadow: 0 4px 24px var(--iq-card-shadow-2);
}

.iq-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--iq-light-border);
    background: transparent;
}

.iq-card-body {
    padding: 20px;
}

/* Stat / KPI cards */
.iq-card-block .iq-card-body h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.iq-iconbox {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ─── 3. Sidebar ────────────────────────────────────────────────────── */

.iq-sidebar {
    z-index: 1040;
}

.iq-sidebar-menu .iq-menu li a {
    border-radius: 8px;
    margin: 2px 8px;
    transition: background 150ms ease, color 150ms ease;
}

.iq-sidebar-menu .iq-menu li.active > a,
.iq-sidebar-menu .iq-menu li > a:hover {
    color: var(--iq-primary);
    background: var(--iq-light-primary);
}

.iq-sidebar-menu .iq-menu li.active > a i,
.iq-sidebar-menu .iq-menu li > a:hover i {
    color: var(--iq-primary);
}

.iq-menu-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--iq-icon-color);
    padding: 20px 20px 6px;
    font-weight: 600;
}

/* ─── 4. Top Navbar ─────────────────────────────────────────────────── */

/*
 * style.css sets min-height:73px and the 20px top margin on .iq-navbar-custom.
 * We let those stand; only add what's needed for the LiveSales layout.
 */

/* Flex row containing: quick-icons | search */
.iq-top-navbar .navbar-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

/*
 * style.css sets `ul#topbar-data-icon { margin: -60px 10px 0 }` — that negative
 * top margin was designed for a layout where a logo row sits above the icons.
 * We have no such row, so reset it to zero.
 */
ul#topbar-data-icon {
    margin: 0;
}

/* Quick-nav icon links */
.topbar-menu-icon li a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: var(--iq-icon-color);
    transition: color 150ms ease, background 150ms ease;
}

.topbar-menu-icon li a:hover {
    color: var(--iq-primary);
}

/* ── Sidebar toggle (.iq-menu-bt / .wrapper-menu) ────────────────────
 *
 * style.css: .iq-top-navbar .iq-navbar-custom .iq-menu-bt { display:none }
 * — the template hides it on desktop (≥1300px) because the sidebar
 *   has its own .iq-menu-bt-sidebar.  We want it always visible, so we
 *   forcibly re-enable it and keep it in the normal document flow.
 *
 * responsive.css at ≤1299px: display:inline-block; position:absolute; right:440px
 * — on tablet/mobile that absolute placement already works fine.
 * ─────────────────────────────────────────────────────────────────── */

/* Always show — override the default display:none */
.iq-top-navbar .iq-navbar-custom .iq-menu-bt {
    display: flex !important;
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
}

/* Desktop only: keep it in flow (not absolutely positioned like responsive.css does) */
@media (min-width: 1300px) {
    .iq-top-navbar .iq-navbar-custom .iq-menu-bt {
        position: static !important;
    }
}

/* Wrapper-menu icon: use primary colour for clear contrast on light card bg */
.iq-top-navbar .wrapper-menu {
    font-size: 26px;
    color: var(--iq-primary);
}

.iq-top-navbar .wrapper-menu .main-circle,
.iq-top-navbar .wrapper-menu .hover-circle {
    color: var(--iq-primary);
    line-height: 1;
}

/* Dark mode: white icons on dark card background */
body.dark .iq-top-navbar .wrapper-menu .main-circle,
body.dark .iq-top-navbar .wrapper-menu .hover-circle {
    color: var(--iq-white);
}

/* ── Search bar ──────────────────────────────────────────────────────
 * Match style.css defaults (background: --iq-body-bg, border:none,
 * border-radius:8px) but keep the dropdown visible.
 * ─────────────────────────────────────────────────────────────────── */

.iq-search-bar .searchbox {
    width: 480px;
    background: var(--iq-body-bg);
    border: none;
    border-radius: 8px;
    overflow: visible;  /* searchbox-datalink uses position:absolute */
    position: relative;
}

.iq-search-bar .search-input {
    background: transparent;
    border: none;
    padding: 5px 40px 5px 15px;
    font-size: 14px;
    color: var(--iq-body-text);
    width: 100%;
}

.iq-search-bar .search-input:focus {
    outline: none;
}

.iq-search-bar .search-link {
    position: absolute;
    right: 15px;
    top: 2px;
    font-size: 16px;
    color: var(--iq-icon-color);
}

/* Suggestion dropdown panel */
.searchbox-datalink {
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

.searchbox-datalink ul li a {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--iq-body-text);
    text-decoration: none;
    transition: background 120ms ease;
}

/* ── Notification icon ────────────────────────────────────────────── */

.ls-nav-icon {
    font-size: 1.4rem;
    color: var(--iq-icon-color);
    display: block;
    line-height: 1;
}

/* Dot badge: position relative to its nav-item anchor */
.nav-item span.dots {
    top: 14px;
    right: 8px;
}

/* ── Responsive search width ──────────────────────────────────────── */

@media (min-width: 768px) and (max-width: 1299.98px) {
    .iq-search-bar .searchbox {
        width: 220px;
    }
}

@media (min-width: 1300px) {
    .iq-search-bar .searchbox {
        width: 380px;
    }
}

/* ─── 5. Tables ─────────────────────────────────────────────────────── */

.table-responsive {
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

.table thead th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--iq-title-text);
    white-space: nowrap;
    padding: 12px 16px;
    border-bottom: 2px solid var(--iq-light-border);
    background: var(--iq-color-light);
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 14px;
    border-bottom: 1px solid var(--iq-light-border);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--iq-color-light);
    transition: background 100ms ease;
}

/* Action icon buttons in tables */
.table .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 150ms ease, transform 150ms ease;
}

.table .action-btn:hover {
    transform: scale(1.1);
}

/* ─── 6. Forms ──────────────────────────────────────────────────────── */

.form-control {
    border-radius: 8px;
    border: 1px solid var(--iq-dark-border);
    padding: 8px 14px;
    font-size: 14px;
    height: auto;
    min-height: 40px;
    color: var(--iq-body-text);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-control:focus {
    border-color: var(--iq-primary);
    box-shadow: 0 0 0 3px var(--iq-light-primary);
    outline: none;
}

.form-control::placeholder {
    color: var(--iq-icon-color);
    opacity: 0.8;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--iq-title-text);
    margin-bottom: 6px;
}

.input-group-text {
    background: var(--iq-color-light);
    border: 1px solid var(--iq-dark-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--iq-icon-color);
}

/* Select2 Vito alignment */
.select2-container--default .select2-selection--single {
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--iq-dark-border);
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0 14px;
    color: var(--iq-body-text);
    font-size: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 8px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--iq-primary);
    box-shadow: 0 0 0 3px var(--iq-light-primary);
}

/* ─── 7. Buttons ────────────────────────────────────────────────────── */

.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 18px;
    transition: all 150ms ease;
    min-height: 36px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--iq-primary);
    border-color: var(--iq-primary);
}

.btn-primary:hover {
    background: var(--iq-primary-dark);
    border-color: var(--iq-primary-dark);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    min-height: 30px;
}

/* ─── 8. Badges & Status Pills ──────────────────────────────────────── */

.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
}

.badge-pill {
    border-radius: 100px;
}

/* ─── 9. Modals ─────────────────────────────────────────────────────── */

.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.modal-header {
    background: var(--iq-primary);
    color: #fff;
    padding: 16px 20px;
    border-bottom: none;
}

.modal-header .modal-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.modal-header .close {
    color: #fff;
    opacity: 0.8;
    text-shadow: none;
}

.modal-header .close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--iq-light-border);
}

/* ─── 10. Alerts & Toasts ───────────────────────────────────────────── */

.alert {
    border-radius: 8px;
    border-left: 4px solid transparent;
    font-size: 14px;
    padding: 12px 16px;
}

.alert-success { border-left-color: var(--iq-success); }
.alert-danger   { border-left-color: var(--iq-danger);  }
.alert-warning  { border-left-color: var(--iq-warning); }
.alert-info     { border-left-color: var(--iq-info);    }

/* ─── 11. Page Loader ───────────────────────────────────────────────── */

/*
 * Override typography.css which sets z-index:999999.
 * CSS animation is the last-resort failsafe: if JS never hides the loader
 * (e.g. custom.js errors, dark-mode re-activation), CSS auto-dismisses it
 * after 1.8s and immediately stops it from blocking pointer events.
 */
#loading {
    background: var(--iq-white) !important; /* always light — no dark overlay */
    z-index: 9999 !important;
    /* Failsafe dismiss: fades out 1.8s after page load */
    animation: ls-dismiss-loader 0.4s ease 1.8s forwards;
}

/* Dark mode must NOT turn #loading into a dark blocking overlay */
body.dark #loading {
    background: var(--iq-white) !important;
}

@keyframes ls-dismiss-loader {
    to {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

#loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ─── 12. Responsive — Mobile (<768px) ─────────────────────────────── */

@media (max-width: 767.98px) {

    .content-page {
        padding: 70px 12px 12px;
    }

    .iq-card-body {
        padding: 14px;
    }

    .iq-card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Stack KPI cards vertically with proper spacing */
    .row .col-lg-3,
    .row .col-md-6 {
        margin-bottom: 12px;
    }

    /* Tables: allow horizontal scroll with a hint shadow */
    .table-responsive {
        box-shadow: inset -8px 0 8px -8px rgba(0,0,0,0.08);
    }

    .table thead th,
    .table tbody td {
        font-size: 12px;
        padding: 10px 12px;
    }

    /* Modals: full width on mobile */
    .modal-dialog {
        margin: 8px;
    }

    /* Forms: full-width inputs */
    .form-group .form-control,
    .form-group .input-group {
        width: 100%;
    }

    /* Flatten filter bars */
    .iq-card-body .d-flex.align-items-center.flex-wrap {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .date-range-picker .d-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .date-range-picker .input-group {
        width: 100%;
        margin: 0 !important;
    }

    .date-range-picker .btn {
        margin: 0 !important;
    }

    /* Chart containers: reduce height on mobile */
    .chart-container,
    #cash-flow-chart,
    #donut-chart,
    #yearly-comparison-chart {
        height: 250px !important;
        min-height: 250px !important;
    }

    /* Login page: stack columns */
    .sign-in-page .col-sm-6:last-child {
        display: none;
    }

    .sign-in-page .col-sm-6:first-child {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    .sign-in-from {
        padding: 24px 20px;
    }
}

/* ─── 13. Responsive — Tablet (768–1023px) ──────────────────────────── */

@media (min-width: 768px) and (max-width: 1023.98px) {

    .content-page {
        padding: 80px 16px 16px;
    }

    .chart-container,
    #cash-flow-chart,
    #yearly-comparison-chart {
        height: 300px !important;
        min-height: 300px !important;
    }

    .date-range-picker .d-flex {
        flex-wrap: wrap;
        gap: 8px;
    }

    .date-range-picker .input-group {
        margin: 0 !important;
    }

    .date-range-picker .btn {
        margin: 0 !important;
    }
}

/* ─── 14. Responsive — Laptop (1024–1439px) ─────────────────────────── */

@media (min-width: 1024px) and (max-width: 1439.98px) {

    .iq-card-block .iq-card-body h2 {
        font-size: 1.5rem;
    }

    .iq-iconbox {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
}

/* ─── 15. Responsive — Desktop (≥1440px) ───────────────────────────── */

@media (min-width: 1440px) {

    .container-fluid {
        padding-left: 24px;
        padding-right: 24px;
    }

    .iq-card-block .iq-card-body h2 {
        font-size: 2rem;
    }
}

/* ─── 16. Ultra-wide (≥1920px) ─────────────────────────────────────── */

@media (min-width: 1920px) {

    /* Note: do NOT apply to .content-page as it gets left margin from sidebar CSS */
    .iq-card,
    .container-fluid {
        max-width: 1760px;
    }
}

/* ─── 17. Dark Mode ─────────────────────────────────────────────────── */

body.dark {
    background: var(--iq-dark-body-bg);
    color: var(--iq-dark-body-text);
}

body.dark .iq-card {
    background: var(--iq-dark-card-bg);
    box-shadow: 0 2px 16px var(--iq-dark-shadow-1);
}

body.dark .iq-card-header {
    border-color: rgba(255,255,255,0.08);
}

body.dark .form-control {
    background: var(--iq-dark-hover-bg);
    border-color: rgba(255,255,255,0.12);
    color: var(--iq-dark-body-text);
}

body.dark .table thead th {
    background: var(--iq-dark-hover-bg);
    color: var(--iq-dark-title-text);
}

body.dark .table tbody td {
    border-color: rgba(255,255,255,0.08);
    color: var(--iq-dark-body-text);
}

body.dark .table tbody tr:hover {
    background: var(--iq-dark-hover-bg);
}

body.dark .modal-content {
    background: var(--iq-dark-card-bg);
}

body.dark .modal-body,
body.dark .modal-footer {
    color: var(--iq-dark-body-text);
}

/* ─── 18. Accessibility / Focus ─────────────────────────────────────── */

:focus-visible {
    outline: 2px solid var(--iq-primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--iq-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ─── 19. Utilities ─────────────────────────────────────────────────── */

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer { cursor: pointer; }

.opacity-75 { opacity: 0.75; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

/* Smooth scrollbar support for sidebar */
#sidebar-scrollbar {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--iq-primary) var(--iq-color-light);
}

#sidebar-scrollbar::-webkit-scrollbar {
    width: 4px;
}

#sidebar-scrollbar::-webkit-scrollbar-track {
    background: var(--iq-color-light);
}

#sidebar-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--iq-primary);
    border-radius: 4px;
}

/* Progress bar animation */
.iq-progress-bar {
    background: var(--iq-progress-light);
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
}

.iq-progress-bar span {
    display: block;
    height: 100%;
    border-radius: 100px;
    width: 0;
    transition: width 800ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
