/* ===== SatyamInvoice — App Overrides (Vuexy core.css provides base theme) ===== */

:root {
    --si-primary: #7367f0;
    --si-primary-hover: #5e50ee;
    --si-primary-subtle: #e9e7fd;
    --si-secondary: #808390;
    --si-success: #28c76f;
    --si-danger: #ff4c51;
    --si-warning: #ff9f43;
    --si-info: #00bad1;
    --si-dark: #2f3349;
    --si-body-bg: #f8f7fa;
    --si-body-color: #6d6b77;
    --si-heading-color: #444050;
    --si-border-color: #e6e6e8;
    --si-card-shadow: 0 0.1875rem 0.75rem 0 rgba(47, 43, 61, 0.14);
    --si-bottom-nav-height: 60px;
    --si-mobile-header-height: 56px;
    --si-radius: 0.375rem;
    --si-radius-lg: 0.5rem;
}

/* ===== Custom Status Badges ===== */
.badge-draft { background-color: var(--si-secondary); color: white; }
.badge-sent { background-color: var(--si-info); color: white; }
.badge-delivered { background-color: var(--si-success); color: white; }
.badge-cancelled { background-color: var(--si-danger); color: white; }
.badge-paid { background-color: var(--si-success); color: white; }
.badge-partial { background-color: var(--si-warning); color: white; }
.badge-overdue { background-color: var(--si-danger); color: white; }

/* ===== Full-width containers ===== */
.container-xxl {
    max-width: 100% !important;
}

/* ===== Card: tighter padding ===== */
.card {
    --bs-card-spacer-y: 1rem;
    --bs-card-spacer-x: 1rem;
}

/* ===== Flatpickr z-index fix ===== */
.flatpickr-calendar {
    z-index: 1060 !important;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

/* ===== Document Items Table ===== */
.document-items-table th {
    font-size: 0.8rem;
    white-space: nowrap;
}
.document-items-table .form-control {
    font-size: 0.85rem;
}
.document-items-table .btn-sm {
    padding: 0.2rem 0.5rem;
}

/* ===== Select2 Bootstrap 5 Override ===== */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid var(--si-border-color);
    border-radius: var(--si-radius);
    padding: 5px 10px;
}
.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--si-primary);
    box-shadow: 0 0 0 0.2rem rgba(115, 103, 240, 0.25);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--si-primary);
}

/* ===== Alerts ===== */
.alert-success { border-left: 4px solid var(--si-success); }
.alert-danger { border-left: 4px solid var(--si-danger); }
.alert-warning { border-left: 4px solid var(--si-warning); }
.alert-info { border-left: 4px solid var(--si-info); }

