/* =========================================
   TEMA GLASSMORPHISM SIPESAN V2
   ========================================= */

/* Root background fallback agar area overscroll tidak flash putih */
html {
    background-color: #d9f4ee;
}

html.dark-mode {
    background-color: #000000;
}

/* 1. Background Animasi Gradien */
body {
    background: linear-gradient(-45deg, #ecfdf5, #d1fae5, #bbf7d0, #a7f3d0);
    background-size: 400% 400%;
    animation: sipesanGradient 18s ease infinite;
    background-attachment: fixed;
}

@keyframes sipesanGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 2. Panel Kaca Utama (Sidebar, Navbar, Kotak Konten) */
.glass-panel {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

/* 3. Kaca Input (Search, Dropdown, Form) */
.glass-input {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}
.glass-input:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: #0ea5e9;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2);
    outline: none;
}

/* 3b. Input Dengan Icon (ikon selalu terlihat) */
.input-icon-wrap {
    position: relative;
}

.input-with-icon {
    position: relative;
    z-index: 1;
}

.input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    pointer-events: none;
    color: #9ca3af;
    opacity: 0.95;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.input-icon-offset-sm {
    left: 1rem;
}

.input-icon-wrap:focus-within .input-icon {
    color: #3b82f6;
    opacity: 1;
}

.input-with-icon:-webkit-autofill,
.input-with-icon:-webkit-autofill:hover,
.input-with-icon:-webkit-autofill:focus {
    -webkit-text-fill-color: #374151;
    transition: background-color 5000s ease-in-out 0s;
}

/* 4. Kaca Tabel (Header Tabel) */
.glass-table-head {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
}

/* 4b. Dropdown User Premium */
.user-dropdown-premium {
    background:
        linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(255, 255, 255, 0.56)),
        rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

/* 4c. Dark Mode */
body.dark-mode {
    background: #000000;
    animation: none;
    background-attachment: fixed;
    color: #f1f5f9;
    color-scheme: dark;
}

/* Perangkat sentuh: tetap animasi, dibuat sedikit lebih terasa */
@media (pointer: coarse) {
    body:not(.dark-mode) {
        background-attachment: fixed;
        background-size: 320% 320%;
        animation-duration: 14s;
    }

    body.dark-mode {
        background-attachment: fixed;
    }
}

body.dark-mode .glass-panel {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

body.dark-mode .glass-input {
    background: rgba(0, 0, 0, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f1f5f9;
}

body.dark-mode .glass-input:focus {
    background: rgba(0, 0, 0, 0.95);
    border-color: #34d399;
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2);
}

body.dark-mode .user-dropdown-premium {
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(52, 211, 153, 0.35);
}

body.dark-mode .text-gray-900 { color: #f8fafc !important; }
body.dark-mode .text-gray-800 { color: #f1f5f9 !important; }
body.dark-mode .text-gray-700 { color: #dbe4ee !important; }
body.dark-mode .text-gray-600 { color: #c3d0de !important; }
body.dark-mode .text-gray-500 { color: #9fb1c3 !important; }
body.dark-mode .text-gray-400 { color: #7f93a8 !important; }
body.dark-mode .placeholder-gray-400::placeholder { color: #7f93a8 !important; }

body.dark-mode [class*="bg-white/"] { background-color: rgba(0, 0, 0, 0.9) !important; }
body.dark-mode [class*="bg-gray-50"] { background-color: rgba(0, 0, 0, 0.92) !important; }
body.dark-mode [class*="bg-gray-100"] { background-color: rgba(0, 0, 0, 0.95) !important; }
body.dark-mode [class*="bg-gray-200"] { background-color: rgba(15, 15, 15, 0.96) !important; }

body.dark-mode .border-white\/50,
body.dark-mode .border-white\/60,
body.dark-mode .border-white\/70,
body.dark-mode .border-white\/80 { border-color: rgba(255, 255, 255, 0.16) !important; }
body.dark-mode .border-gray-100,
body.dark-mode .border-gray-200,
body.dark-mode .border-gray-300 { border-color: rgba(255, 255, 255, 0.16) !important; }

body.dark-mode table thead tr,
body.dark-mode .glass-table-head {
    background: rgba(0, 0, 0, 0.98) !important;
}

body.dark-mode table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}

body.dark-mode select option {
    background: #000000;
    color: #f1f5f9;
}

body.dark-mode #themeToggleButton,
body.dark-mode #userMenuButton {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

/* 4d. App Shell Fixed Sidebar + Topbar */
#app-content-shell {
    width: 100%;
    margin-left: 0;
    transition: margin-left 0.25s ease, width 0.25s ease;
}

#app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transition: left 0.25s ease;
}

#app-main {
    padding-top: calc(4rem + 1rem) !important;
}

@media (min-width: 1024px) {
    #app-content-shell {
        margin-left: 16rem;
        width: calc(100% - 16rem);
    }

    #app-topbar {
        left: 16rem;
    }

    #sidebar.w-20 ~ #app-content-shell {
        margin-left: 5rem;
        width: calc(100% - 5rem);
    }

    #sidebar.w-20 ~ #app-content-shell #app-topbar {
        left: 5rem;
    }
}

/* 5. Scrollbar Elegan */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(156, 163, 175, 0.5); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(107, 114, 128, 0.8); }

