/* Design tokens */
:root {
    --primary: #015958;
    --primary-soft: rgba(1, 89, 88, .14);
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --surface: #ffffff;
    --surface-alt: #F1F5F9;
    --surface-hover: rgba(15, 23, 42, .06);
    --background: #F8FAFC;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --ring: rgba(1, 89, 88, .18);
    --shadow-soft: 0 12px 32px -20px rgba(15, 23, 42, .18);
}

[data-theme="dark"] {
    color-scheme: dark;
    --primary: #20B2AA;
    --primary-soft: rgba(32, 178, 170, .22);
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --surface: #132133;
    --surface-alt: #0D1726;
    --surface-hover: rgba(148, 163, 184, .08);
    --background: #0B1120;
    --text: #F8FAFC;
    --text-muted: #9CA3AF;
    --border: rgba(148, 163, 184, .24);
    --ring: rgba(32, 178, 170, .35);
    --shadow-soft: 0 28px 60px -32px rgba(8, 47, 73, .85);
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    background-color: var(--background);
    color: var(--text);
    transition: background-color .3s ease, color .3s ease;
}

aside {
    background-color: var(--surface-alt);
    border-right: 1px solid var(--border);
    transition: background-color .3s ease, border-color .3s ease;
}

main,
header,
.bg-surface,
.modal-content {
    transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}

.bg-surface {
    background-color: var(--surface);
    border: 1px solid transparent;
}

[data-theme="dark"] .bg-surface {
    border-color: rgba(148, 163, 184, .1);
}

.text-main {
    color: var(--text);
}

.text-muted {
    color: var(--text-muted);
}

.hover-bg-muted:hover {
    background-color: var(--surface-hover);
}

.shadow-soft {
    box-shadow: var(--shadow-soft);
}

.sidebar-item {
    color: var(--text);
    transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.sidebar-item.active {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px -12px var(--primary-soft);
}

.sidebar-item.active svg {
    color: #fff;
}

.sidebar-submenu .sidebar-link {
    color: var(--text);
    transition: color .2s ease;
}

.sidebar-submenu .sidebar-link.active {
    color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .sidebar-submenu .sidebar-link.active {
    color: #7dd3fc;
}

.sidebar-submenu .sidebar-link.active::before {
    content: '';
    background-color: var(--primary);
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
}

[data-theme="dark"] .sidebar-submenu .sidebar-link.active::before {
    background-color: #7dd3fc;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: #9ca3af;
}

[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .35);
}

[data-theme="dark"] .sidebar-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .5);
}

.table-zebra tbody tr:nth-child(even) {
    background-color: #F9FAFB;
}

[data-theme="dark"] .table-zebra tbody tr:nth-child(even) {
    background-color: rgba(148, 163, 184, .06);
}

[data-theme="dark"] .table-zebra tbody tr,
[data-theme="dark"] .table-zebra thead tr {
    border-color: var(--border);
}

[data-theme="dark"] thead.bg-gray-50 {
    background-color: rgba(148, 163, 184, .08) !important;
}

[data-theme="dark"] thead.bg-gray-50 th {
    color: var(--text);
}

/* ===========================
     GLOBAL FORM INPUTS
     =========================== */
.form-input,
input.form-input,
select.form-input,
textarea.form-input {
    display: block;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .625rem .75rem;
    line-height: 1.5;
    outline: 0;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease;
}

.form-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

.form-input:disabled,
.form-input[readonly] {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

[data-theme="dark"] .form-input {
    background: rgba(15, 23, 42, .65);
    border-color: var(--border);
    color: var(--text);
}

[data-theme="dark"] .form-input::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .form-input:disabled,
[data-theme="dark"] .form-input[readonly] {
    background: rgba(30, 41, 59, .6);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-input.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .18);
}

[data-theme="dark"] .form-input.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .25);
}

textarea.form-input {
    resize: vertical;
    min-height: 2.75rem;
}

select.form-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 2rem;
}

input.form-input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: .8;
}

.tab-item.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .tab-item.active {
    border-bottom-color: #7dd3fc;
    color: #7dd3fc;
}