/* ===== Auth ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--si-body-bg);
}
.auth-card {
    background: white;
    padding: 2rem;
    border-radius: var(--si-radius-lg);
    box-shadow: var(--si-card-shadow);
    width: 100%;
    max-width: 450px;
}

/* ===== PDF ===== */
.pdf-document { font-family: sans-serif; font-size: 12px; color: #333; }
.pdf-header { border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 15px; }
.pdf-table { width: 100%; border-collapse: collapse; }
.pdf-table td, .pdf-table th { border: 1px solid #ddd; padding: 6px 8px; }
.pdf-table th { background: #f5f5f5; font-weight: 600; }

/* ===== Offline Badge ===== */
#offlineBadge {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== DataTables Responsive: disable scroll wrapper so extension can collapse columns ===== */
.table-responsive:has(.datatable),
.table-responsive:has(.dataTable) {
    overflow: visible !important;
}

/* ===== DataTables: length + search on same row, compact spacing ===== */
div.dt-container div.dt-length,
div.dt-container div.dt-search {
    margin-block: 0.5rem !important;
}
div.dt-container .row:has(.dt-layout-start) {
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 0.5rem;
}
div.dt-container .dt-layout-start,
div.dt-container .dt-layout-end {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
}
@media (max-width: 767.98px) {
    div.dt-container div.dt-length,
    div.dt-container div.dt-search,
    div.dt-container div.dt-info,
    div.dt-container div.dt-paging {
        text-align: left !important;
    }
    div.dt-container .dt-search input {
        width: 120px !important;
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    div.dt-container .dt-length select {
        padding: 0.25rem 1.5rem 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    /* Info + paging on separate lines on mobile */
    div.dt-container .row:has(.dt-info) {
        flex-wrap: wrap !important;
    }
    div.dt-container .row:has(.dt-info) .dt-layout-start,
    div.dt-container .row:has(.dt-info) .dt-layout-end {
        flex: 0 0 100% !important;
        width: 100% !important;
    }
    div.dt-container div.dt-info {
        text-align: center !important;
    }
    div.dt-container div.dt-paging {
        margin-top: 0.5rem;
        display: flex;
        justify-content: center;
    }
    div.dt-container div.dt-paging .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ===== DataTables Responsive control arrow ===== */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    border-left-color: var(--si-primary) !important;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > th.dtr-control::before {
    border-top-color: var(--si-danger) !important;
    border-left-color: transparent !important;
}

/* ===== DataTables Responsive child rows ===== */
table.dataTable > tbody > tr.child ul.dtr-details {
    width: 100%;
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid var(--si-border-color);
    padding: 0.5rem 0;
}
table.dataTable > tbody > tr.child span.dtr-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--si-heading-color);
    min-width: 90px;
}
table.dataTable > tbody > tr.child span.dtr-data {
    font-size: 0.875rem;
    color: var(--si-body-color);
}

/* ===================================================================
   MOBILE: Custom header, menu, backdrop, bottom nav (<768px)
   =================================================================== */
.si-mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--si-mobile-header-height);
    background: #fff;
    box-shadow: 0 1px 4px rgba(47, 43, 61, 0.12);
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    z-index: 1080;
    gap: 0.5rem;
    overflow: visible;
}
.si-mobile-header button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--si-heading-color);
    padding: 0.25rem;
    line-height: 1;
    cursor: pointer;
}
.si-mobile-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--si-heading-color);
    flex: 1;
}
.si-mobile-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.si-mobile-header .dropdown-menu {
    font-size: 0.8125rem;
}
.si-mobile-header .dropdown-item {
    font-size: 0.8125rem;
    padding: 0.35rem 0.75rem;
}
.si-mobile-header .dropdown-item-text {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
}

/* ===== Mobile Full Menu (slide-down overlay) ===== */
.si-mobile-menu {
    position: fixed;
    top: var(--si-mobile-header-height);
    left: 0;
    right: 0;
    bottom: var(--si-bottom-nav-height);
    background: #fff;
    z-index: 1070;
    overflow-y: auto;
    padding: 0.75rem 0;
    transform: translateY(-110%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.25s ease;
    pointer-events: none;
}
.si-mobile-menu.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Mobile menu nav list — simple, no Vuexy classes */
.si-mobile-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem;
}
.si-mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    min-height: 48px;
    border-radius: var(--si-radius);
    color: var(--si-body-color);
    text-decoration: none;
    transition: all 0.2s ease;
}
.si-mobile-nav-link i {
    font-size: 1.1rem;
}
.si-mobile-nav-link:hover {
    color: var(--si-primary);
    background: var(--si-primary-subtle);
    text-decoration: none;
}
.si-mobile-nav-link.active {
    color: #fff;
    background: var(--si-primary);
}
.si-mobile-nav-link.active:hover {
    background: var(--si-primary-hover);
    color: #fff;
}
.si-mobile-nav-divider {
    height: 1px;
    background: var(--si-border-color);
    margin: 0.5rem 1rem;
}

/* Mobile menu topbar controls */
.si-mobile-topbar-controls {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--si-border-color);
    margin-top: 0.5rem;
}

