﻿/* ==================== ROOT VARIABLES - KOREAN GREEN THEME ==================== */
:root {
    --primary: #063b6a;
    --primary-dark: #052e52;
    --primary-light: #1a5d8a;
    --primary-soft: #e6f0f7;
    --primary-bg: #f5f9fc;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --dark: #1e293b;
    --dark-2: #334155;
    --gray: #64748b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --sidebar-bg: #063b6a;
    --sidebar-hover: #1a5d8a;
    --sidebar-active: #2a6d9a;
    --navbar-bg: #063b6a;
    --sidebar-width: 280px;
    --header-height: 44px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 12px;
    background: var(--primary-bg);
    overflow-x: hidden;
}

/* ==================== TOP NAVBAR ==================== */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--navbar-bg);
    box-shadow: 0 2px 10px rgba(6, 59, 106, 0.2);
    z-index: 1055;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 14px;
    max-width: 100%;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    font-size: 1.3rem;
    color: white;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .menu-toggle:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: scale(1.02);
    }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
}

    .logo i {
        font-size: 1.5rem;
        color: white;
    }

    .logo span {
        color: white;
        letter-spacing: 0.5px;
    }

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    padding: 8px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: white;
}

    .icon-btn:hover {
        background: rgba(255, 255, 255, 0.25);
    }

.user-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    padding: 8px 14px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: white;
}

    .user-btn:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .user-btn i {
        font-size: 1.2rem;
    }

/* Dropdown Menu */
.dropdown-menu {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    margin-top: 8px;
    min-width: 200px;
}

.dropdown-item {
    padding: 10px 20px;
    font-size: 0.9rem;
    transition: var(--transition);
}

    .dropdown-item:hover {
        background-color: var(--primary-soft);
        color: var(--primary);
    }

    .dropdown-item i {
        width: 20px;
        color: var(--primary);
    }

/* ==================== SIDEBAR ==================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
}

.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1020;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    z-index: 1030;
    overflow-y: auto;
}

.sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Sidebar User Info */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 16px;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .user-avatar i {
        font-size: 1.8rem;
        color: white;
    }

.user-details h6 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: white;
}

.user-details span {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: var(--border-radius);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.9rem;
}

    .nav-link i {
        width: 22px;
        font-size: 1rem;
        text-align: center;
    }

    .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }

    .nav-link.active {
        background: var(--primary-light);
        color: white;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

/* Submenu */
.nav-item.has-submenu {
    position: relative;
}

    .nav-item.has-submenu .nav-link {
        cursor: pointer;
    }

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
}

.nav-item.has-submenu.open .submenu {
    max-height: 600px;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 50px;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
}

    .submenu-link i {
        width: 20px;
        font-size: 0.85rem;
    }

    .submenu-link:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
    }

    .submenu-link.active {
        color: white;
        background: rgba(255, 255, 255, 0.15);
    }

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: auto;
}

.datetime {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.version {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height));
    background: var(--primary-bg);
}

.content-wrapper {
    padding: 5px;
    min-height: 100%;
    margin: 0;
}

/* ==================== CARD STYLES ==================== */
.card {
    border: 1px solid #4e9cd0;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    margin: 2px;
}

    /* .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px rgba(6, 59, 106, 0.12);
    } */

.card-header {
    background: #4e9cd0;
    border-bottom: 2px solid var(--primary-soft);
    border-radius: 10px 10px 0 0 !important;
    padding: 6px 10px;
    font-weight: 600;
    color: var(--primary);
    height: var(--header-height);
}

/* ==================== BUTTON STYLES ==================== */
.btn {
    border: none;
    border-radius: 5px;
    padding: 2px 5px;
    font-weight: 500;
    transition: var(--transition);
    height: 30px;
}

    /* .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(6, 59, 106, 0.3);
    } */

    .btn:disabled,
    .btn.disabled {
        opacity: 0.65;
        cursor: not-allowed;
        transform: none;
    }

/* Nút Cancel/Confirm dùng chung toàn app (NewProjectMaster làm đầu tiên).
   Override height/padding/border cứng từ .btn global ở trên. */
