@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background: #93c5fd;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #60a5fa;
}
::-webkit-scrollbar-track {
    background: transparent;
}

/* ===== TRANSITIONS ===== */
body, .sidebar, .topbar, .kanban-card, .kanban-column, .workflow-step, .tab-btn, .sub-tab-btn, .modal-tab-btn {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== LOGIN PAGE ===== */
.login-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* ===== NAVIGATION ===== */
.nav-link.active {
    background-color: #3b82f6;
    color: #ffffff;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.nav-link-header.active {
    background-color: #eff6ff;
    color: #3b82f6;
    font-weight: 500;
}

.dark .nav-link-header.active {
    background-color: #1f2937;
    color: #60a5fa;
}

/* ===== TABS ===== */
.tab-btn {
    border-color: transparent;
    color: #6b7280;
    transition: all 0.3s ease;
}

.tab-btn.active {
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
    font-weight: 600 !important;
}

.tab-btn:not(.active):hover {
    color: #374151;
    border-color: #d1d5db;
}

.dark .tab-btn {
    color: #9ca3af;
}

.dark .tab-btn.active {
    color: #60a5fa !important;
}

.dark .tab-btn:not(.active):hover {
    color: #e5e7eb;
    border-color: #4b5563;
}

.sub-tab-btn.active, .service-subtab-btn.active {
    background-color: #3b82f6;
    color: #ffffff;
}

/* ===== MODAL TAB BUTTONS ===== */
.modal-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    color: #6b7280;
    cursor: pointer;
}

.modal-tab-btn.active {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.modal-tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    display: none !important;
}

.page-content.active {
    display: block !important;
    height: 100%;
}

.page-content.hidden {
    display: none !important;
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block !important;
}

.modal-tab-content {
    display: block;
}

.modal-tab-content.hidden {
    display: none !important;
}

/* Khắc phục modal và main page contexts */
.modal .tab-content {
    display: none;
}

.modal .tab-content:not(.hidden) {
    display: block;
}

.modal .customer-tab-content {
    display: none;
}

.modal .customer-tab-content:not(.hidden) {
    display: block;
}

/* ===== FORM INPUTS ===== */
.input-readonly {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.dark .input-readonly {
    background-color: #374151;
    color: #d1d5db;
}

/* ===== NATIVE SELECT DARK MODE ===== */
select {
    background-color: #ffffff;
    color: #1f2937;
    border-color: #d1d5db;
}

select:focus {
    border-color: #3b82f6;
    outline: none;
}

.dark select {
    background-color: #374151;
    color: #e5e7eb;
    border-color: #4b5563;
}

.dark select:focus {
    border-color: #60a5fa;
    outline: none;
}

/* Support for select with readonly/disabled state */
select:disabled,
select[readonly] {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.dark select:disabled,
.dark select[readonly] {
    background-color: #374151;
    color: #d1d5db;
    cursor: not-allowed;
}

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.modal-overlay.flex {
    display: flex;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    position: relative;
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-height: 90vh;
    overflow-y: auto;
}

.dark .modal-content {
    background-color: #1f2937;
}

/* ===== FILE UPLOAD ===== */
.file-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px 24px;
    text-align: center;
    background-color: #f9fafb;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.dark .file-upload-area {
    border-color: #4b5563;
    background-color: #1f2937;
}

.file-upload-area.drag-over {
    background-color: #eff6ff;
    border-color: #3b82f6;
}

.dark .file-upload-area.drag-over {
    background-color: #1e3a8a;
    border-color: #60a5fa;
}

.file-drop-area {
    border: 2px dashed #93c5fd;
    background-color: #eff6ff;
}

.dark .file-drop-area {
    border-color: #3b82f6;
    background-color: #1e3a8a;
}

.file-drop-area.dragover {
    border-style: solid;
    background-color: #dbeafe;
}

.dark .file-drop-area.dragover {
    background-color: #1e40af;
}

/* ===== FILE HISTORY ===== */
.history-file-item {
    display: list-item;
    width: 100%;
}

.history-file-item > div {
    width: 100%;
}

.history-file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    border-radius: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-right: 12px;
}

/* ===== SUB-TAB BUTTONS ===== */
.sub-tab-btn-yctt, .sub-tab-btn-dntt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem 0.5rem 0 0;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.dark .sub-tab-btn-yctt, .dark .sub-tab-btn-dntt {
    color: #d1d5db;
}

.sub-tab-btn-yctt:hover, .sub-tab-btn-dntt:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.dark .sub-tab-btn-yctt:hover, .dark .sub-tab-btn-dntt:hover {
    background-color: #374151;
    color: #f9fafb;
}

.sub-tab-btn-yctt.active, .sub-tab-btn-dntt.active {
    background-color: #3b82f6;
    color: #ffffff;
}

/* ===== PAGE SUB-TAB ===== */
.page-sub-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: #6b7280;
    cursor: pointer;
}

.dark .page-sub-tab {
    color: #d1d5db;
}

.page-sub-tab:hover {
    border-color: #e5e7eb;
    color: #111827;
}

.dark .page-sub-tab:hover {
    border-color: #4b5563;
    color: #f9fafb;
}