/* 6. SPA Main Transition */
main.spa-main-exit {
    opacity: 0.85;
}

main.spa-main-enter {
    opacity: 0;
    transform: translateY(6px);
}

main.spa-main-enter.spa-main-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

body.spa-loading {
    cursor: progress;
}

/* 6a. Shared Utility Animation */
.animate-fadeIn {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 1024px) {
    html.sidebar-init-collapsed #sidebar {
        width: 5rem !important;
    }

    html.sidebar-init-collapsed #logo-text,
    html.sidebar-init-collapsed .nav-label {
        display: none !important;
    }
}

/* Pagination info (light mode) harus jelas terbaca */
body:not(.dark-mode) nav[aria-label="Pagination Navigation"] p {
    color: #000000 !important;
}

/* 6c. Floating Table Navigator (Desktop) */
.table-nav-fab {
    position: fixed;
    right: 1rem;
    bottom: 4.1rem;
    z-index: 45;
    --dpad-arm-long: 2.35rem;
    --dpad-arm-short: 1.72rem;
    --dpad-gap: 0.38rem;
    --dpad-cut: 63.4%;
    --dpad-size: calc(var(--dpad-arm-long) * 2 + var(--dpad-gap));
    width: var(--dpad-size);
    height: var(--dpad-size);
}

.table-nav-placeholder {
    display: none;
}

.table-nav-btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.34);
    color: transparent;
    background: linear-gradient(
        162deg,
        rgba(100, 116, 139, 0.5) 0%,
        rgba(71, 85, 105, 0.44) 54%,
        rgba(51, 65, 85, 0.4) 100%
    );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        0 6px 0 rgba(15, 23, 42, 0.18),
        0 12px 20px rgba(15, 23, 42, 0.2),
        inset 0 1px 1px rgba(255, 255, 255, 0.24),
        inset 0 -8px 12px rgba(3, 7, 18, 0.16);
    font-size: 0;
    line-height: 1;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease, opacity 0.2s ease;
    will-change: transform;
    overflow: hidden;
}

.table-nav-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 52%);
    opacity: 0.72;
}

.table-nav-btn > i {
    display: none !important;
}

.table-nav-btn[data-nav-action="top"] {
    width: var(--dpad-arm-short);
    height: var(--dpad-arm-long);
    left: calc((var(--dpad-size) - var(--dpad-arm-short)) / 2);
    top: 0;
    border-radius: 0.24rem;
    clip-path: polygon(0 0, 100% 0, 100% var(--dpad-cut), 50% 100%, 0 var(--dpad-cut));
}

.table-nav-btn[data-nav-action="left"] {
    width: var(--dpad-arm-long);
    height: var(--dpad-arm-short);
    left: 0;
    top: calc((var(--dpad-size) - var(--dpad-arm-short)) / 2);
    border-radius: 0.24rem;
    clip-path: polygon(0 0, var(--dpad-cut) 0, 100% 50%, var(--dpad-cut) 100%, 0 100%);
}

.table-nav-btn[data-nav-action="right"] {
    width: var(--dpad-arm-long);
    height: var(--dpad-arm-short);
    right: 0;
    top: calc((var(--dpad-size) - var(--dpad-arm-short)) / 2);
    border-radius: 0.24rem;
    clip-path: polygon(calc(100% - var(--dpad-cut)) 0, 100% 0, 100% 100%, calc(100% - var(--dpad-cut)) 100%, 0 50%);
}