.btn-cancel,
.btn-confirm-primary {
    height: auto;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.btn-cancel {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
}

    .btn-cancel:hover {
        background: #f3f4f6;
        border-color: #d1d5db;
        color: #111827;
        transform: none;
        box-shadow: none;
    }

.btn-confirm-primary {
    background: #1468f3;
    border: 1px solid #1468f3;
    color: #fff;
}

    .btn-confirm-primary:hover {
        background: #0c5de0;
        border-color: #0c5de0;
        color: #fff;
        transform: none;
        box-shadow: none;
    }

/* ==================== TABLE STYLES ==================== */
.table {
    border-radius: var(--border-radius);
    overflow: hidden;
    background: white;
}

    .table thead th {
        background: var(--primary);
        color: white;
        font-weight: 600;
        border: none;
        padding: 4px 8px;
    }

    .table tbody tr:hover {
        background-color: var(--primary-soft);
    }

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================== MODAL STYLES ==================== */
.modal {
    backdrop-filter: blur(4px);
    z-index: 1050;
}

.modal-backdrop {
    z-index: 1040;
}

.modal-dialog {
    margin: 1.75rem auto;
}

.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    background: white;
}

.modal-header {
    background: linear-gradient(135deg, #063b6a, #0f766e);
    color: white;
    border-bottom: none;
    padding: 6px 14px;
    height: 45px;
}

    .modal-header .modal-title {
        font-weight: 600;
        font-size: 1rem;
        color: white;
    }

    .modal-header .btn-close {
        filter: brightness(0) invert(1);
        opacity: 0.8;
        transition: all 0.2s ease;
    }

        .modal-header .btn-close:hover {
            opacity: 1;
            transform: rotate(90deg);
        }

.modal-body {
    padding: 24px;
    background: white;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

    .modal-body::-webkit-scrollbar {
        width: 6px;
    }

    .modal-body::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: var(--border-radius);
    }

    .modal-body::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: var(--border-radius);
    }

        .modal-body::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    background: #fafbfc;
    border-radius: 0 0 20px 20px;
}

/* ==================== FORM STYLES ==================== */
.form-control {
    height: 1.9rem;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(6, 59, 106, 0.2);
    }

.form-label {
    font-weight: 500;
    color: var(--dark);
}

.form-group {
    margin-bottom: 1rem;
}

.form-select {
    background-color: white;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
}

.input-group-text {
    background-color: var(--primary-soft);
    border: 1px solid var(--border);
    color: var(--dark);
}

/* Select2 — đồng bộ theme với .form-select
   (prefix .select2-container để tăng specificity, thắng select2.min.css load sau trong section Scripts)
   Normal state theo chuẩn input module: border #ccd5e1 + radius 6px */
.select2-container.select2-container--default .select2-selection--single {
    height: 2.375rem;
    border: 1px solid #ccd5e1;
    border-radius: 6px;
    background-color: white;
}

.select2-container.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 2.375rem;
    padding-left: 0.75rem;
    padding-right: 2.25rem;
    color: var(--dark);
}

.select2-container.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--gray);
}

.select2-container.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 2.375rem;
    right: 8px;
}

/* Focus / open — giống .form-select:focus của input module (#1769d5 + shadow nhạt) */
.select2-container.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #1769d5;
    box-shadow: 0 0 0 2px #eff6ff;
}

/* Mũi tên chevron thay tam giác mặc định */
.select2-container.select2-container--default .select2-selection--single .select2-selection__arrow b {
    display: none;
}

.select2-container.select2-container--default .select2-selection--single .select2-selection__arrow {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}

/* Dropdown results — border + radius đồng bộ ô selection (#ccd5e1 / 6px) */
.select2-container .select2-dropdown {
    border-color: #ccd5e1;
    border-radius: 6px;
}

.select2-container .select2-results__option {
    font-size: 12px;
}

.select2-container.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--primary);
}

/* Validation — border đỏ khi thiếu field */
.select2-container.select2-container--default .select2-selection--single.is-invalid {
    border-color: var(--danger);
}

.select2-container.select2-container--default.select2-container--focus .select2-selection--single.is-invalid {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Required field */
.required:after {
    content: " *";
    color: var(--danger);
    font-weight: bold;
}

/* Form validation */
.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--danger);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ef4444'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='0.6' fill='%23ef4444' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--success);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Switch/Checkbox */
.form-switch .form-check-input {
    width: 2em;
    margin-left: -2.5em;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(6, 59, 106, 0.25);
}