/* Tailwind neutral overrides in dark mode */
[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-700 {
    color: var(--text) !important;
}

[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-400 {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100 {
    background-color: var(--surface) !important;
    color: var(--text) !important;
}

[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300 {
    border-color: var(--border) !important;
}

[data-theme="dark"] .divide-gray-100> :not([hidden])~ :not([hidden]),
[data-theme="dark"] .divide-gray-200> :not([hidden])~ :not([hidden]) {
    border-color: var(--border) !important;
}

[data-theme="dark"] .hover\:bg-gray-50:hover,
[data-theme="dark"] .hover\:bg-gray-100:hover {
    background-color: var(--surface-hover) !important;
}

/* Toggle switch component */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    appearance: none;
    background-color: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
    transition: transform .2s ease;
}

.toggle-switch:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.toggle-switch:checked::after {
    transform: translateX(20px);
}

.toggle-switch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

.toggle-switch:disabled {
    cursor: not-allowed;
    opacity: .6;
}

[data-theme="dark"] .toggle-switch {
    background-color: rgba(148, 163, 184, .25);
    border-color: rgba(148, 163, 184, .35);
}

[data-theme="dark"] .toggle-switch::after {
    background-color: rgba(15, 23, 42, .85);
    box-shadow: 0 1px 3px rgba(8, 47, 73, .5);
}

[data-theme="dark"] .toggle-switch:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

[data-theme="dark"] .toggle-switch:checked::after {
    background-color: rgba(15, 23, 42, .85);
}

[data-theme="dark"] .bg-blue-100 {
    background-color: rgba(56, 189, 248, .16) !important;
}

[data-theme="dark"] .text-blue-800 {
    color: #38BDF8 !important;
}

[data-theme="dark"] .bg-green-100 {
    background-color: rgba(52, 211, 153, .18) !important;
}

[data-theme="dark"] .text-green-800 {
    color: #34D399 !important;
}

[data-theme="dark"] .bg-yellow-100 {
    background-color: rgba(250, 204, 21, .18) !important;
}

[data-theme="dark"] .text-yellow-800 {
    color: #FACC15 !important;
}

[data-theme="dark"] .bg-red-100 {
    background-color: rgba(248, 113, 113, .18) !important;
}

[data-theme="dark"] .text-red-800 {
    color: #F87171 !important;
}

[data-theme="dark"] .bg-red-50 {
    background-color: rgba(248, 113, 113, .12) !important;
}

[data-theme="dark"] .hover\:bg-red-50:hover {
    background-color: rgba(248, 113, 113, .18) !important;
}

/* For page transition simulation */
.page-content {
    display: none;
}

.page-content.active {
    display: block;
}

/* Mobile sidebar */
.sidebar {
    transform: translateX(-100%);
}

.sidebar.open {
    transform: translateX(0);
}

/* Modal */
.modal-overlay {
    transition: opacity .3s ease;
    overflow-y: auto;
}

.modal-content {
    transition: transform .3s ease;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.modal-form {
    align-content: center !important;
    justify-items: center !important;
}

/* ===========================
   OVERRIDE INDIGO → PRIMARY
   =========================== */

/* Text */
.text-indigo-600,
.text-indigo-700,
.text-indigo-800 {
    color: var(--primary) !important;
}

/* Background */
.bg-indigo-600,
.bg-indigo-700 {
    background-color: var(--primary) !important;
}

.bg-indigo-50 {
    background-color: var(--primary-soft) !important;
}

/* Border */
.border-indigo-100,
.border-indigo-200,
.border-indigo-300 {
    border-color: var(--primary-soft) !important;
}

/* Hover states */
.hover\:bg-indigo-700:hover {
    background-color: var(--primary) !important;
}

.hover\:text-indigo-600:hover {
    color: var(--primary) !important;
}

/* Ring */
.focus\:ring-indigo-50:focus,
.focus\:ring-indigo-100:focus {
    --tw-ring-color: var(--ring) !important;
}

.ts-control {
    border: 1px solid var(--border) !important;
    padding: .625rem .75rem !important;
    width: 100%;
    overflow: hidden;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    box-shadow: none;
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
}

.signature-canvas {
    touch-action: none;
}

.ttd-draw-box {
    width: 100%;
    max-width: 420px;
    height: 190px;
    margin: 0 auto;
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
}

.ttd-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.ts-control {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    /* rounded-xl */
    padding: 8px 12px;
    min-height: 52px;
    /* Tinggi kotak nyaman */

    /* Flexbox: Agar item & input berjejer */
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px;
    /* Jarak antar nama dan kursor ketik */

    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    position: relative;
    cursor: text;
    /* Ubah kursor mouse jadi 'I' saat hover */
}

/* 2. AREA KETIK (INPUT) - INI SOLUSINYA */
/* Kita paksa input punya lebar minimal agar kursor terlihat */
.ts-control>input {
    display: inline-block !important;
    flex: 1 1 auto !important;
    /* Isi ruang kosong */
    min-width: 150px !important;
    /* LEBAR MINIMAL: Agar pasti kelihatan */
    width: auto !important;

    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;

    font-size: 0.875rem !important;
    color: #1e293b !important;
    opacity: 1 !important;
    /* Pastikan tidak transparan */
}

/* Placeholder styling */
.ts-control>input::placeholder {
    color: #94a3b8;
}

/* 3. Item yang sudah dipilih (Tags) */
.ts-control .item {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    padding: 4px 10px;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    cursor: default;
}

/* 4. Focus State (Ring Biru) */
.ts-wrapper.focus .ts-control {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Dropdown Menu */
.ts-dropdown {
    margin-top: 8px;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    border: 1px solid #f1f5f9;
    z-index: 50;
}

[x-cloak] {
    display: none !important;
}