/**
 * Perkebunan-app: Modern Government Data Platform Design System
 * Theme overrides for Hope UI Bootstrap 5
 * Color Theme: Emerald Green, Forest Green, Slate Neutral, White
 */

:root {
    --bs-primary: #059669;
    --bs-primary-rgb: 5, 150, 105;
    --bs-primary-hover: #047857;
    --bs-primary-active: #065f46;
    --bs-primary-shade-20: #047857;
    --bs-primary-tint-20: #10b981;
    --bs-primary-tint-40: #34d399;
    --bs-primary-tint-60: #6ee7b7;
    --bs-primary-tint-80: #a7f3d0;
    --bs-primary-tint-90: #d1fae5;
    --bs-primary-bg-subtle: #ecfdf5;
    --bs-primary-border-subtle: #a7f3d0;

    --bs-success: #10b981;
    --bs-success-rgb: 16, 185, 129;
    --bs-warning: #f59e0b;
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger: #ef4444;
    --bs-danger-rgb: 239, 68, 68;
    --bs-info: #0284c7;
    --bs-info-rgb: 2, 132, 199;

    --gov-forest-dark: #064e3b;
    --gov-emerald: #059669;
    --gov-emerald-light: #ecfdf5;
    --gov-slate-dark: #0f172a;
    --gov-slate-muted: #64748b;
    --gov-border: #e2e8f0;
    --gov-card-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

/* Global resets & typography */
body {
    background-color: #f8fafc !important;
    color: #1e293b;
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Navbar Brand & Header styling */
.navbar-brand .logo-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #064e3b !important;
}

.brand-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

/* ==========================================================================
   SIDEBAR & MAIN CONTENT LAYOUT SYSTEM
   Professional admin layout with synchronized width transition and independent scroll
   ========================================================================== */

/* 1. Sidebar Container */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: var(--sidebar-width, 19.2rem);
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* Ubah overflow agar tombol melayang di tepi tidak terpotong */
    overflow: visible !important;
    z-index: 1000;
    background-color: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
    transition:
        max-width 400ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.sidebar-mini {
    --sidebar-width: 4.8rem;
    max-width: 4.8rem;
}

/* 3. Sidebar Header - Fixed at Top */
.sidebar .sidebar-header {
    position: relative; /* Diperlukan agar absolute positioning tombol berpatokan ke header */
    flex-shrink: 0;
    height: 72px;
    min-height: 72px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    background-color: #ffffff;
    overflow: visible !important;
}

/* Styling untuk tombol toggle panah */
.sidebar .sidebar-toggle {
    position: absolute;
    right: -14px; /* Posisi kan tombol melayang pas di garis tepi kanan */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1050;
    cursor: pointer;
    /* Memastikan tombol tidak terpengaruh flexbox layout header */
    flex-shrink: 0;
}

.sidebar.sidebar-mini .sidebar-header {
    padding: 0 0.5rem;
    justify-content: center;
}

.sidebar.sidebar-mini .navbar-brand {
    display: none; /* Sembunyikan brand saat mini agar tidak berbenturan */
}

/* 4. Smooth Fade for Logo Text in Header */
.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    transition:
        opacity 250ms ease,
        max-width 350ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 350ms ease;
    white-space: nowrap;
    overflow: hidden;
    max-width: 150px;
}

.sidebar.sidebar-mini .sidebar-logo-text {
    opacity: 0;
    max-width: 0;
    transform: translateX(-15px);
    pointer-events: none;
}

/* 5. Sidebar Body - Independent Vertical Scroll */
.sidebar .sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: calc(100vh - 72px);
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0.5rem 0.5rem 1.5rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.sidebar .sidebar-body::-webkit-scrollbar {
    width: 4px;
}
.sidebar .sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar .sidebar-body::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 6px;
}
.sidebar .sidebar-body::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* 6. User Profile Card in Sidebar */
.sidebar-user-card {
    transition: padding 350ms cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid #f1f5f9;
}

.sidebar-user-info {
    transition:
        opacity 250ms ease,
        max-width 350ms cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: hidden;
    max-width: 180px;
}

.sidebar.sidebar-mini .sidebar-user-card {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
    justify-content: center !important;
}