/* ==================== BADGE STYLES ==================== */
.badge {
    padding: 4px 10px;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.8rem;
}

    .badge.bg-primary {
        background-color: var(--primary) !important;
    }

/* ==================== PAGINATION STYLES ==================== */
.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

.page-link {
    color: var(--primary);
}

    .page-link:hover {
        color: var(--primary-dark);
    }

/* ==================== SIDEBAR TOGGLE (Desktop) ==================== */
@media (min-width: 993px) {
    .sidebar.sidebar-hidden {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .main-content.sidebar-hidden {
        margin-left: 0;
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .nav-container {
        padding: 0 16px;
    }

    .logo span {
        display: none;
    }

    .user-btn span {
        display: none;
    }

    .icon-btn span {
        display: none;
    }

    .content-wrapper {
        padding: 16px;
    }
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 59, 106, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    background: white;
    padding: 30px 40px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

    .loading-spinner .spinner-border {
        width: 3rem;
        height: 3rem;
        color: var(--primary);
    }

.spinner-border.text-primary {
    color: var(--primary) !important;
}

/* ==================== TOAST ==================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast-glass {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    min-width: 280px;
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.80);
    color: #333;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
    border-left: 4px solid;
}

    .toast-glass.show {
        opacity: 1;
        transform: translateX(0);
    }

.toast-success {
    border-left-color: var(--success);
    background-color: #058400;
}

    .toast-success i {
        color: var(--success);
    }

.toast-warning {
    border-left-color: var(--warning);
    background-color: #8d9100;
}

    .toast-warning i {
        color: var(--warning);
    }

.toast-error {
    border-left-color: var(--danger);
    background-color: #870000;
}

    .toast-error i {
        color: var(--danger);
    }

.toast-info {
    border-left-color: var(--info);
    background-color: #cffafe;
}

    .toast-info i {
        color: var(--info);
    }

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
    background: #1a5d8a;
}

::-webkit-scrollbar-track {
    background: var(--primary-soft);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary-light);
    }

/* ==================== SELECT2 SCROLLBAR ==================== */
/* Override scrollbar global (#1a5d8a, 6px) cho dropdown select2 —
   áp dụng global cho mọi select2 trong app, không cần scope module */
.select2-container--default .select2-results__options::-webkit-scrollbar {
    width: 10px;
    background: #f1f5f9;
}

.select2-container--default .select2-results__options::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.select2-container--default .select2-results__options::-webkit-scrollbar-thumb {
    background: #c1cdd9;
    border-radius: 10px;
}

    .select2-container--default .select2-results__options::-webkit-scrollbar-thumb:hover {
        background: #a3b1c2;
    }

/* ==================== ANIMATION ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-wrapper > * {
    animation: fadeIn 0.3s ease-out;
}

/* ==================== PUBLIC CONTENT ==================== */
.public-main {
    padding-top: var(--header-height);
    min-height: 100vh;
    background: var(--primary-bg);
}

/* ==================== CONTACT INFO STYLES ==================== */
/* Tree Node Actions */
.btn-tree-action {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    transition: all 0.2s ease;
}

    .btn-tree-action:hover {
        transform: scale(1.05);
        opacity: 0.9;
    }

/* Tree Node Active State */
.tree-node.active {
    background: linear-gradient(90deg, rgba(6, 59, 106, 0.15), rgba(6, 59, 106, 0.05));
    border-left: 3px solid #063b6a;
}

    .tree-node.active .fw-medium {
        color: #063b6a;
        font-weight: 600;
    }

/* Search Highlight */
.search-highlight {
    background-color: rgba(6, 59, 106, 0.1);
    border-left: 3px solid #063b6a;
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0% {
        background-color: rgba(6, 59, 106, 0.05);
    }

    50% {
        background-color: rgba(6, 59, 106, 0.2);
    }

    100% {
        background-color: rgba(6, 59, 106, 0.1);
    }
}

/* Tree Stats */
.tree-stats {
    background: var(--primary-soft);
    border-radius: var(--border-radius);
    padding: 4px 12px;
    font-size: 0.75rem;
    color: var(--primary);
}

/* Scroll to Top Button */
.scroll-to-top {
    background-color: #063b6a;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    transition: all 0.3s ease;
}

    .scroll-to-top:hover {
        background-color: #052e52;
        transform: translateY(-2px);
    }

/* Tree Empty State */
.tree-empty-state i {
    color: #063b6a;
    opacity: 0.5;
}

/* Person Table */
#contactTable td {
    vertical-align: middle;
}

/* Modal Header Colors */
#deptModal .modal-header,
#personModal .modal-header {
    background: linear-gradient(135deg, #063b6a, #0f766e);
}

/* ==================== TREE ACTIONS - HOVER EFFECT ==================== */
.tree-actions {
    min-width: 65px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tree-node:hover .tree-actions {
    opacity: 1;
    visibility: visible;
}

.tree-actions .btn-tree-action {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

    .tree-actions .btn-tree-action:hover {
        transform: scale(1.05);
        opacity: 0.9;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

.tree-node:has(.tree-actions:empty) .tree-actions {
    display: none;
}

/* Responsive touch devices */
@media (hover: none) and (pointer: coarse) {
    .tree-actions {
        opacity: 1;
        visibility: visible;
    }

        .tree-actions .btn-tree-action {
            width: 28px;
            height: 28px;
            font-size: 0.7rem;
        }
}

@media (max-width: 768px) {
    .tree-actions {
        min-width: 55px;
    }

        .tree-actions .btn-tree-action {
            width: 26px;
            height: 26px;
            font-size: 0.7rem;
        }
}

/* ==================== SELECTED LIST STYLES ==================== */
.selected-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    min-height: 100px;
}

.selected-list-empty {
    color: #6c757d;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #fafafa;
    transition: all 0.2s ease;
}

    .selected-item:last-child {
        border-bottom: none;
    }

    .selected-item:hover {
        background-color: #f5f5f5;
    }

.selected-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.selected-item-icon {
    width: 28px;
    text-align: center;
    color: #6c757d;
}

.selected-item-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-item-subtext {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: 8px;
    font-weight: normal;
}

.btn-remove-item {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.8rem;
}

    .btn-remove-item:hover {
        background-color: rgba(220, 53, 69, 0.1);
        color: #c82333;
        transform: scale(1.05);
    }

.selected-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid var(--border);
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 0.8rem;
}

    .selected-list-header .count-badge {
        background-color: var(--primary);
        color: white;
        padding: 2px 8px;
        border-radius: var(--border-radius);
        font-size: 0.7rem;
    }

    .selected-list-header .clear-btn {
        background: none;
        border: none;
        color: #dc3545;
        font-size: 0.75rem;
        cursor: pointer;
        padding: 2px 6px;
        border-radius: 4px;
    }

        .selected-list-header .clear-btn:hover {
            text-decoration: underline;
            background-color: rgba(220, 53, 69, 0.1);
        }

/* Variants */
.selected-item.department-item {
    border-left: 3px solid #063b6a;
}

/* ==================== AVAILABLE LIST STYLES ==================== */
.available-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
}

.available-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .available-item:hover {
        background-color: #e3f2fd;
        transform: translateX(3px);
    }

    .available-item:last-child {
        border-bottom: none;
    }

    .available-item.disabled,
    .available-item.selected {
        background-color: #d4edda;
        opacity: 0.7;
        cursor: not-allowed;
    }

.available-item-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.available-item-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #2c3e50;
}

.available-item-subtext {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: 8px;
}

.search-wrapper {
    margin-bottom: 12px;
}

    .search-wrapper .input-group-text {
        background-color: #f8f9fa;
    }

/* ==================== DATATABLE CUSTOM STYLES ==================== */
.dataTables_wrapper {
    padding: 0;
    margin-top: 0;
}

    .dataTables_wrapper .dataTables_length {
        margin-bottom: 1rem;
    }

        .dataTables_wrapper .dataTables_length label {
            font-weight: 500;
            color: var(--dark);
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .dataTables_wrapper .dataTables_length select {
            width: auto;
            min-width: 60px;
            padding: 4px 8px;
            border-radius: var(--border-radius);
            border: 1px solid var(--border);
            background-color: white;
            color: var(--dark);
            cursor: pointer;
        }

    .dataTables_wrapper .dataTables_filter {
        margin-bottom: 1rem;
    }

        .dataTables_wrapper .dataTables_filter label {
            font-weight: 500;
            color: var(--dark);
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .dataTables_wrapper .dataTables_filter input {
            padding: 6px 12px;
            border-radius: var(--border-radius);
            border: 1px solid var(--border);
            background-color: white;
            margin-left: 8px;
            width: 250px;
            transition: var(--transition);
        }

            .dataTables_wrapper .dataTables_filter input:focus {
                border-color: var(--primary);
                outline: none;
                box-shadow: 0 0 0 3px rgba(6, 59, 106, 0.1);
            }

    .dataTables_wrapper .dataTable {
        border-collapse: collapse;
        width: 100%;
        background: white;
        border-radius: var(--border-radius);
        overflow: hidden;
    }

        .dataTables_wrapper .dataTable thead th {
            background: var(--primary);
            color: white;
            font-weight: 600;
            padding: 12px 16px;
            border-bottom: none;
            white-space: nowrap;
        }

        .dataTables_wrapper .dataTable tbody td {
            padding: 10px 12px;
            vertical-align: middle;
            border-bottom: 1px solid var(--border);
            color: var(--dark-2);
        }

        .dataTables_wrapper .dataTable tbody tr:hover {
            background-color: var(--primary-soft);
            cursor: pointer;
        }

    .dataTables_wrapper .dataTables_info {
        padding-top: 1rem;
        font-size: 0.875rem;
        color: var(--gray);
    }

    .dataTables_wrapper .dataTables_paginate {
        padding-top: 1rem;
    }

        .dataTables_wrapper .dataTables_paginate .paginate_button {
            padding: 6px 12px;
            margin: 0 2px;
            border-radius: var(--border-radius);
            border: 1px solid var(--border);
            background: white;
            color: var(--primary);
            font-size: 0.875rem;
            cursor: pointer;
            transition: var(--transition);
        }

            .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
                background: var(--primary-soft);
                border-color: var(--primary);
                color: var(--primary);
            }

            .dataTables_wrapper .dataTables_paginate .paginate_button.current {
                background: var(--primary);
                border-color: var(--primary);
                color: white;
            }

            .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
                opacity: 0.5;
                cursor: not-allowed;
            }

/* DataTable Scroll */
.dataTables_scroll {
    border-radius: var(--border-radius);
    overflow: hidden;
    overflow-x: auto !important;
}

.dataTables_scrollHeadInner {
    background: var(--primary);
    overflow-x: auto !important;
}

.dataTables_scrollBody {
    border-radius: 0 0 12px 12px;
    overflow-x: auto !important;
    overflow-y: visible !important;
}

    .dataTables_scrollBody::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    .dataTables_scrollBody::-webkit-scrollbar-track {
        background: var(--primary-soft);
        border-radius: 4px;
    }

    .dataTables_scrollBody::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 4px;
    }