.table-nav-btn[data-nav-action="bottom"] {
    width: var(--dpad-arm-short);
    height: var(--dpad-arm-long);
    left: calc((var(--dpad-size) - var(--dpad-arm-short)) / 2);
    bottom: 0;
    border-radius: 0.24rem;
    clip-path: polygon(0 calc(100% - var(--dpad-cut)), 50% 0, 100% calc(100% - var(--dpad-cut)), 100% 100%, 0 100%);
}

.table-nav-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05) saturate(0.95);
    box-shadow:
        0 8px 0 rgba(15, 23, 42, 0.2),
        0 15px 24px rgba(15, 23, 42, 0.26),
        inset 0 1px 1px rgba(255, 255, 255, 0.3),
        inset 0 -8px 12px rgba(3, 7, 18, 0.2);
}

.table-nav-btn:active {
    transform: translateY(2px);
    box-shadow:
        0 3px 0 rgba(15, 23, 42, 0.16),
        0 8px 14px rgba(15, 23, 42, 0.18),
        inset 0 1px 1px rgba(255, 255, 255, 0.2),
        inset 0 -7px 10px rgba(3, 7, 18, 0.18);
}

.table-nav-btn.is-disabled {
    opacity: 0.28;
    pointer-events: none;
}

body.dark-mode .table-nav-btn {
    color: transparent;
    border-color: rgba(148, 163, 184, 0.2);
    background: linear-gradient(
        162deg,
        rgba(71, 85, 105, 0.48) 0%,
        rgba(51, 65, 85, 0.42) 54%,
        rgba(30, 41, 59, 0.38) 100%
    );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        0 6px 0 rgba(2, 6, 23, 0.28),
        0 13px 22px rgba(0, 0, 0, 0.42),
        inset 0 1px 1px rgba(203, 213, 225, 0.2),
        inset 0 -8px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .table-nav-btn:hover {
    color: transparent;
    filter: brightness(1.08);
}

@media (max-width: 1023px) {
    .table-nav-fab {
        display: none !important;
    }
}

/* 6c. Sidebar Mobile Overlay (tanpa icon tersisa) */
@media (max-width: 1023px) {
    #sidebar {
        transform: translateX(-100%) !important;
        width: 16rem !important;
    }

    #sidebar.sidebar-mobile-open {
        transform: translateX(0) !important;
    }
}

/* 6b. SweetAlert Toast Theme */
.swal2-popup.sipesan-toast.swal2-toast {
    width: min(19.5rem, calc(100vw - 1rem)) !important;
    padding: 0.6rem 0.75rem !important;
    border-radius: 0.82rem !important;
    border: 1px solid rgba(52, 211, 153, 0.42) !important;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.72), rgba(220, 252, 231, 0.68)) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 10px 22px rgba(16, 185, 129, 0.16) !important;
}

.sipesan-toast-title {
    margin: 0 !important;
    font-size: 0.86rem !important;
    font-weight: 700 !important;
    color: #065f46 !important;
}

.sipesan-toast-text {
    margin-top: 0.18rem !important;
    font-size: 0.75rem !important;
    line-height: 1.35 !important;
    color: #0f766e !important;
}

.sipesan-toast .swal2-timer-progress-bar {
    background: linear-gradient(90deg, #10b981, #22c55e) !important;
    opacity: 0.95 !important;
}

body.dark-mode .swal2-popup.sipesan-toast.swal2-toast {
    border-color: rgba(52, 211, 153, 0.32) !important;
    background: linear-gradient(140deg, rgba(3, 26, 18, 0.72), rgba(15, 23, 42, 0.75)) !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45) !important;
}

body.dark-mode .sipesan-toast-title {
    color: #bbf7d0 !important;
}

body.dark-mode .sipesan-toast-text {
    color: #99f6e4 !important;
}

body.dark-mode .sipesan-toast .swal2-timer-progress-bar {
    background: linear-gradient(90deg, #34d399, #22d3ee) !important;
}

/* 6d. SweetAlert Confirm Theme */
.swal2-popup.sipesan-confirm {
    border-radius: 1rem !important;
    border: 1px solid rgba(52, 211, 153, 0.38) !important;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(236, 253, 245, 0.86)) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    box-shadow: 0 14px 32px rgba(16, 185, 129, 0.15) !important;
}

