/* Pastikan ruang untuk scrollbar sentiasa ada */
html {
    scrollbar-gutter: stable;
}

/* Kelas untuk sekat scroll apabila modal/sidebar dibuka PADA SKRIN KECIL SAHAJA */

    body.modal-open {
        overflow: hidden;
    }


body { 
    font-family: 'Inter', sans-serif; 
}

/* Menambah transisi yang lancar untuk semua elemen */
*, ::before, ::after {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* CSS UNTUK SKELETON LOADER */
@keyframes pulse {
    50% {
        opacity: .5;
    }
}
.skeleton {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    background-color: #e5e7eb; /* bg-slate-200 */
    border-radius: 0.5rem;
}
.dark .skeleton {
    background-color: #334155; /* dark:bg-slate-700 */
}

/* CSS UNTUK IKON TEMA (ANTI-FLICKER) */
#theme-toggle-light-icon { display: none; }
#theme-toggle-dark-icon { display: block; }
.dark #theme-toggle-light-icon { display: block; }
.dark #theme-toggle-dark-icon { display: none; }


.card-hover-effect { 
    transition-property: transform, box-shadow, border-color;
    transition-duration: 0.2s;
    transition-timing-function: ease-in-out;
    border: 1px solid transparent;
}
.card-hover-effect:hover { 
    transform: translateY(-6px); 
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    border-color: #3b82f6;
}
.dark .card-hover-effect:hover {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #e5e7eb; }
::-webkit-scrollbar-thumb { background: #9ca3af; border-radius: 10px; }

.dark ::-webkit-scrollbar-track { background: #1f2937; }
.dark ::-webkit-scrollbar-thumb { background: #4b5563; }


.swal2-popup {
    background: #fff;
    border-radius: 1rem;
}

/* Gaya Butang Kategori */
.category-btn.active {
    background-color: #3b82f6;
    color: white;
}
.dark .category-btn.active {
    background-color: #3b82f6 !important;
    color: white !important;
}

.category-btn.active:hover {
    background-color: #3b82f6;
}
.dark .category-btn.active:hover {
    background-color: #3b82f6 !important;
}

.category-count {
    background-color: #e2e8f0; 
    color: #475569;
}
.dark .category-count {
    background-color: #475569;
    color: #e2e8f0;
}
.category-btn.active .category-count {
    background-color: #ffffff;
    color: #2563eb;
}

.category-btn.delete-mode-active {
    background-color: transparent !important;
    color: #ef4444 !important;
    border: 1px solid #ef4444;
    cursor: default;
}
.dark .category-btn.delete-mode-active {
    color: #f87171 !important;
    border-color: #ef4444;
}
.delete-category-icon svg {
    color: #ef4444;
}
.dark .delete-category-icon svg {
    color: #f87171;
}

#toggle-delete-mode-btn.active {
    background-color: #fee2e2;
}
#toggle-delete-mode-btn.active svg {
    color: #dc2626;
}
.dark #toggle-delete-mode-btn.active {
    background-color: #450a0a;
}
.dark #toggle-delete-mode-btn.active svg {
    color: #f87171;
}

/* Tom Select Styling */
.ts-control {
    background-color: #f3f4f6 !important;
    border-radius: 0.5rem !important;
    border: 2px solid transparent !important;
    padding: 0.5rem 1rem !important;
}
.ts-control.focus {
    box-shadow: none !important;
    border-color: #3b82f6 !important;
}
.ts-dropdown {
    border-radius: 0.5rem !important;
    border: 1px solid #e5e7eb !important;
    background-color: white !important;
}
.ts-dropdown .ts-option { 
    padding: 0.5rem 1rem !important; 
}
.ts-dropdown .ts-option.active, 
.ts-dropdown .ts-option:hover {
    background-color: #3b82f6 !important;
    color: white !important;
}
.ts-dropdown .create { 
    color: #1d4ed8 !important; 
}

.dark .ts-control {
    background-color: #334155 !important;
    color: #e2e8f0;
}
.dark .ts-dropdown {
    background-color: #475569 !important;
    border-color: #475569 !important;
    color: #ffffff;
}
.dark .ts-dropdown .ts-option {
    color: #cbd5e1;
}
.dark .ts-dropdown .ts-option.active, 
.dark .ts-dropdown .ts-option:hover {
    background-color: #3b82f6 !important;
    color: white !important;
}
.dark .ts-dropdown .create {
    color: #60a5fa !important;
}
.dark .ts-control .item {
    color: #e2e8f0;
}

/* SweetAlert2 Dark Mode Styling */
.dark .swal2-popup {
    background: #1e293b;
    color: #e2e8f0;
}
.dark .swal2-title {
    color: #f1f5f9 !important;
}
.dark .swal2-html-container {
    color: #94a3b8 !important;
}
.dark .swal2-input {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #4b5563 !important;
}

/* 👇 PERUBAHAN: Kelas baru untuk menghadkan teks kepada 2 baris */
.line-clamp-2 {
   overflow: hidden;
   display: -webkit-box;
   -webkit-box-orient: vertical;
   -webkit-line-clamp: 2;
}
/* Tambahan untuk Favicon dalam Dark Mode */
.dark .flex-shrink-0 img {
    background-color: #e2e8f0; /* Warna kelabu cerah (slate-200) */
    border-radius: 50%;      /* Tukar kepada bentuk bulatan penuh */
    padding: 2px;            /* Tambah ruang di sekeliling ikon */
}

/*
 * Mengawal lebar pop-up 'Enter New Category' pada skrin kecil.
 * Ia akan aktif pada skrin dengan lebar 640px ke bawah.
*/
@media (max-width: 640px) {
    .swal2-popup.new-category-swal {
        width: 90%; /* Menjadikan lebar kotak 90% dari lebar skrin */
    }
}

/* Menetapkan saiz untuk pop-up info bookmark */
.swal2-popup.info-swal {
    width: 550px;
}

/* Menjadikan pop-up lebih responsif pada skrin kecil */
@media (max-width: 640px) {
    .swal2-popup.info-swal {
        width: 90%;
    }
}
/* Stail untuk butang edit kategori utama */
#toggle-edit-mode-btn.active {
    background-color: #dbeafe; /* blue-100 */
}
#toggle-edit-mode-btn.active svg {
    color: #2563eb; /* blue-600 */
}
.dark #toggle-edit-mode-btn.active {
    background-color: #1e3a8a; /* blue-900 */
}
.dark #toggle-edit-mode-btn.active svg {
    color: #60a5fa; /* blue-400 */
}

/* Stail untuk butang kategori dalam mod edit */
.category-btn.edit-mode-active {
    background-color: transparent !important;
    color: #3b82f6 !important; /* blue-500 */
    border: 1px solid #3b82f6;
    cursor: default;
}
.dark .category-btn.edit-mode-active {
    color: #60a5fa !important; /* blue-400 */
    border-color: #60a5fa;
}

.ts-dropdown-content {
    max-height: 22vh;
}

/* Stail untuk kandungan popup delete di mobile */
.swal-delete-confirm {
    text-align: center;
    word-wrap: break-word;
}
.swal-delete-confirm .swal2-input {
    display: block;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1em;
}
.preserve-whitespace {
    white-space: pre-wrap;
    word-wrap: break-word;
}