.dataTables_scroll::-webkit-scrollbar {
    height: 8px;
}

.dataTables_scroll::-webkit-scrollbar-track {
    background: var(--primary-soft);
    border-radius: 4px;
}

.dataTables_scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

    .dataTables_scroll::-webkit-scrollbar-thumb:hover {
        background: var(--primary-dark);
    }

/* Export buttons */
.dt-buttons {
    margin-bottom: 1rem;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

    .dt-buttons .btn,
    .dt-buttons .dt-button {
        background: var(--primary);
        color: white;
        border: none;
        padding: 6px 14px;
        border-radius: 8px;
        font-size: 0.875rem;
        cursor: pointer;
        transition: var(--transition);
    }

        .dt-buttons .btn:hover,
        .dt-buttons .dt-button:hover {
            background: var(--primary-dark);
            transform: translateY(-1px);
        }

/* Responsive DataTable */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        margin-bottom: 1rem;
    }

        .dataTables_wrapper .dataTables_filter input {
            width: 100%;
        }

    .dataTables_wrapper .dataTable thead th {
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .dataTables_wrapper .dataTable tbody td {
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .dataTables_wrapper .dataTable {
        min-width: 700px;
    }
}

/* ==================== MENU TREE STYLES ==================== */
.menu-tree-container {
    padding: 12px;
}

.menu-tree-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

    .menu-tree-list .menu-tree-list {
        margin-top: 4px;
    }

.menu-tree-item {
    margin-bottom: 8px;
}

.menu-tree-node {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

    .menu-tree-node:hover {
        border-color: var(--primary);
        box-shadow: 0 2px 8px rgba(6, 59, 106, 0.1);
    }

        .menu-tree-node:hover .menu-tree-actions {
            opacity: 1;
            visibility: visible;
        }

.menu-tree-item.inactive .menu-tree-node {
    background: #f8f9fa;
    opacity: 0.7;
}

.menu-tree-item.active > .menu-tree-node {
    background: linear-gradient(90deg, rgba(6, 59, 106, 0.1), rgba(6, 59, 106, 0.02));
    border-left: 3px solid var(--primary);
}

.menu-tree-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

.menu-tree-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    border-radius: 8px;
    color: var(--primary);
    flex-shrink: 0;
}

.menu-tree-info {
    flex: 1;
    min-width: 0;
}

.menu-tree-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

    .menu-tree-title strong {
        font-size: 0.95rem;
        color: var(--dark);
    }

    .menu-tree-title .badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

.menu-tree-sub {
    font-size: 0.7rem;
    line-height: 1.4;
}

    .menu-tree-sub small {
        word-break: break-word;
    }

.menu-tree-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

    .menu-tree-actions .btn-tree-action {
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        border: none;
        cursor: pointer;
        font-size: 0.85rem;
    }

        .menu-tree-actions .btn-tree-action:hover {
            transform: scale(1.05);
            opacity: 0.9;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }

/* Menu Tree Empty State */
.menu-tree-empty {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: var(--border-radius);
    border: 1px dashed var(--border);
}

    .menu-tree-empty i {
        font-size: 3rem;
        color: var(--primary-light);
        margin-bottom: 12px;
        opacity: 0.5;
    }

    .menu-tree-empty p {
        color: var(--gray);
        margin-bottom: 16px;
    }

/* Menu Tree Scroll */
.menu-tree-container {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

    .menu-tree-container::-webkit-scrollbar {
        width: 6px;
    }

    .menu-tree-container::-webkit-scrollbar-track {
        background: var(--primary-soft);
        border-radius: 4px;
    }

    .menu-tree-container::-webkit-scrollbar-thumb {
        background: var(--primary-light);
        border-radius: 4px;
    }

/* Responsive Menu Tree */
@media (hover: none) and (pointer: coarse) {
    .menu-tree-actions {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .menu-tree-node {
        flex-wrap: wrap;
        gap: 10px;
    }

    .menu-tree-main {
        width: 100%;
    }

    .menu-tree-actions {
        width: 100%;
        justify-content: flex-end;
        opacity: 1;
        visibility: visible;
    }

        .menu-tree-actions .btn-tree-action {
            width: 36px;
            height: 36px;
        }
}

/* ==================== ALERT CONTAINER ==================== */
#alertContainer {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
}


/* ==================== EXTRA MOBILE OPTIMIZATIONS ==================== */

/* Better touch targets for all interactive elements */
@media (max-width: 768px) {
    button,
    .btn,
    .list-group-item,
    .tree-node-item,
    .user-item,
    .page-link,
    .nav-link,
    .dropdown-item,
    .modal-footer .btn,
    .action-buttons .btn,
    .selected-user-item,
    .available-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm {
        min-height: 36px;
    }

    .btn-xs {
        min-height: 32px;
    }

    /* Improve table readability on mobile */
    .table {
        font-size: 12px;
    }

        .table thead th {
            font-size: 11px;
            padding: 8px 6px;
            white-space: nowrap;
        }

        .table tbody td {
            padding: 10px 6px;
            vertical-align: middle;
        }

        /* Table action buttons */
        .table .btn-sm {
            padding: 4px 8px;
            font-size: 10px;
            min-height: 30px;
        }

    /* Card improvements */
    .card {
        margin-bottom: 12px;
    }

    .card-header {
        padding: 8px 12px;
        height: auto;
        min-height: 40px;
    }

        .card-header h6 {
            font-size: 13px;
            margin: 0;
        }

    /* Modal improvements for mobile */
    .modal-dialog {
        margin: 10px;
    }

    .modal-fullscreen {
        margin: 0;
    }

    .modal-header {
        padding: 10px 12px;
        height: auto;
        min-height: 50px;
    }

        .modal-header .modal-title {
            font-size: 14px;
        }

    .modal-body {
        padding: 15px;
        max-height: calc(100vh - 120px);
    }

    .modal-footer {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

        .modal-footer .btn {
            flex: 1;
            min-width: 80px;
        }

    /* Form controls */
    .form-control,
    .form-select,
    .input-group-text {
        font-size: 14px; /* Prevents zoom on focus in iOS */
    }

        .form-control:focus,
        .form-select:focus {
            font-size: 14px;
        }

    /* Badge improvements */
    .badge {
        font-size: 10px;
        padding: 4px 8px;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    .page-link {
        padding: 6px 10px;
        font-size: 12px;
        min-width: 36px;
    }

    /* Toast messages */
    .toast-message,
    #toast-container .toast-glass {
        min-width: 250px;
        max-width: 90%;
        font-size: 12px;
        padding: 10px 15px;
    }

    /* Loading spinner */
    .loading-spinner {
        padding: 20px 30px;
    }

        .loading-spinner .spinner-border {
            width: 2rem;
            height: 2rem;
        }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
    /* Font sizes */
    body {
        font-size: 11px;
    }

    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.3rem;
    }

    h3, .h3 {
        font-size: 1.15rem;
    }

    h4, .h4 {
        font-size: 1rem;
    }

    h5, .h5 {
        font-size: 0.9rem;
    }

    h6, .h6 {
        font-size: 0.85rem;
    }

    /* Table */
    .table {
        font-size: 11px;
    }

        .table thead th {
            font-size: 10px;
            padding: 6px 4px;
        }

        .table tbody td {
            padding: 8px 4px;
        }

    /* Badges */
    .badge {
        font-size: 9px;
        padding: 3px 6px;
    }

    /* Buttons */
    .btn {
        font-size: 11px;
        padding: 4px 10px;
    }

    .btn-sm {
        font-size: 10px;
        padding: 3px 8px;
    }

    /* Modal */
    .modal-header .modal-title {
        font-size: 13px;
    }

    /* Container padding */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .content-wrapper {
        padding: 8px;
    }

    /* Grid gap */
    .g-3 {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }
}

/* Landscape mode optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-body {
        max-height: calc(100vh - 100px);
    }

    .sidebar {
        overflow-y: auto;
        max-height: 100vh;
    }

    .selected-list,
    .available-list {
        max-height: 200px;
    }
}

/* Improve sidebar animation on mobile */
@media (max-width: 992px) {
    .sidebar-overlay.show {
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
    }

    /* Adjust main content when sidebar is hidden */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* Fix for sticky/fixed elements on mobile */
@media (max-width: 768px) {
    .top-navbar {
        position: sticky;
        top: 0;
        z-index: 1055;
    }

    .app-wrapper {
        padding-top: 0;
    }

    /* Improve scroll containers */
    .table-responsive {
        margin: 0 -8px;
        padding: 0 8px;
        width: calc(100% + 16px);
    }

    /* Better modal scrolling */
    .modal-dialog-scrollable .modal-body {
        overflow-y: auto;
    }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    input[type="datetime-local"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Improve dropdown on mobile */
@media (max-width: 768px) {
    .dropdown-menu {
        max-width: 90vw;
        position: absolute !important;
    }

    .dropdown-item {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Loading overlay on mobile */
@media (max-width: 768px) {
    .loading-overlay {
        backdrop-filter: blur(2px);
    }

    .loading-spinner {
        padding: 15px 25px;
        width: 80%;
        max-width: 250px;
    }
}

/* Safe area support for notched phones */
@supports (padding: max(0px)) {
    .top-navbar {
        padding-top: env(safe-area-inset-top);
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .modal-header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .modal-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Improve touch feedback */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .nav-link:active,
    .list-group-item:active,
    .tree-node-item:active {
        opacity: 0.7;
        transform: scale(0.98);
        transition: transform 0.05s;
    }

    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .card:hover {
        transform: none;
    }
}