.sipesan-confirm-title {
    color: #064e3b !important;
    font-weight: 800 !important;
}

.sipesan-confirm-text {
    color: #115e59 !important;
}

.swal2-popup.sipesan-confirm .swal2-actions {
    gap: 0.7rem !important;
    margin-top: 1rem !important;
}

.swal2-actions .sipesan-confirm-btn,
.swal2-actions .sipesan-cancel-btn {
    height: 40px !important;
    min-width: 126px !important;
    border-radius: 0.72rem !important;
    border: 0 !important;
    padding: 0 1rem !important;
    font-size: 0.84rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
}

.swal2-actions .sipesan-confirm-btn {
    color: #ffffff !important;
    background: linear-gradient(90deg, #10b981, #059669) !important;
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.26) !important;
}

.swal2-actions .sipesan-cancel-btn {
    color: #374151 !important;
    background: rgba(255, 255, 255, 0.84) !important;
    border: 1px solid rgba(209, 213, 219, 0.95) !important;
}

body.dark-mode .swal2-popup.sipesan-confirm {
    border-color: rgba(52, 211, 153, 0.28) !important;
    background: linear-gradient(145deg, rgba(2, 22, 16, 0.9), rgba(15, 23, 42, 0.88)) !important;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .sipesan-confirm-title {
    color: #d1fae5 !important;
}

body.dark-mode .sipesan-confirm-text {
    color: #99f6e4 !important;
}

body.dark-mode .swal2-actions .sipesan-cancel-btn {
    color: #e2e8f0 !important;
    background: rgba(30, 41, 59, 0.82) !important;
    border-color: rgba(100, 116, 139, 0.62) !important;
}

/* 7. Mobile Fit: Halaman, Modal, Swal */
@media (max-width: 768px) {
    .app-shell {
        height: auto !important;
        min-height: 100dvh !important;
    }

    main {
        padding: 1rem !important;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
    }

    div[id^="modal"].fixed.inset-0 {
        padding: 0 !important;
    }

    div[id^="modal"].fixed.inset-0 > div {
        align-items: center !important;
        justify-content: center !important;
        min-height: 100dvh !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 0.75rem !important;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    }

    div[id^="modal"].fixed.inset-0 > div > .glass-panel {
        width: calc(100vw - 1.5rem) !important;
        max-width: calc(100vw - 1.5rem) !important;
        max-height: 92dvh !important;
        overflow-y: auto !important;
        border-radius: 1rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .swal2-container.swal2-top-end {
        inset: 0.5rem !important;
        align-items: flex-start !important;
    }

    .swal2-container.swal2-top-end > .swal2-popup.swal2-toast {
        width: min(92vw, 18.5rem) !important;
        max-width: min(92vw, 18.5rem) !important;
        margin: 0 0 0 auto !important;
    }

    .swal2-popup {
        width: min(92vw, 420px) !important;
        padding: 1rem !important;
        border-radius: 1rem !important;
    }

    .swal2-title {
        font-size: 1.05rem !important;
    }

    .swal2-html-container {
        font-size: 0.9rem !important;
        margin-top: 0.5rem !important;
    }

    .swal2-actions {
        width: 100% !important;
        gap: 0.5rem !important;
        margin-top: 0.9rem !important;
    }

    .swal2-styled {
        flex: 1 1 0 !important;
        margin: 0 !important;
        height: 42px !important;
        border-radius: 0.75rem !important;
        font-weight: 700 !important;
    }
}

/* 8. Tablet Landscape Fit (pakai layout desktop, hindari konten bawah terpotong) */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) and (pointer: coarse) {
    .app-shell {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
    }

    .app-shell > .flex-1 {
        min-height: 100dvh !important;
    }

    .app-shell main {
        overflow-y: auto !important;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    }
}

/* 9. Tab Strip Horizontal (Input Usulan & Super Area) */
#inputTabs,
#superTabs {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.25rem;
}

#inputTabs::-webkit-scrollbar,
#superTabs::-webkit-scrollbar {
    display: none;
}

#inputTabs > li,
#superTabs > li {
    flex: 0 0 auto;
    margin-right: 0 !important;
}

#inputTabs button,
#superTabs button {
    white-space: nowrap;
    flex-shrink: 0;
}
