/* App styles on top of Tabler (wwwroot/lib/tabler). Tabler provides the page
   shell, sidebar, cards, tables, forms and dark mode; this file only holds the
   app's brand colours and the few custom pieces Tabler doesn't have. */

:root {
    --app-brand: #16324c;
    --app-brand-soft: #1f476b;
    --app-surface: #f6f8fb;
}

/* ---------- Sidebar ---------- */

.app-sidebar {
    background: var(--app-brand) !important;
}

.app-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #fff;
}

.app-menu .nav-link {
    border-radius: 0.375rem;
    margin: 0 0.5rem;
    padding-left: 0.75rem;
}

.app-menu .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

.app-menu .nav-link.active {
    background: var(--app-brand-soft);
    color: #fff;
    font-weight: 600;
}

.app-menu-caret {
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.app-menu-toggle:not(.collapsed) .app-menu-caret {
    transform: rotate(180deg);
}

.app-menu-children {
    margin-left: 1.25rem;
    padding-left: 0.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.app-menu-children .nav-link {
    font-size: 0.875rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

/* Sidebar layout: tools on top, scrolling menu in the middle, theme /
   account / user pinned at the bottom (desktop). */
.app-sidebar button.nav-link {
    background: none;
    border: 0;
    text-align: left;
}

.app-sidebar .app-user {
    cursor: default;
}

.app-sidebar .app-logout:hover {
    color: #ff8a8a;
}

.app-sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

@media (min-width: 992px) {
    .app-sidebar > .container-fluid,
    .app-sidebar .navbar-collapse {
        min-height: 0;
    }

    .app-sidebar .navbar-collapse {
        flex: 1 1 auto;
        display: flex !important;
        flex-direction: column;
    }

    .app-sidebar-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .app-sidebar-scroll .app-menu {
        padding-top: 0.25rem !important;
    }

    .app-sidebar-footer {
        margin-top: auto !important;
        padding-bottom: 0.75rem;
    }

    .app-sidebar,
    .navbar-vertical.navbar-expand-lg ~ .navbar,
    .navbar-vertical.navbar-expand-lg ~ .page-wrapper {
        transition: width 0.18s ease, margin-left 0.18s ease;
    }

    /* Collapsed = icon rail (like VS Code's activity bar). Hovering the rail
       slides the full menu out over the page; the page itself doesn't move. */
    html.sidebar-mini .navbar-vertical.navbar-expand-lg ~ .navbar,
    html.sidebar-mini .navbar-vertical.navbar-expand-lg ~ .page-wrapper {
        margin-left: 4.75rem;
    }

    html.sidebar-mini .app-sidebar:hover {
        box-shadow: 0.5rem 0 1.5rem rgba(0, 0, 0, 0.3);
    }

    html.sidebar-mini .app-sidebar:not(:hover) {
        width: 4.75rem;
    }

    html.sidebar-mini .app-sidebar:not(:hover) .nav-link-title,
    html.sidebar-mini .app-sidebar:not(:hover) .app-menu-caret,
    html.sidebar-mini .app-sidebar:not(:hover) .app-brand-text,
    html.sidebar-mini .app-sidebar:not(:hover) .app-menu .collapse,
    html.sidebar-mini .app-sidebar:not(:hover) .app-menu .nav-link.disabled {
        display: none !important;
    }

    html.sidebar-mini .app-sidebar:not(:hover) .nav-link,
    html.sidebar-mini .app-sidebar:not(:hover) .navbar-brand {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    html.sidebar-mini .app-sidebar:not(:hover) .nav-link-icon {
        margin: 0;
    }
}

/* Mobile: the opened menu overlays the page instead of pushing it down. */
@media (max-width: 991.98px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        z-index: 1030;
    }

    .app-sidebar #sidebar-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        background: var(--app-brand);
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.25);
        padding-bottom: 0.75rem;
    }
}

/* ---------- Content ---------- */

.app-content {
    padding-top: 1.25rem;
}

/* Plain <h1> page headings (most views) get Tabler's page-title look. */
.app-content h1 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.75rem;
    margin-bottom: 1rem;
}

.app-content h1.mb-0 {
    margin-bottom: 0;
}

/* Section headings inside tabbed forms (e.g. the Quotation form). */
.app-content .tab-content h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tblr-secondary);
    margin-bottom: 0.75rem;
}

