/* ==========================================================================
   1. CORE & BRAND IDENTITIES (Single Source of Truth)
   ========================================================================== */
:root {
    --brand-color: #ee4d2d;
    --brand-hover: #fb5533;
    --brand-text: #ffffff;
    /* Tambahkan variabel teks khusus brand */
    --brand-light: rgba(238, 77, 45, 0.1);

    --error-color: #ef4444;
    --slate-100: #f1f5f9;
    --slate-400: #94a3b8;
    --slate-600: #475569;
    --slate-700: #334155;
}

/* MODIFIKASI: bg-brand sekarang mengatur warna background DAN teks */
.bg-brand {
    background-color: var(--brand-color) !important;
    color: var(--brand-text) !important;
}

.bg-brand-header {
    background-color: var(--brand-color) !important;
}

/* Menjamin icon (bi) dan span di dalam bg-brand juga mengikuti warna teks brand */
.bg-brand i,
.bg-brand span,
.bg-brand a {
    color: var(--brand-text) !important;
}

.btn.bg-brand:hover {
    background-color: var(--brand-hover) !important;
    color: var(--brand-text) !important;
    opacity: 0.9;
    border: none !important;
}

.text-brand {
    color: var(--brand-color) !important;
}

.border-top-brand {
    border-top: 4px solid var(--brand-color);
}

.hover-brand:hover {
    color: var(--brand-hover) !important;
}



/* ==========================================================================
   2. GLOBAL LAYOUT & FIXES
   ========================================================================== */
body {
    background-color: #f5f5f5 !important;
}

#main-content,
.content-wrapper {
    width: 100% !important;
    padding: 0 !important;
}

#tab-content-area {
    width: 100% !important;
    overflow-x: auto;
}

.swal2-container {
    z-index: 100000 !important;
}

/* ==========================================================================
   3. FORM VALIDATION (INLINE ERROR STYLE)
   ========================================================================== */
input.is-invalid,
textarea.is-invalid,
select.is-invalid {
    border-color: var(--error-color) !important;
    border-width: 1px !important;
    outline: none !important;
}

input.is-invalid:focus {
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* ==========================================================================
   4. GLOBAL TABLE TYPOGRAPHY
   ========================================================================== */
.t-title {
    font-weight: 500;
    color: var(--slate-700);
    font-size: 0.875rem;
    line-height: 1.25rem;
    display: block;
}

.t-sub {
    font-size: 0.75rem;
    color: var(--slate-400);
    margin-top: 0.125rem;
    display: block;
    font-family: ui-monospace, monospace;
}

.t-desc {
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.25;
}

.t-icon {
    margin-right: 0.25rem;
    color: #cbd5e1;
}

.t-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #353f4d;
    text-transform: uppercase;
    margin-bottom: 0.375rem;
    margin-left: 0.25rem;
}

.t-link {
    color: var(--slate-600);
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.t-link:hover {
    color: #059669;
}

/* ==========================================================================
   5. UI COMPONENTS (LINKED TO BRAND VARIABLE)
   ========================================================================== */

/* --- Table Flat --- */
.table-flat {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: white;
}

.table-flat thead {
    background-color: var(--slate-100);
    color: var(--slate-600);
    white-space: nowrap;
    font-size: 0.875rem;
}

.table-flat th {
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

.table-flat td {
    color: var(--slate-700);
    border-bottom: 1px solid var(--slate-100);
    vertical-align: middle;
}

.table-flat tbody tr:hover {
    background-color: #f8fafc !important;
}

/* --- Tab Underline --- */
.tab-nav {
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    background: white;
    margin-bottom: 20px;
    gap: 8px;
}

.tab-underline {
    position: relative;
    padding: 12px 20px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0.95rem;
}

.tab-underline:hover {
    color: var(--brand-color);
    background-color: #f8fafc;
}

.tab-underline.active {
    color: var(--brand-color);
    font-weight: 600;
}

.tab-underline.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--brand-color);
    border-radius: 2px;
}

/* --- Alpine Modal --- */
.alpine-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.modal-anim-active {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Floating Dropdown --- */
.floating-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: white;
    border: 1px solid #f1f5f9;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 6px;
    z-index: 9999 !important;
    min-width: 160px;
}

.floating-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: #475569;
    border-radius: 6px;
    transition: all 0.2s;
}

.floating-item:hover {
    background-color: #f8fafc;
    color: var(--brand-color);
    transform: translateX(2px);
}

.floating-item.active {
    background-color: var(--brand-light);
    color: var(--brand-color);
    font-weight: 600;
}

/* ==========================================================================
   6. SPA ESSENTIALS (HTMX LOADING)
   ========================================================================== */
#global-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--brand-color);
    box-shadow: 0 0 10px var(--brand-light);
    z-index: 9999;
    opacity: 0;
    display: none;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#global-loading.htmx-request {
    display: block !important;
    opacity: 1 !important;
    animation: htmx-crawling 2s ease-out forwards !important;
}

@keyframes htmx-crawling {
    0% {
        width: 0%;
    }

    20% {
        width: 30%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 95%;
    }
}

/* ==========================================================================
   7. UI COMPONENTS TOMBOL
   ========================================================================== */

/* Standarisasi Tombol Baru Anda */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    gap: 0.5rem;
    border: 1px solid transparent;
}

/* Pengganti btn-primary: btn-brand */
.btn-brand {
    background-color: var(--brand-color) !important;
    color: var(--brand-text) !important;
}

.btn-brand:hover {
    background-color: var(--brand-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--brand-light);
    opacity: 0.95;
}

/* Menjamin icon di dalam btn-brand ikut putih */
.btn-brand i {
    color: var(--brand-text) !important;
}

/* Varian Ukuran (Wajib ada agar layout tidak pecah) */
.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

.btn-xs {
    padding: 0.125rem 0.5rem;
    font-size: 10px;
}

/* Modifier Tombol Laporan */
.btn-excel {
    background-color: #16a34a !important;
    color: #ffffff !important;
}

.btn-excel:hover {
    background-color: #15803d !important;
}

.btn-pdf {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

.btn-pdf:hover {
    background-color: #b91c1c !important;
}


/* ==========================================================================
   8. UI COMPONENTS INPUT
   ========================================================================== */

.input-brand {
    width: 100%;
    height: 40px;
    padding-left: 1rem;
    padding-right: 3rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background-color: white;
    font-size: 0.875rem;
    color: var(--slate-700);
    transition: all 0.2s;
}

.input-brand:focus {
    outline: none;
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.input-sm {
    height: 32px;
    font-size: 0.75rem;
    padding: 0 0.75rem;
}