.si-mobile-backdrop {
    position: fixed;
    top: var(--si-mobile-header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(47, 43, 61, 0.5);
    z-index: 1060;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.si-mobile-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Mobile Bottom Nav ===== */
.si-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--si-bottom-nav-height);
    background: #fff;
    box-shadow: 0 -2px 8px rgba(47, 43, 61, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1080;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.si-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--si-secondary);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    min-width: 48px;
    min-height: 48px;
    border: none;
    background: none;
    cursor: pointer;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.si-bottom-nav-item i {
    font-size: 1.25rem;
}
.si-bottom-nav-item:hover,
.si-bottom-nav-item.active {
    color: var(--si-primary);
    text-decoration: none;
}
.si-bottom-nav-item.active {
    font-weight: 600;
}
.si-bottom-nav-item.active i {
    transform: scale(1.1);
}

/* ===================================================================
   RESPONSIVE: Mobile (<768px) — hide Vuexy, show our mobile UI
   =================================================================== */
@media (max-width: 767.98px) {
    html {
        height: -webkit-fill-available;
    }
    body {
        min-height: 100dvh;
        min-height: -webkit-fill-available;
    }
    /* Hide Vuexy navbar + menu on mobile, keep content */
    #layout-navbar,
    #layout-menu,
    .layout-overlay {
        display: none !important;
    }
    /* Reset Vuexy's navbar-offset padding on mobile */
    .layout-wrapper,
    .layout-container,
    .layout-page,
    .content-wrapper {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    .layout-navbar ~ .layout-page {
        padding-top: 0 !important;
    }
    /* Our mobile header + bottom nav spacing */
    .container-xxl.flex-grow-1.container-p-y {
        padding: 0.75rem !important;
        margin-top: var(--si-mobile-header-height) !important;
        margin-bottom: var(--si-bottom-nav-height) !important;
    }

    body {
        font-size: 0.8125rem;
    }

    h1, .h1 { font-size: 1.375rem; }
    h2, .h2 { font-size: 1.2rem; }
    h3, .h3 { font-size: 1.075rem; }
    h4, .h4 { font-size: 0.975rem; }
    h5, .h5 { font-size: 0.875rem; }
    h6, .h6 { font-size: 0.8125rem; }

    .page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        margin-bottom: 0;
    }
    .page-header h4 {
        font-size: 0.95rem;
        margin-bottom: 0;
    }

    .btn-action .btn-text {
        display: none;
    }

    .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.75rem;
    }
    .btn-sm {
        font-size: 0.725rem;
        padding: 0.2rem 0.5rem;
    }

    .form-control, .form-select {
        font-size: 0.8125rem;
        padding: 0.35rem 0.65rem;
    }
    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .badge {
        font-size: 0.675rem;
        padding: 0.25em 0.5em;
    }

    .card-body {
        padding: 0.75rem;
    }
    .card-header {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .alert {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    .select2-container--default .select2-selection--single {
        height: 34px;
        padding: 3px 8px;
        font-size: 0.8125rem;
    }

    /* ── Mobile Card Layout for Line Item Tables ── */
    #itemsTable thead {
        display: none;
    }
    #itemsTable tbody tr.item-row {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--si-border-color);
        border-radius: 0.5rem;
        padding: 0.75rem;
        background: #fff;
        box-shadow: 0 1px 3px rgba(47, 43, 61, 0.08);
    }
    #itemsTable tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0;
        border: none !important;
    }
    #itemsTable tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--si-heading-color);
        min-width: 60px;
    }
    #itemsTable tbody td:last-child::before {
        display: none;
    }
    #itemsTable tbody td .form-control,
    #itemsTable tbody td .form-select {
        width: 100% !important;
        max-width: 60%;
    }
    #itemsTable tbody td:first-child {
        flex-direction: column;
        align-items: stretch;
    }
    #itemsTable tbody td:first-child .form-control,
    #itemsTable tbody td:first-child .form-select {
        max-width: 100%;
    }
}

/* ===== Responsive: Hide CGST/SGST/IGST on very small phones ===== */
@media (max-width: 575.98px) {
    #itemsTable tbody td[data-label="CGST"],
    #itemsTable tbody td[data-label="SGST"],
    #itemsTable tbody td[data-label="IGST"] {
        display: none;
    }
}

/* ===== Responsive: Tablet + Desktop (>=768px) — hide mobile UI ===== */
@media (min-width: 768px) {
    .si-bottom-nav,
    .si-mobile-header,
    .si-mobile-menu,
    .si-mobile-backdrop {
        display: none !important;
    }
}

/* ===== Print ===== */
@media print {
    .layout-navbar, .si-mobile-header, .si-bottom-nav, .si-mobile-menu,
    .si-mobile-backdrop, .layout-menu-horizontal, .page-header .btn,
    .delete-form, .pagination, .alert, .layout-overlay {
        display: none !important;
    }
    .container-xxl.flex-grow-1 {
        margin: 0 !important;
        padding: 0 !important;
    }
    .card {
        border: none !important;
        box-shadow: none !important;
    }
}

/* ===== PWA Install Banner ===== */
.si-install-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    left: auto;
    width: 380px;
    z-index: 1060;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    animation: si-slide-up .35s ease-out;
}
@media (max-width: 767.98px) {
    .si-install-banner {
        bottom: 70px; /* above bottom nav */
        left: 12px;
        right: 12px;
        width: auto;
    }
}
.si-install-banner-icon {
    flex-shrink: 0;
}
.si-install-banner-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}
.si-install-banner-text strong {
    font-size: .95rem;
}
.si-install-banner-text small {
    font-size: .78rem;
    color: #808390;
}
.si-install-banner-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
@keyframes si-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
