/* ==========================================
   INVOMATE - GLOBAL STYLES
   Font: Poppins Only
   ========================================== */

/* Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

p {
    line-height: 1.6;
}

/* Navigation */
.nav-item {
    color: #cbd5e1;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background-color: #334155;
    color: white;
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: white;
    border-radius: 0 2px 2px 0;
}

/* Sidebar Scrollbar */
aside ::-webkit-scrollbar {
    width: 4px;
}

aside ::-webkit-scrollbar-track {
    background: #1e293b;
}

aside ::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

aside ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Main Content Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-paid { background: #ecfdf5; color: #059669; }
.badge-sent { background: #eff6ff; color: #2563eb; }
.badge-draft { background: #f8fafc; color: #64748b; }
.badge-overdue { background: #fef2f2; color: #dc2626; }

/* Table Styles */
.table-row:hover {
    background-color: #f8fafc;
}

.table-row:hover .action-buttons {
    opacity: 1;
}

.action-buttons {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Form Inputs */
.form-input {
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Loading States */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
    
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        font-size: 12pt;
    }
}

/* Invoice Status Colors */
.status-select.draft {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.status-select.sent {
    background-color: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.status-select.paid {
    background-color: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.status-select.overdue {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* --- FIX DROPDOWN ITEM (Invoice Form) --- */
/* Paksa container items jadi visible supaya dropdown tak terpotong */
#itemsBody {
    overflow: visible !important;
}

#itemsBody tr {
    overflow: visible !important;
}

#itemsBody td {
    overflow: visible !important;
}

/* Pastikan dropdown sentiasa kat depan dan ada scrollbar kalau panjang sangat */
.choices__list--dropdown {
    z-index: 9999 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}


/* --- CLEANER DROPDOWN UI --- */
.choices__list--dropdown {
    z-index: 9999 !important;
    max-height: 60vh !important; /* Tinggi sikit, sampai 60% skrin */
}

/* Sembunyikan scrollbar (Chrome/Edge/Safari) */
.choices__list--dropdown::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

/* Sembunyikan scrollbar (Firefox) */
.choices__list--dropdown {
    scrollbar-width: none;
}

/* Paksa dropdown product keluar dari table */
#itemsBody .choices[data-type*="select-one"] .choices__list--dropdown {
    position: fixed !important;
    z-index: 9999 !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
}

/* Cancel position fixed dari cubaan tadi */

/* --- FINAL FIX DROPDOWN POSITIONING --- */
/* Beri anchor point pada cell Description */
#itemsBody td:first-child {
    position: relative !important;
    overflow: visible !important;
}

/* Pastikan dropdown duduk betul-betul bawah input */
#itemsBody .choices__list--dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9999 !important;
    margin-top: 4px !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1) !important;
}

/* --- CLEAN INVOICE DROPDOWN --- */
/* Biarkan overflow, tapi buat scrollbar invisible */
#itemsBody .choices__list--dropdown {
    max-height: 400px !important;
    overflow-y: auto !important;
    z-index: 9999 !important;
    
    /* Smooth scrollbar (invisible tapi berfungsi) */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

/* Hide scrollbar for Chrome/Safari */
#itemsBody .choices__list--dropdown::-webkit-scrollbar {
    width: 4px;
}

#itemsBody .choices__list--dropdown::-webkit-scrollbar-track {
    background: transparent;
}

#itemsBody .choices__list--dropdown::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 20px;
}

/* Show scrollbar bila hover */
#itemsBody .choices__list--dropdown:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.5);
}

/* --- FINAL CSS FIX FOR PRODUCT DROPDOWN --- */
/* Paksa parent container visible */
#itemsBody,
#itemsBody tr,
#itemsBody td {
    overflow: visible !important;
}

/* Paksa dropdown keluar dengan style yang betul */
.choices[data-type*="select-one"] .choices__list--dropdown,
.choices[data-type*="select-one"] .choices__list[aria-expanded] {
    z-index: 9999 !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 400px !important;
    overflow-y: auto !important;
    border: 1px solid #e5e7eb !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1) !important;
    background: white !important;
    margin-top: 2px !important;
}

/* Smooth scrollbar */
.choices__list--dropdown::-webkit-scrollbar {
    width: 6px;
}

.choices__list--dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.choices__list--dropdown::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.choices__list--dropdown:hover::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.5);
}

/* --- CUSTOM PRODUCT DROPDOWN STYLES --- */

/* Pastikan cell dalam table tak potong dropdown */
#itemsBody td:first-child {
    overflow: visible !important;
    position: relative !important;
    z-index: 10;
}

/* Style untuk container dropdown */
.custom-dropdown-list {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1) !important;
    z-index: 9999 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    margin-top: 4px !important;
    display: none; /* Hidden by default */
}

/* Style untuk setiap item dalam list */
.custom-dropdown-item {
    padding: 10px 16px !important;
    cursor: pointer !important;
    font-size: 0.875rem !important;
    color: #374151 !important;
    transition: background 0.2s !important;
    border-bottom: 1px solid #f3f4f6 !important;
}

.custom-dropdown-item:hover {
    background-color: #f9fafb !important;
    color: #111827 !important;
}

.custom-dropdown-item:last-child {
    border-bottom: none !important;
}

/* Style untuk scrollbar custom list */
.custom-dropdown-list::-webkit-scrollbar {
    width: 6px;
}
.custom-dropdown-list::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}
.custom-dropdown-list::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* Reset table rows supaya tak wujudkan stacking context baru */
#itemsBody tr,
#itemsBody td {
    position: static !important;
    z-index: auto !important;
    overflow: visible !important;
}

/* Dropdown list jadi fixed dan terap di atas */
.custom-dropdown-list {
    position: fixed !important;
    z-index: 99999 !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    min-width: 300px !important;
    max-width: 500px !important;
}
