/* ────────────────────────────────────────────────────────────
   SIMPKL custom layer — loaded ON TOP of InApp (public/inapp)
   Bootstrap + theme styles come from InApp main.css; this file
   only holds app-specific helpers, loading state, compat + landing.
   ──────────────────────────────────────────────────────────── */

/* ─── InApp content spacing ───
   #topbar is fixed-top (h60) → .content must start below it,
   then .container-fluid adds the visual gap under the header. */
.content {
    padding-top: 60px;
}
.content > .container-fluid {
    padding-top: 2rem;
    padding-bottom: 2rem;
}
@media (max-width: 575.98px) {
    .content > .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
.content {
    overflow-x: hidden;
}

/* ─── Sidebar thin scrollbar (menu is long) ─── */
.sidebar {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
    z-index: 1034;
}
.sidebar .logo-area {
    position: sticky;
    top: 0;
    z-index: 1;
}
#overlay {
    z-index: 1032;
}
.sidebar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.35);
}
.sidebar > .nav {
    padding-bottom: 1.5rem;
}
html[data-bs-theme="dark"] .sidebar {
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
html[data-bs-theme="dark"] .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
}

/* ─── Icon helpers (main.css defines only .icon-xxs…xl; bare .icon used by views) ─── */
.icon {
    font-size: 1.5rem;
    line-height: 1;
}
.icon-white {
    color: #fff;
}

/* ─── Page header (compat for remaining views using page-header) ─── */
.page-header {
    margin-bottom: 1.25rem;
}
.page-header h2 {
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 0.1rem;
    color: var(--bs-body-color);
}
.page-subtitle {
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
}

/* ─── Avatar helpers (header dropdown, about page) ─── */
.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E66239, #00B8DB);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E66239, #00B8DB);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ─── Brand accent buttons (compat for existing views) ─── */
.btn-gold {
    background: #d4a027;
    border-color: #d4a027;
    color: #fff;
}
.btn-gold:hover {
    background: #b98a1e;
    border-color: #b98a1e;
    color: #fff;
}
.btn-outline-gold {
    border-color: #d4a027;
    color: #b98a1e;
}
.btn-outline-gold:hover {
    background: #d4a027;
    border-color: #d4a027;
    color: #fff;
}

/* ─── Scroll to Top ─── */
#scrollTopBtn {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #E66239, #00B8DB);
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}
#scrollTopBtn.visible {
    opacity: 1;
    visibility: visible;
}
#scrollTopBtn:hover {
    transform: translateY(-3px);
}

/* ─── Loading overlay ─── */
.page-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
}
.page-loading-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.page-loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(230, 98, 57, 0.15);
    border-top-color: #E66239;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}
.btn-loading::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────
   LANDING PAGE (welcome.blade.php — InApp look)
   ───────────────────────────────────────────── */
body.landing-page {
    overflow-x: hidden;
}

/* ─── Dark theme overrides ─────────────
   InApp ships light-only; this minimal flip keeps the dark
   toggle usable (admin shell, landing, auth) via Bootstrap's
   native html[data-bs-theme] marker.
   ────────────────────────────────────── */
html[data-bs-theme="dark"] body,
html[data-bs-theme="dark"] .bg-light,
html[data-bs-theme="dark"] .table-light {
    background: #14181f !important;
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .navbar,
html[data-bs-theme="dark"] #topbar.navbar,
html[data-bs-theme="dark"] .sidebar,
html[data-bs-theme="dark"] .card {
    background: #1d232d !important;
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .card-footer {
    background: #232b37 !important;
    border-color: rgba(255, 255, 255, 0.07) !important;
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-bottom {
    border-color: rgba(255, 255, 255, 0.08) !important;
}
html[data-bs-theme="dark"] .sidebar .logo-area {
    background: #1d232d;
    border-bottom-color: rgba(255, 255, 255, 0.08);
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .sidebar .logo-text,
html[data-bs-theme="dark"] .navbar-brand {
    color: #e4e6ec !important;
}
html[data-bs-theme="dark"] .sidebar .nav-link {
    color: #aeb6c4;
}
html[data-bs-theme="dark"] .sidebar .nav-link:hover,
html[data-bs-theme="dark"] .sidebar .nav-link.active {
    color: #E66239;
}
html[data-bs-theme="dark"] .text-secondary,
html[data-bs-theme="dark"] .text-muted {
    color: #98a2b3 !important;
}
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text {
    background: #14181f;
    border-color: #303a49;
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .form-control::placeholder {
    color: #6b7689;
}
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
    background: #14181f;
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .table {
    --bs-table-color: #e4e6ec;
    --bs-table-bg: transparent;
    --bs-table-border-color: rgba(255, 255, 255, 0.08);
}
html[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) {
    --bs-table-striped-bg: rgba(255, 255, 255, 0.035);
}
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .dropdown-menu {
    background: #1d232d;
    color: #e4e6ec;
    border-color: #303a49;
}
html[data-bs-theme="dark"] .page-loading-overlay {
    background: rgba(13, 16, 22, 0.78);
}
html[data-bs-theme="dark"] .page-loading-overlay .spinner {
    border-color: rgba(255, 255, 255, 0.15);
    border-top-color: #E66239;
}
html[data-bs-theme="dark"] .landing-hero {
    background:
        radial-gradient(600px 400px at 10% 15%, rgba(230, 98, 57, 0.14), transparent 60%),
        radial-gradient(700px 460px at 90% 10%, rgba(0, 184, 219, 0.16), transparent 62%),
        linear-gradient(180deg, #14181f 0%, #1d232d 100%);
}
html[data-bs-theme="dark"] .landing-hero h1,
html[data-bs-theme="dark"] .landing-page .card h6,
html[data-bs-theme="dark"] .landing-page .card .fw-semibold,
html[data-bs-theme="dark"] .landing-page h2 {
    color: #e4e6ec;
}
html[data-bs-theme="dark"] .landing-hero.hero-has-bg .bg-white {
    background: #1d232d !important;
}

/* ─── Responsive ─── */
@media (max-width: 575.98px) {
    #scrollTopBtn {
        right: 16px;
        bottom: 16px;
    }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
    .landing-reveal {
        transition: none !important;
        animation: none !important;
        opacity: 1;
        transform: none;
    }
}

/* ─── Mobile / tablet (≤992px) ───
   Shell behaviour (sidebar off-canvas, topbar fixed, content margin)
   comes from InApp's main.css — DO NOT override #sidebar / #topbar /
   #content position or overflow here: doing so pulls the sidebar into
   normal flow and pushes the page content below it. */
@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
    }
    .table-responsive::-webkit-scrollbar {
        height: 5px;
    }
    .table-responsive::-webkit-scrollbar-track {
        background: transparent;
    }
    .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 4px;
    }
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.45);
    }
    html[data-bs-theme="dark"] .table-responsive {
        scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    }
    html[data-bs-theme="dark"] .table-responsive::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
    }

    /* Aksi column stays on one line so buttons never stack mid-row */
    .table > tbody > tr > td:last-child,
    .table > thead > tr > th:last-child {
        white-space: nowrap;
    }
}