.page-sub-tab.active {
    border-color: #3b82f6;
    color: #3b82f6;
}

/* ===== ANIMATIONS ===== */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* ===== FLOWCHART ===== */
.flow-step {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid;
    font-weight: 500;
    transition: all 0.3s ease;
}

.flow-step ion-icon {
    font-size: 20px;
    margin-right: 12px;
}

.flow-step.complete {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.dark .flow-step.complete {
    background-color: #14532d;
    border-color: #22c55e;
    color: #dcfce7;
}

.flow-step.pending {
    background-color: #fefce8;
    border-color: #fde08a;
    color: #854d0e;
    cursor: pointer;
    animation: pulse-border 2s infinite;
}

.dark .flow-step.pending {
    background-color: #422006;
    border-color: #facc15;
    color: #fefce8;
}

.flow-step.pending:hover {
    opacity: 0.8;
}

@keyframes pulse-border {
    0% { 
        box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); 
    }
    70% { 
        box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(250, 204, 21, 0); 
    }
}

.flow-step.inactive {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    color: #6b7280;
}

.dark .flow-step.inactive {
    background-color: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.flow-step-arrow {
    text-align: center;
    color: #9ca3af;
    font-size: 20px;
    margin: -8px 0;
}

@media (min-width: 1024px) {
    .flow-step-arrow {
        margin: -4px 0;
    }
}

/* ===== SERVICE SUBTAB CONTENT ===== */
.service-subtab-content {
    display: none;
}

.service-subtab-content.active {
    display: block;
}

/* ===== MOBILE MENU OVERLAY ===== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.hidden {
    display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 50;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    /* Ẩn thanh tìm kiếm trên mobile */
    .topbar .relative:has(#main-search-input) {
        display: none;
    }

    /* Điều chỉnh page title */
    #page-title {
        font-size: 1.25rem;
    }
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-new {
    background-color: #dbeafe;
    color: #1e40af;
}

.dark .status-new {
    background-color: #1e3a8a;
    color: #93c5fd;
}

.status-pending {
    background-color: #fef3c7;
    color: #92400e;
}

.dark .status-pending {
    background-color: #78350f;
    color: #fbbf24;
}

.status-completed {
    background-color: #d1fae5;
    color: #065f46;
}

.dark .status-completed {
    background-color: #064e3b;
    color: #6ee7b7;
}

.status-overdue {
    background-color: #fee2e2;
    color: #991b1b;
}

.dark .status-overdue {
    background-color: #7f1d1d;
    color: #fca5a5;
}

/* ===== LEGAL DOCUMENTS PAGE ===== */
.legal-tab-btn {
    border-color: transparent;
    color: #6b7280;
    transition: all 0.2s;
}

.legal-tab-btn.active {
    border-color: #3b82f6;
    color: #3b82f6;
    font-weight: 600;
}

.legal-tab-btn:hover {
    color: #1f2937;
    border-color: #d1d5db;
}

.dark .legal-tab-btn:hover {
    color: #f3f4f6;
    border-color: #4b5563;
}

/* ===== MODAL STYLES ===== */
.modal {
    backdrop-filter: blur(4px);
}

.modal-backdrop {
    transition: opacity 0.3s ease;
}

.modal-content {
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}
/* ===== SCORE RING (Circular Progress) ===== */
.score-ring {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    background: conic-gradient(
        currentColor 0deg,
        currentColor calc(var(--score, 0) * 3.6deg),
        transparent calc(var(--score, 0) * 3.6deg),
        transparent 360deg
    );
}

.score-ring::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: white;
}

.dark .score-ring::before {
    background: #1f2937;
}

.score-ring::after {
    content: attr(data-score);
    position: relative;
    z-index: 1;
}

/* ===== PAYMENT PROPOSALS ===== */
#pp-list-body input[type="checkbox"],
#select-all-pp {
    width: 0.875rem; /* 14px */
    height: 0.875rem; /* 14px */
}

/* ===== PERMISSION HIDDEN ===== */
/* Ẩn mặc định các phần tử cần phân quyền, chỉ hiện khi có quyền */
.permission-hidden {
    display: none !important;
}

/* Class để hiện phần tử khi có quyền */
/* Cho menu items (li elements) - dùng block để giữ layout dọc */
li.permission-visible {
    display: list-item !important;
}

/* Cho các elements khác (buttons, divs có flex) */
.permission-visible:not(li) {
    display: flex !important;
}

/* Cho các button/inline elements */
.permission-visible-inline {
    display: inline-flex !important;
}

/* Cho các block elements */
.permission-visible-block {
    display: block !important;
}

/* ===== DRAGGABLE MODAL ===== */
/* Style for jQuery UI draggable modals */
.bg-light-card.ui-draggable {
    position: fixed !important;
    z-index: 51;
}

.dark .bg-dark-card.ui-draggable {
    position: fixed !important;
    z-index: 51;
}

/* Modal header draggable handle - target the header directly */
.ui-draggable > .flex.items-center.justify-between.p-2 {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.ui-draggable > .flex.items-center.justify-between.p-2:active {
    cursor: grabbing;
}

/* While dragging */
.ui-draggable-dragging {
    opacity: 0.95;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}