.app-content .tab-content hr {
    margin: 1.5rem 0;
    opacity: 0.1;
}

.app-content .card + .card,
.app-content .card + form,
.app-content form + .card {
    margin-top: 1rem;
}

.app-page-subtitle-inline {
    margin-top: 0.15rem;
    color: var(--tblr-secondary);
    font-size: 0.95rem;
    line-height: 1.25;
}

.form-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--tblr-bg-surface);
    border-radius: var(--tblr-border-radius-lg);
    border: 1px solid var(--tblr-border-color);
    box-shadow: var(--tblr-box-shadow-card);
    margin-bottom: 1rem;
}

.form-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.page-shell .page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin: 0 0 1rem;
}

.page-title {
    margin-bottom: 0.25rem;
}

.page-subtitle {
    margin: 0;
    color: var(--tblr-secondary);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Right-align numeric values project-wide: every numeric input, and any
   computed/readonly numeric text field marked with .numeric-value. Table
   cells holding money/qty/percent values still need class="text-end"
   individually (Bootstrap convention), but this covers every form field. */
input[type="number"],
input.numeric-value {
    text-align: right;
}

/* Validation summary styled as an alert only shows once it has errors. */
.validation-summary-valid.alert {
    display: none;
}

/* ---------- DataTables (wwwroot/js/app-ui.js) ---------- */

div.dt-container .dt-search input {
    min-width: 300px;
}

div.dt-container .dt-buttons {
    margin-left: 0.5rem;
}

div.dt-container .dt-layout-row:first-child,
div.dt-container .dt-layout-row:last-child {
    margin: 0.25rem 0 0.75rem;
}

/* ---------- Login ---------- */

body.login-shell {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(22, 50, 76, 0.18), transparent 30%), radial-gradient(circle at bottom right, rgba(201, 16, 16, 0.16), transparent 28%), var(--app-surface);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    width: min(100%, 460px);
    background: var(--tblr-bg-surface, #fff);
    border-radius: 1rem;
    overflow: hidden;
}

.login-card-header {
    padding: 1.35rem 1.5rem;
    background: linear-gradient(135deg, var(--app-brand), var(--app-brand-soft));
    color: #fff;
}

.login-brand {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.login-subtitle {
    opacity: 0.9;
    margin-top: 0.35rem;
}

.login-form {
    padding: 1.5rem;
}

/* ---------- Dark theme ---------- */

html[data-bs-theme="dark"] {
    --app-surface: #14181a;
    --app-brand: #0f2438;
    --app-brand-soft: #16324c;
}

html[data-bs-theme="dark"] body.login-shell {
    background: radial-gradient(circle at top left, rgba(22, 50, 76, 0.35), transparent 30%), radial-gradient(circle at bottom right, rgba(201, 16, 16, 0.22), transparent 28%), var(--app-surface);
}

/* ---------- Sidebar sizing & bottom alignment ---------- */

.app-sidebar .nav-link-icon,
.app-sidebar .nav-link-icon .ti {
    font-size: 1.35rem;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-sidebar .nav-link-icon {
    margin-right: 0.6rem;
}

.app-sidebar .navbar-brand .ti {
    font-size: 1.6rem;
}

.app-sidebar .app-menu > .nav-item > .nav-link {
    min-height: 2.6rem;
}

@media (min-width: 992px) {
    /* Full-height column so theme / password / logout / user sit at the bottom. */
    .app-sidebar {
        display: flex;
        flex-direction: column;
    }

    .app-sidebar > .container-fluid {
        flex: 1 1 auto;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
    }

}

/* ---------- Top bar ---------- */

.app-topbar {
    min-height: 3.5rem;
    border-bottom: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

.app-topbar-org {
    min-width: 0;
}

.app-topbar-btn {
    position: relative;
    font-size: 1.35rem;
    padding: 0.4rem 0.6rem !important;
    border-radius: var(--tblr-border-radius);
    color: var(--tblr-secondary) !important;
}

.app-topbar-btn:hover {
    background: var(--tblr-bg-surface-secondary);
    color: var(--tblr-body-color) !important;
}

.app-topbar-btn .badge {
    position: absolute;
    top: 0.35rem;
    right: 0.4rem;
    width: 0.5rem;
    height: 0.5rem;
    padding: 0;
    border-radius: 50%;
}

.app-notifications {
    width: 20rem;
    max-width: calc(100vw - 2rem);
}

/* Tabler gives every sidebar .navbar-nav flex-grow:1, which split the free
   space between the tools list and the bottom list. Only the scrolling menu
   area may grow, so theme / password / logout / user sit at the very bottom. */
@media (min-width: 992px) {
    .app-sidebar {
        overflow: hidden !important;
    }

    .app-sidebar .app-sidebar-tools,
    .app-sidebar .app-sidebar-footer {
        flex-grow: 0 !important;
        flex-shrink: 0;
    }

    .app-sidebar .app-sidebar-scroll {
        display: flex;
        flex-direction: column;
    }
}

/* Sub-menu items: brighter and heavier so they read clearly on the navy. */
.app-sidebar .app-menu-children .nav-link {
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
    font-size: 0.9rem;
}

.app-sidebar .app-menu-children .nav-link:hover,
.app-sidebar .app-menu-children .nav-link.active {
    color: #fff;
}

.app-sidebar .app-menu > .nav-item > .nav-link {
    font-weight: 600;
}

/* Dark mode: top bar text in white. */
html[data-bs-theme="dark"] .app-topbar,
html[data-bs-theme="dark"] .app-topbar .fw-semibold {
    color: #fff;
}

html[data-bs-theme="dark"] .app-topbar .app-topbar-btn {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Grid search boxes: a little larger everywhere. */
div.dt-container .dt-search input {
    height: 2.25rem;
    font-size: 0.95rem;
    padding-left: 2rem;
    background: var(--tblr-bg-forms) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23868e96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='M21 21l-6-6'/%3E%3C/svg%3E") no-repeat 0.6rem center;
}

/* Grid search box: darker border so it stands out from the card. */
div.dt-container .dt-search input {
    border: 1px solid #8a94a6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

div.dt-container .dt-search input:focus {
    border-color: var(--tblr-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--tblr-primary-rgb), 0.2);
}

html[data-bs-theme="dark"] div.dt-container .dt-search input {
    border-color: #5c6778;
}

/* Menu weights: entries that only open a sub-menu are regular; entries that
   open a page (the actual options) are bold — at every level. */
.app-sidebar .app-menu .nav-link.app-menu-toggle {
    font-weight: 400 !important;
}

.app-sidebar .app-menu .nav-link.app-menu-link {
    font-weight: 600 !important;
}

/* Listing pages: alternate white / light-grey rows so long lists are easy to follow
   across a line. Applies to every list table (<table data-datatable>); hover still wins. */
table[data-datatable] > tbody > tr:nth-of-type(even) > * {
    background-color: #f1f3f5;
}
table[data-datatable].table-hover > tbody > tr:hover > * {
    background-color: #e3ebf6;
}
/* Dark theme: a slightly lighter band on the dark card, and a blue-tinted hover. */
[data-bs-theme="dark"] table[data-datatable] > tbody > tr:nth-of-type(even) > * {
    background-color: rgba(255, 255, 255, 0.05);
}
[data-bs-theme="dark"] table[data-datatable].table-hover > tbody > tr:hover > * {
    background-color: rgba(66, 153, 225, 0.18);
}

/* ---- Buttons inside list tables (both themes) ---------------------------------
   1 clear hover colour, 2 slight lift, 3 keyboard focus ring. */
table[data-datatable] .btn {
    transition: background-color .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .15s ease;
}
table[data-datatable] .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
table[data-datatable] .btn:active { transform: none; box-shadow: none; }
table[data-datatable] .btn:focus-visible {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}
table[data-datatable] .btn-outline-primary:hover   { background-color: #206bc4; border-color: #206bc4; color: #fff; }
table[data-datatable] .btn-outline-danger:hover    { background-color: #d63939; border-color: #d63939; color: #fff; }
table[data-datatable] .btn-outline-secondary:hover { background-color: #616876; border-color: #616876; color: #fff; }
table[data-datatable] .btn-primary:hover { background-color: #1a569d; border-color: #1a569d; }
table[data-datatable] .btn-success:hover { background-color: #257a3e; border-color: #257a3e; }
table[data-datatable] .btn-warning:hover { background-color: #c75e0a; border-color: #c75e0a; color: #fff; }
table[data-datatable] .btn-danger:hover  { background-color: #ab2e2e; border-color: #ab2e2e; }

/* Dark theme: 4 brighter outline border/text, 5 faint tint at rest,
   6 hover fills with the light colour and dark text. */
[data-bs-theme="dark"] table[data-datatable] .btn-outline-primary {
    color: #6ea8fe; border-color: #6ea8fe; background-color: rgba(110, 168, 254, .10);
}
[data-bs-theme="dark"] table[data-datatable] .btn-outline-danger {
    color: #f1828d; border-color: #f1828d; background-color: rgba(241, 130, 141, .10);
}
[data-bs-theme="dark"] table[data-datatable] .btn-outline-secondary {
    color: #c3c9d2; border-color: #8a93a2; background-color: rgba(195, 201, 210, .08);
}
[data-bs-theme="dark"] table[data-datatable] .btn-outline-primary:hover   { background-color: #6ea8fe; border-color: #6ea8fe; color: #10233d; }
[data-bs-theme="dark"] table[data-datatable] .btn-outline-danger:hover    { background-color: #f1828d; border-color: #f1828d; color: #3d1015; }
[data-bs-theme="dark"] table[data-datatable] .btn-outline-secondary:hover { background-color: #c3c9d2; border-color: #c3c9d2; color: #1d222b; }
[data-bs-theme="dark"] table[data-datatable] .btn:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
[data-bs-theme="dark"] table[data-datatable] .btn:focus-visible { outline-color: #6ea8fe; }

/* Plain "View" buttons in lists (class="btn btn-sm", no colour variant): light grey. */
html:not([data-bs-theme="dark"]) table[data-datatable] .btn[class="btn btn-sm"] {
    background-color: #f1f3f5; border-color: #dce1e7; color: #495057;
}
html:not([data-bs-theme="dark"]) table[data-datatable] .btn[class="btn btn-sm"]:hover {
    background-color: #e2e6ea; border-color: #c8ced6; color: #1d273b;
}
/* Dark theme: the same button as a subtle grey chip; hover lightens it a little (no white flash). */
[data-bs-theme="dark"] table[data-datatable] .btn[class="btn btn-sm"] {
    background-color: rgba(255, 255, 255, .06); border-color: #4a5260; color: #c3c9d2;
}
[data-bs-theme="dark"] table[data-datatable] .btn[class="btn btn-sm"]:hover {
    background-color: rgba(255, 255, 255, .14); border-color: #6b7483; color: #fff;
}

/* ---- Excel / PDF export buttons above list tables ------------------------------
   Excel green, PDF red: tinted outline at rest, solid fill on hover. */
.dt-buttons .btn.btn-export-excel,
.dt-buttons .btn.btn-export-pdf {
    border: 1px solid; transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.dt-buttons .btn.btn-export-excel { color: #1e7b3c; border-color: #2fb344; background-color: rgba(47, 179, 68, .08); }
.dt-buttons .btn.btn-export-pdf   { color: #b42323; border-color: #d63939; background-color: rgba(214, 57, 57, .08); }
.dt-buttons .btn.btn-export-excel:hover { color: #fff; border-color: #2fb344; background-color: #2fb344; }
.dt-buttons .btn.btn-export-pdf:hover   { color: #fff; border-color: #d63939; background-color: #d63939; }
.dt-buttons .btn.btn-export-excel:hover,
.dt-buttons .btn.btn-export-pdf:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.dt-buttons .btn.btn-export-excel:focus-visible,
.dt-buttons .btn.btn-export-pdf:focus-visible { outline: 2px solid #4299e1; outline-offset: 2px; }

[data-bs-theme="dark"] .dt-buttons .btn.btn-export-excel { color: #75d68a; border-color: #75d68a; background-color: rgba(117, 214, 138, .10); }
[data-bs-theme="dark"] .dt-buttons .btn.btn-export-pdf   { color: #f1828d; border-color: #f1828d; background-color: rgba(241, 130, 141, .10); }
[data-bs-theme="dark"] .dt-buttons .btn.btn-export-excel:hover { color: #10301a; background-color: #75d68a; }
[data-bs-theme="dark"] .dt-buttons .btn.btn-export-pdf:hover   { color: #3d1015; background-color: #f1828d; }
[data-bs-theme="dark"] .dt-buttons .btn.btn-export-excel:hover,
[data-bs-theme="dark"] .dt-buttons .btn.btn-export-pdf:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