/* ─── Page header on phones: title own row, buttons share the next row ─── */
@media (max-width: 575.98px) {
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: stretch !important; /* beats Bootstrap's .align-items-center !important */
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > h2 {
        flex: 0 0 100%;
        font-size: 1.25rem;
        margin-bottom: 0;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > div {
        flex: 0 0 100%;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > .btn {
        display: flex;
        justify-content: center;
        white-space: normal;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > div > .btn {
        width: 100%;
        display: flex;
        justify-content: center;
        white-space: normal;
    }
    .d-flex.justify-content-between.align-items-center.mb-4 > .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 > div > .btn {
        font-size: 0.9rem;
        padding: 0.55rem 0.75rem;
    }

    .table {
        font-size: 0.875rem;
    }
    .table > :not(caption) > * > * {
        padding: 0.5rem 0.5rem;
    }
}

/* ─── Phone (≤576px): opted-in tables become stacked cards ───
   Add `table-mobile-cards` to the .table-responsive wrapper and a
   `data-label` on every <td> to render one card per row instead of a
   horizontally scrolling table. */
@media (max-width: 575.98px) {
    .table-mobile-cards {
        overflow-x: visible;
    }
    .table-mobile-cards > .table {
        display: block;
        width: 100%;
        min-width: 0;
        margin-bottom: 0;
        font-size: 0.875rem;
    }
    .table-mobile-cards > .table > thead {
        display: none;
    }
    .table-mobile-cards > .table > tbody {
        display: block;
        width: 100%;
    }
    .table-mobile-cards > .table > tbody > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 0.85rem;
        row-gap: 0.1rem;
        width: 100%;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.85rem 0.4rem;
        border: 1px solid var(--bs-border-color);
        border-radius: 0.5rem;
        background: var(--bs-body-bg);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
        overflow: hidden;
    }
    .table-mobile-cards > .table > tbody > tr:last-child {
        margin-bottom: 0;
    }
    .table-mobile-cards > .table > tbody > tr > td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0 0.5rem;
        min-width: 0;
        padding: 0.3rem 0;
        border: 0 !important;
        background: transparent !important;
        text-align: left !important;
        white-space: normal !important;
        vertical-align: baseline;
    }
    /* long fields take the full card width */
    .table-mobile-cards > .table > tbody > tr > td:nth-child(4),
    .table-mobile-cards > .table > tbody > tr > td:nth-child(9),
    .table-mobile-cards > .table > tbody > tr > td:last-child {
        grid-column: 1 / -1;
    }
    .table-mobile-cards > .table > tbody > tr > td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--bs-secondary-color);
    }
    .table-mobile-cards > .table > tbody > tr > td:nth-child(2) {
        font-weight: 600;
    }
    .table-mobile-cards > .table > tbody > tr > td:last-child {
        justify-content: flex-end;
        gap: 0.5rem;
        flex-wrap: wrap;
        padding-top: 0.5rem;
        margin-top: 0.2rem;
        border-top: 1px solid var(--bs-border-color) !important;
    }
    .table-mobile-cards > .table > tbody > tr > td:last-child::before {
        margin-right: auto;
        align-self: center;
    }
    .table-mobile-cards > .table > tbody > tr > td[colspan] {
        display: block;
        padding: 1.25rem 0.5rem;
        text-align: center !important;
    }
    .table-mobile-cards > .table > tbody > tr > td[colspan]::before {
        content: none !important;
    }
    .table-mobile-cards > .table tbody .badge,
    .table-mobile-cards > .table tbody .btn {
        flex-shrink: 0;
    }
    /* comfortable tap targets for row actions */
    .table-mobile-cards > .table > tbody > tr > td:last-child .btn-sm {
        min-height: 36px;
        padding: 0.45rem 0.9rem;
        font-size: 0.85rem;
    }
}

html[data-bs-theme="dark"] .table-mobile-cards > .table > tbody > tr {
    background: #1d232d;
    border-color: #303a49;
    box-shadow: none;
}
html[data-bs-theme="dark"] .table-mobile-cards > .table > tbody > tr > td {
    border-color: #303a49 !important;
}