.sidebar.sidebar-mini .sidebar-user-info {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

/* 7. Nav Links in Expanded Mode */
.sidebar .nav-item .nav-link {
    color: #475569;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    margin: 0.15rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        padding 350ms cubic-bezier(0.4, 0, 0.2, 1),
        margin 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .nav-item .nav-link:hover {
    color: #059669;
    background-color: #f0fdf4;
}

.sidebar .nav-item .nav-link.active {
    color: #ffffff !important;
    background-color: #059669 !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.sidebar .nav-item .nav-link.active .icon,
.sidebar .nav-item .nav-link.active svg {
    color: #ffffff !important;
    fill: currentColor;
}

.sidebar .nav-item .nav-link .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    flex-shrink: 0;
}

.sidebar .item-name {
    flex: 1 1 auto;
    transition:
        opacity 250ms ease,
        max-width 350ms cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    overflow: hidden;
    max-width: 200px;
}

.sidebar .right-icon {
    transition:
        opacity 250ms ease,
        max-width 350ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 150ms ease;
    white-space: nowrap;
    overflow: hidden;
    max-width: 20px;
    margin-left: auto;
}

/* 8. Nav Links in Mini Mode */
.sidebar.sidebar-mini .nav-item {
    width: 100%;
    text-align: center;
}

.sidebar.sidebar-mini .nav-item .nav-link {
    width: 44px;
    height: 44px;
    padding: 0 !important;
    margin: 0.25rem auto !important;
    justify-content: center !important;
    gap: 0;
}

.sidebar.sidebar-mini .item-name,
.sidebar.sidebar-mini .right-icon {
    opacity: 0;
    max-width: 0;
    margin: 0 !important;
    pointer-events: none;
}

/* 9. Static Items (Section Dividers) */
.sidebar .nav-item.static-item .nav-link.static-item {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    padding: 1rem 0.85rem 0.35rem;
    margin: 0;
    display: flex;
    align-items: center;
    transition: all 350ms ease;
}

.sidebar.sidebar-mini .nav-item.static-item {
    padding: 0.35rem 0;
    margin: 0;
}

.sidebar.sidebar-mini .nav-item.static-item .nav-link.static-item {
    height: 1px;
    width: 24px;
    background-color: #e2e8f0;
    margin: 0.35rem auto;
    padding: 0;
    display: block;
    border: none;
}

.sidebar.sidebar-mini .nav-item.static-item .default-icon,
.sidebar.sidebar-mini .nav-item.static-item .mini-icon {
    display: none;
}

/* 10. Sub-nav */
.sidebar .sub-nav {
    padding-left: 0;
    list-style: none;
}

.sidebar .sub-nav .nav-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem 0.5rem 2.25rem;
    margin: 0.1rem 0.5rem;
}

.sidebar.sidebar-mini .sub-nav {
    display: none;
}

/* 11. Responsive & Mobile Offcanvas Drawer (< 1200px) */
@media (max-width: 1199.98px) {
    .sidebar + .main-content,
    .sidebar ~ .main-content,
    .main-content {
        margin-left: 0 !important;
    }

    .sidebar {
        max-width: 19.2rem !important;
        transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .sidebar.sidebar-mini {
        transform: translateX(-100%) !important;
    }

    .sidebar:not(.sidebar-mini) {
        transform: translateX(0) !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    }
}

/* 12. Mobile Backdrop */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 300ms ease,
        visibility 300ms ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Top Navbar */
.iq-navbar {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

.iq-navbar .breadcrumb {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.iq-navbar .breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
}

.iq-navbar .breadcrumb-item.active {
    color: #0f172a;
    font-weight: 600;
}

/* User Profile Badge */
.user-profile-badge {
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 2rem;
    padding: 0.35rem 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Cards & Elevation */
.card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.75rem !important;
    box-shadow: var(--gov-card-shadow) !important;
    background-color: #ffffff;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-header.bg-emerald {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    color: #ffffff !important;
    border-bottom: none;
}

.card-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

/* KPI Summary Cards */
.kpi-card {
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 1.25rem;
    background: #ffffff;
    box-shadow: var(--gov-card-shadow);
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: #059669;
}

.kpi-card.kpi-amber::before {
    background-color: #f59e0b;
}
.kpi-card.kpi-blue::before {
    background-color: #0284c7;
}
.kpi-card.kpi-forest::before {
    background-color: #064e3b;
}

.kpi-card .kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.kpi-card .kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.kpi-icon-emerald {
    background-color: #ecfdf5;
    color: #059669;
}
.kpi-icon-amber {
    background-color: #fef3c7;
    color: #d97706;
}
.kpi-icon-blue {
    background-color: #e0f2fe;
    color: #0284c7;
}
.kpi-icon-forest {
    background-color: #d1fae5;
    color: #064e3b;
}

/* Government Header Banner */
.gov-banner {
    background: linear-gradient(135deg, #064e3b 0%, #059669 60%, #10b981 100%);
    color: #ffffff;
    border-radius: 0.75rem;
    padding: 1.75rem 2rem;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.3);
    margin-bottom: 1.5rem;
}

.gov-banner h2,
.gov-banner h3 {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.gov-banner p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0;
}

/* DataTables Styling */
.dataTables_wrapper {
    padding: 0.5rem 0;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
    margin-top: 0.75rem !important;
    margin-bottom: 0.75rem !important;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
}

table.dataTable thead th {
    background-color: #064e3b !important;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid #047857 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    vertical-align: middle;
}

table.dataTable thead tr:first-child th {
    border-top: none;
}

table.dataTable tbody td {
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f8fafc;
    vertical-align: middle;
    color: #334155;
}

table.dataTable tbody tr:hover {
    background-color: #f0fdf4 !important;
}

table.dataTable tfoot th {
    background-color: #f8fafc !important;
    color: #0f172a !important;
    font-weight: 700;
    padding: 0.75rem 0.85rem;
    border-top: 2px solid #cbd5e1 !important;
}

/* Numeric table columns */
.number-col,
table.dataTable td.text-end,
table.dataTable th.text-end {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

/* DataTable Buttons */
.dt-buttons .btn,
.btnRefresh {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: 0.5rem !important;
    padding: 0.4rem 0.85rem !important;
    margin-right: 0.5rem;
    transition: all 0.2s ease;
}

.dt-buttons .btn:hover,
.btnRefresh:hover {
    background-color: #f1f5f9 !important;
    color: #059669 !important;
    border-color: #059669 !important;
}

/* Backward compatibility for Legacy Bootstrap 4 Badges and Labels */
.badge-primary,
.label-primary {
    background-color: #059669 !important;
    color: #ffffff !important;
    border: none;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
    font-weight: 600;
    font-size: 0.775rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.badge-primary:hover,
.label-primary:hover {
    background-color: #047857 !important;
    color: #ffffff !important;
}

.badge-success,
.label-success {
    background-color: #10b981 !important;
    color: #ffffff !important;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
    font-weight: 600;
    font-size: 0.775rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    cursor: pointer;
}
.badge-success:hover,
.label-success:hover {
    background-color: #059669 !important;
    color: #ffffff !important;
}

.badge-danger,
.label-danger {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
    font-weight: 600;
    font-size: 0.775rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    cursor: pointer;
}
.badge-danger:hover,
.label-danger:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

.badge-warning,
.label-warning {
    background-color: #f59e0b !important;
    color: #ffffff !important;
    border-radius: 0.375rem;
    padding: 0.35rem 0.65rem;
    font-weight: 600;
    font-size: 0.775rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    text-decoration: none;
    cursor: pointer;
}

/* Alert styles */
.alert-primary {
    background-color: #ecfdf5 !important;
    border: 1px solid #a7f3d0 !important;
    color: #065f46 !important;
    border-radius: 0.5rem;
    font-weight: 600;
}

.alert-success {
    background-color: #f0fdf4 !important;
    border: 1px solid #bbf7d0 !important;
    color: #166534 !important;
    border-radius: 0.5rem;
    font-weight: 600;
}

/* Buttons */
.btn-primary {
    background-color: #059669 !important;
    border-color: #059669 !important;
    color: #ffffff !important;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #047857 !important;
    border-color: #047857 !important;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.25);
}

.btn-success {
    background-color: #10b981 !important;
    border-color: #10b981 !important;
}

.btn-danger {
    background-color: #ef4444 !important;
    border-color: #ef4444 !important;
}

/* Form Controls & Select2 Customization */
.form-control,
.form-select {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    color: #1e293b;
    background-color: #ffffff;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.select2-container .select2-selection--single {
    height: 38px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.5rem !important;
    padding: 4px 8px !important;
    display: flex;
    align-items: center;
}

.select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    height: 36px !important;
}

.select2-dropdown {
    border: 1px solid #d1d5db !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
}

.select2-results__option--highlighted[aria-selected] {
    background-color: #059669 !important;
}

/* Nav Tabs & Nav Pills */
.nav-tabs .nav-link {
    font-weight: 600;
    color: #64748b;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.65rem 1.25rem;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: #059669;
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: #059669 !important;
    border-bottom: 2px solid #059669 !important;
    background: transparent;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.25rem 1.5rem;
}

.modal-header .modal-title {
    font-weight: 700;
    color: #0f172a;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 1rem 1.5rem;
    background: #f8fafc;
}

/* Export Cards */
.export-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #ffffff;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
    overflow: hidden;
}

.export-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.07);
}

.export-card .export-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    font-weight: 700;
    color: #064e3b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Toastr customization */
#toast-container > .toast-success {
    background-color: #059669 !important;
}

#toast-container > .toast-error {
    background-color: #ef4444 !important;
}

/* Responsive adjust */
@media (max-width: 991.98px) {
    .gov-banner {
        padding: 1.25rem 1rem;
    }
    .kpi-card .kpi-value {
        font-size: 1.35rem;
    }
}
