/* ============================================
   Base Styles
   ============================================ */
:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --success-color: #34a853;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;
    --border-color: #dadce0;
    --bg-light: #f8f9fa;
    --bg-card: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(60,64,67,0.1), 0 1px 3px 1px rgba(60,64,67,0.08);
    --shadow-md: 0 1px 3px 0 rgba(60,64,67,0.15), 0 4px 8px 3px rgba(60,64,67,0.1);
    --shadow-lg: 0 2px 6px 2px rgba(60,64,67,0.15), 0 8px 16px 8px rgba(60,64,67,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

html {
    font-size: 14px;
    height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f1f3f4;
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
}

/* ============================================
   Layout Structure
   ============================================ */
#wrapper {
    display: flex;
    height: 100vh;
}

/* ============================================
   Sidebar - Fresh Design
   ============================================ */
#sidebar-wrapper {
    width: 240px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    margin-left: -240px;
    transition: margin 0.25s ease;
    z-index: 1000;
}

#wrapper.toggled #sidebar-wrapper {
    margin-left: 0;
}

@media (min-width: 768px) {
    #sidebar-wrapper {
        margin-left: 0;
    }
}

/* Sidebar Header - Logo Area */
.sidebar-heading {
    flex-shrink: 0;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.sidebar-heading a {
    display: block;
    text-align: center;
    text-decoration: none;
    color: var(--primary-color);
}

.sidebar-heading img {
    height: 42px;
    width: auto;
    margin-bottom: 0.5rem;
}

.sidebar-heading span {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Dashboard Link */
.sidebar-nav .sidebar-dashboard {
    padding: 0 0 0.5rem 0;
    margin-bottom: 0.25rem;
}

.sidebar-nav .sidebar-dashboard .list-group-item {
    margin: 0 0.5rem;
    border-radius: 6px;
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary-color);
    font-weight: 500;
}

/* Menu Items */
.sidebar-nav .list-group-item {
    border: none;
    border-radius: 0;
    padding: 0.7rem 1.25rem;
    color: #4b5563;
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent;
}

.sidebar-nav .list-group-item:hover {
    background: rgba(26, 115, 232, 0.06);
    color: var(--primary-color);
}

.sidebar-nav .list-group-item.active {
    background: rgba(26, 115, 232, 0.1);
    color: var(--primary-color);
}

.sidebar-nav .list-group-item i {
    width: 1.25rem;
    text-align: center;
}

/* Section Headers */
.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 1rem;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
    border-left: 3px solid;
    cursor: pointer;
}

.sidebar-section-header i {
    font-size: 0.65rem;
    transition: transform 0.2s;
}

.sidebar-section-header[aria-expanded="false"] i {
    transform: rotate(-90deg);
}

/* Section Colors */
button[data-bs-target="#sidebar-hr"] {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.12) 0%, transparent 100%);
    color: #6366f1;
    border-left-color: #6366f1;
}

button[data-bs-target="#sidebar-organization"] {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.12) 0%, transparent 100%);
    color: #059669;
    border-left-color: #10b981;
}

button[data-bs-target="#sidebar-work"] {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.12) 0%, transparent 100%);
    color: #2563eb;
    border-left-color: #3b82f6;
}

button[data-bs-target="#sidebar-finance"] {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.12) 0%, transparent 100%);
    color: #d97706;
    border-left-color: #f59e0b;
}

button[data-bs-target="#sidebar-assets"] {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.12) 0%, transparent 100%);
    color: #7c3aed;
    border-left-color: #8b5cf6;
}

button[data-bs-target="#sidebar-documents"] {
    background: linear-gradient(90deg, rgba(236, 72, 153, 0.12) 0%, transparent 100%);
    color: #db2777;
    border-left-color: #ec4899;
}

button[data-bs-target="#sidebar-system"] {
    background: linear-gradient(90deg, rgba(220, 38, 38, 0.12) 0%, transparent 100%);
    color: #dc2626;
    border-left-color: #dc2626;
}

/* Collapse sections */
.sidebar-nav .collapse,
.sidebar-nav .collapsing {
    background: #fff;
}

/* ============================================
   Main Content Area
   ============================================ */
#page-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

#page-content-wrapper > nav {
    flex-shrink: 0;
}

#page-content-wrapper > .container-fluid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 2rem;
}

@media (min-width: 768px) {
    #wrapper.toggled #sidebar-wrapper {
        margin-left: -240px;
    }
}

@media (max-width: 768px) {
    #sidebar-wrapper {
        position: fixed;
        top: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
    }
}

/* Hide footer or move it inside content */
footer.footer {
    display: none;
}

/* ============================================
   Form Elements
   ============================================ */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.25);
}

.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.625rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
}

.form-control-lg {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-light);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* ============================================
   Page Header Styles
   ============================================ */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ============================================
   Search Bar
   ============================================ */
.search-wrapper {
    position: relative;
}

.search-wrapper .form-control {
    padding-left: 1rem;
    padding-right: 3rem;
    background-color: #fff;
    border: 2px solid var(--border-color);
}

.search-wrapper .form-control:focus {
    border-color: var(--primary-color);
    background-color: #fff;
}

.search-wrapper .btn {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================
   Employee Cards - Professional Design
   ============================================ */
#employeeGrid .employee-item {
    display: block;
    padding: 0;
    background: transparent;
    border-radius: 0;
    gap: 0;
}

.employee-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.25s ease;
    position: relative;
    overflow: visible;
    margin-bottom: 0.5rem;
}

.employee-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.employee-card .card-body {
    padding: 1.25rem;
    padding-right: 4rem;
}

.employee-card .card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
}

/* Avatar Styles */
.employee-avatar {
    flex-shrink: 0;
}

.employee-avatar img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.avatar-placeholder {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4285f4 100%);
    color: white;
    font-size: 1.25rem;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.avatar-placeholder-sm {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4285f4 100%);
    color: white;
    font-size: 1rem;
    border-radius: 50%;
}

/* Employee Name & Badge */
.employee-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.employee-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    letter-spacing: 0.3px;
}

/* Employee Info Rows */
.employee-info {
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.employee-info:last-child {
    margin-bottom: 0;
}

.employee-info i {
    width: 18px;
    margin-right: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.min-width-0 {
    min-width: 0;
}

/* Action Buttons */
.action-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: scale(1.05);
}

.action-btn.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn.btn-outline-secondary {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.action-btn.btn-outline-secondary:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ============================================
   Toggle Switch - Professional Style
   ============================================ */
.toggle-switch {
    position: absolute;
    right: 1rem;
    top: 1rem;
    z-index: 10;
}

.toggle-switch .form-check-input {
    width: 44px;
    height: 24px;
    cursor: pointer;
    background-color: #dadce0;
    border: none;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    margin: 0;
}

.toggle-switch .form-check-input:checked {
    background-color: var(--success-color);
}

.toggle-switch .form-check-input:not(:checked) {
    background-color: #dadce0;
}

.toggle-switch .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.25);
}

.toggle-switch .form-check-input:not(:checked):focus {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* Custom toggle circle */
.toggle-switch .form-check-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: left center;
    background-size: contain;
}

.toggle-switch .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-position: right center;
}

/* ============================================
   Department Cards - Professional Design
   ============================================ */
.department-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    position: relative;
    overflow: visible;
}

.department-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.department-card .card-body {
    padding: 1.25rem;
    padding-right: 4rem;
}

.department-card .card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
}

/* Department Avatar Styles */
.department-avatar {
    flex-shrink: 0;
}

.department-avatar .avatar-placeholder {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary-color), #5f6368);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
}

/* Department Name */
.department-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.3;
}

/* Department Badge */
.department-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    letter-spacing: 0.3px;
}

/* Department Info Rows */
.department-info {
    display: flex;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.department-info:last-child {
    margin-bottom: 0;
}

.department-info i {
    width: 18px;
    margin-right: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive Adjustments for Department Cards */
@media (max-width: 991px) {
    .department-card .card-footer .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
}

/* ============================================
   Department Details Modal - Sidebar Style
   ============================================ */
.department-details-modal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.dept-modal-header {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: white;
    border-bottom: none;
    padding: 1rem 1.5rem;
}

.dept-modal-header .modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.dept-modal-sidebar {
    width: 200px;
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    min-height: 350px;
}

.dept-modal-nav {
    padding: 1rem 0;
}

.dept-modal-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    border: none;
    border-left: 3px solid transparent;
    background: none;
    text-align: left;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.dept-modal-nav .nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(0, 0, 0, 0.03);
}

.dept-modal-nav .nav-link.active {
    color: #f97316;
    background-color: white;
    border-left-color: #f97316;
    font-weight: 500;
}

.dept-modal-nav .nav-link i {
    font-size: 1rem;
}

.dept-modal-content {
    padding: 1.5rem;
    min-height: 350px;
}

.dept-section-title {
    color: #f97316;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #f97316;
}

.dept-info-group {
    margin-bottom: 1.25rem;
}

.dept-info-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dept-info-value {
    font-size: 1rem;
    color: var(--text-primary);
}

.dept-employee-list {
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.dept-employee-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.dept-employee-item:last-child {
    border-bottom: none;
}

.dept-employee-item i {
    margin-right: 0.5rem;
    color: var(--text-muted);
}

.department-details-modal .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.department-details-modal .btn-outline-primary {
    border-color: #f97316;
    color: #f97316;
}

.department-details-modal .btn-outline-primary:hover {
    background-color: #f97316;
    border-color: #f97316;
    color: white;
}

/* Responsive for modal sidebar */
@media (max-width: 576px) {
    .dept-modal-sidebar {
        width: 100%;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .department-details-modal .modal-body .d-flex {
        flex-direction: column;
    }

    .dept-modal-nav {
        flex-direction: row !important;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .dept-modal-nav .nav-link {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        padding: 0.5rem 1rem;
    }

    .dept-modal-nav .nav-link.active {
        border-left-color: transparent;
        border-bottom-color: #f97316;
    }
}

/* ============================================
   View Members Modal - Employee Cards
   ============================================ */
.department-members-modal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.department-members-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.members-employee-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.member-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    background: #fff;
    transition: all 0.2s ease;
}

.member-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.member-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.member-card-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.member-card-code {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background-color: #e5e7eb;
    color: #6b7280;
}

.member-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.member-card-position {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.member-card-position strong {
    color: var(--text-primary);
}

.member-card-department {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.member-card-department strong {
    color: var(--text-primary);
}

.member-card-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.member-status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-status-icon.active {
    background-color: var(--success-color);
    color: white;
}

.member-status-icon.inactive {
    background-color: var(--danger-color);
    color: white;
}

.member-status-icon i {
    font-size: 0.7rem;
}

.member-card-date {
    font-size: 0.8rem;
    color: #f97316;
    font-weight: 500;
}

.member-card-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.member-contact-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.member-contact-item i {
    color: var(--text-muted);
}

.member-contact-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

.member-contact-item a:hover {
    color: var(--primary-color);
}

/* Search input styling in members modal */
.department-members-modal .input-group-text {
    border-color: var(--border-color);
}

.department-members-modal .form-control {
    border-color: var(--border-color);
}

.department-members-modal .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* ============================================
   Manager Info Button
   ============================================ */
.manager-info {
    display: flex;
    align-items: center;
}

.change-manager-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-color: #f97316;
    color: #f97316;
    transition: all 0.2s ease;
}

.change-manager-btn:hover {
    background-color: #f97316;
    border-color: #f97316;
    color: #fff;
}

.change-manager-btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(249, 115, 22, 0.25);
}

/* ============================================
   Org Chart Modal
   ============================================ */
.department-modal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.orgchart-display {
    border-right: 1px solid var(--border-color);
    min-height: 400px;
    background-color: #fafafa;
}

.orgchart-form {
    width: 280px;
    min-width: 280px;
    background-color: #fff;
}

.orgchart-tree {
    padding: 1rem 0;
}

/* Org Chart Node Styles */
.org-node {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.org-node-card {
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    min-width: 160px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.org-node-card:hover {
    border-color: #f97316;
    box-shadow: var(--shadow-sm);
}

.org-node-card.selected {
    border-color: #f97316;
    background-color: #fff7ed;
}

.org-node-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.org-node-manager {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.org-node-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Org Chart Tree Lines */
.org-children {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
    position: relative;
}

.org-children::before {
    content: '';
    position: absolute;
    top: -0.75rem;
    left: 50%;
    width: 0;
    height: 0.75rem;
    border-left: 2px solid var(--border-color);
}

.org-node:not(:only-child)::before {
    content: '';
    position: absolute;
    top: 0;
    width: 100%;
    height: 0;
    border-top: 2px solid var(--border-color);
}

.org-child-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.org-child-wrapper::before {
    content: '';
    position: absolute;
    top: -0.75rem;
    width: 2px;
    height: 0.75rem;
    background-color: var(--border-color);
}

/* Responsive for org chart modal */
@media (max-width: 768px) {
    #orgChartModal .modal-body .d-flex {
        flex-direction: column;
    }

    .orgchart-form {
        width: 100%;
        min-width: 100%;
        border-top: 1px solid var(--border-color);
    }

    .orgchart-display {
        border-right: none;
        min-height: 300px;
    }
}

/* ============================================
   View Toggle Buttons
   ============================================ */
.view-toggle .btn {
    padding: 0.5rem 0.75rem;
}

.view-toggle .btn-primary {
    background-color: var(--primary-color);
}

.view-toggle .btn-outline-secondary {
    background-color: #fff;
}

/* ============================================
   Stats/Count Badge
   ============================================ */
.results-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.results-count strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Table Styles
   ============================================ */
.table {
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table thead th {
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: rgba(26, 115, 232, 0.04);
}

/* Table Toggle Switch */
.table .form-check-input {
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.table .form-check-input:checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 1rem;
}

.empty-state h4 {
    color: var(--text-secondary);
    font-weight: 500;
}

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

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 991px) {
    .employee-card .card-footer .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }
}

@media (max-width: 576px) {
    .action-btn {
        width: 38px;
        height: 38px;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.shadow-professional {
    box-shadow: var(--shadow-sm);
}

.shadow-professional-hover:hover {
    box-shadow: var(--shadow-md);
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card grid spacing fix */
.row.g-4 {
    margin-bottom: 1rem;
}

/* Ensure last row items are visible and proper spacing */
#employeeGrid {
    padding-bottom: 1rem;
    row-gap: 1.5rem !important;
}

/* ============================================
   Employee Details Modal
   ============================================ */
.employee-modal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.employee-modal .modal-header {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 50%, #fdba74 100%);
    border: none;
    padding: 1.5rem 1.5rem 1rem;
    position: relative;
}

.employee-modal .modal-header .btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: rgba(255,255,255,0.2);
    border-radius: 50%;
    padding: 0.5rem;
    opacity: 1;
    filter: brightness(0) invert(1);
}

.employee-modal .modal-header .btn-close:hover {
    background-color: rgba(255,255,255,0.3);
}

.employee-modal .modal-body {
    padding: 0;
}

.employee-modal .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* Modal Header Content */
.modal-employee-header {
    display: flex;
    align-items: flex-start;
    color: white;
}

.modal-employee-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4285f4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
    position: relative;
    flex-shrink: 0;
}

.modal-employee-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.modal-employee-avatar .status-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--success-color);
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-employee-avatar .status-badge i {
    font-size: 0.75rem;
    color: white;
}

.modal-employee-info {
    margin-left: 1rem;
    flex: 1;
}

.modal-employee-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: white;
}

.modal-employee-title {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 0.75rem;
    color: white;
}

.modal-employee-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.modal-badge-code {
    background: rgba(255,255,255,0.2);
    color: white;
}

.modal-badge-status {
    background: white;
}

.modal-badge-status.active {
    color: var(--success-color);
}

.modal-badge-status.inactive {
    color: var(--danger-color);
}

/* Modal Tabs */
.modal-tabs {
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    background: #fff;
}

.modal-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 1rem 1rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.modal-tabs .nav-link:hover {
    color: var(--primary-color);
    border-color: transparent;
}

.modal-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: transparent;
}

.modal-tabs .nav-link i {
    margin-right: 0.5rem;
}

/* Modal Tab Content */
.modal-tab-content {
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

/* Info Section */
.info-section {
    margin-bottom: 1.5rem;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.info-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Status Badge in Info */
.info-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.info-status-badge.active {
    background: rgba(52, 168, 83, 0.1);
    color: var(--success-color);
}

.info-status-badge.inactive {
    background: rgba(234, 67, 53, 0.1);
    color: var(--danger-color);
}

/* History Timeline */
.history-timeline {
    position: relative;
    padding-left: 1.5rem;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.history-item {
    position: relative;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.history-item::before {
    content: '';
    position: absolute;
    left: -1.25rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.history-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.history-department {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive modal */
@media (max-width: 576px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .modal-employee-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-employee-info {
        margin-left: 0;
        margin-top: 1rem;
    }

    .modal-employee-badges {
        justify-content: center;
    }
}

/* ============================================
   Digital Business Card
   ============================================ */
.business-card {
    background: #fff;
    border: 2px solid #f97316;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    max-width: 500px;
    margin: 0 auto;
}

.business-card-header {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
}

.business-card-logo {
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f97316;
    font-size: 1.25rem;
}

.business-card-body {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.business-card-info {
    flex: 1;
}

.business-card-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 0.25rem;
}

.business-card-title {
    font-size: 1rem;
    color: #f97316;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.business-card-dept {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.business-card-contact {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.business-card-contact .contact-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.business-card-contact .contact-item i {
    color: #1e3a5f;
    width: 16px;
}

.business-card-qr {
    flex-shrink: 0;
}

.qr-placeholder {
    width: 160px;
    height: 160px;
    padding: 5px;
    box-sizing: border-box;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e3a5f;
    font-size: 3rem;
    overflow: hidden;
}

.qr-placeholder canvas,
.qr-placeholder img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.business-card-footer {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.business-card-footer span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.business-card-footer i {
    color: #f97316;
}

/* VCard Actions */
.vcard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.vcard-actions .btn {
    padding: 0.5rem 1.5rem;
}

/* Direct Contact Section */
.direct-contact {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.direct-contact-title {
    text-align: center;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 1rem;
}

.direct-contact-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.direct-contact-buttons .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.direct-contact-buttons .btn i {
    margin-right: 0.25rem;
}

/* Responsive business card */
@media (max-width: 576px) {
    .business-card-body {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .business-card-contact {
        align-items: center;
    }

    .business-card-footer {
        justify-content: center;
    }

    .vcard-actions {
        flex-direction: column;
    }

    .vcard-actions .btn {
        width: 100%;
    }

    .direct-contact-buttons {
        flex-direction: column;
    }

    .direct-contact-buttons .btn {
        width: 100%;
    }
}

/* ============================================
   Social Links
   ============================================ */
.social-links-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.social-link-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.social-link-item:hover {
    background: #fff;
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.social-link-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.social-link-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.social-link-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.social-link-value {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Employee Form Modal
   ============================================ */
.employee-form-modal .modal-content {
    border: none;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.employee-form-modal .modal-header {
    background: linear-gradient(135deg, #f97316 0%, #fb923c 100%);
    border: none;
    padding: 1rem 1.5rem;
}

.employee-form-modal .modal-header .modal-title {
    color: white;
    font-weight: 600;
}

.employee-form-modal .modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 1;
}

.employee-form-modal .modal-body {
    padding: 0;
}

.employee-form-modal .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* Form Tabs */
.form-tabs {
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    background: #f8f9fa;
}

.form-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 1rem 1.5rem;
    font-weight: 500;
    border-radius: 0;
    margin-bottom: 0;
}

.form-tabs .nav-link:hover {
    color: #f97316;
    border-color: transparent;
    background: transparent;
}

.form-tabs .nav-link.active {
    color: #f97316;
    border-bottom-color: #f97316;
    background: white;
}

/* Form Tab Content */
.form-tab-content {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.form-tab-content .form-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}

.form-tab-content .form-control,
.form-tab-content .form-select {
    border-color: var(--border-color);
    padding: 0.625rem 0.875rem;
}

.form-tab-content .form-control:focus,
.form-tab-content .form-select:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 0.2rem rgba(249, 115, 22, 0.15);
}

.form-tab-content .form-control::placeholder {
    color: var(--text-muted);
}

/* Form Validation */
.form-tab-content .form-control.is-invalid {
    border-color: var(--danger-color);
}

/* Alert styling */
.employee-form-modal .alert-danger {
    background: rgba(234, 67, 53, 0.1);
    border: 1px solid rgba(234, 67, 53, 0.3);
    color: var(--danger-color);
    margin: 1rem 1.5rem 0;
    border-radius: var(--radius-md);
}

/* ============================================
   Organization Chart Page
   ============================================ */
.orgchart-page {
    padding: 1.5rem 0;
    position: relative;
}

.orgchart-header {
    margin-bottom: 1.5rem;
}

/* Statistics Cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.bg-primary-subtle {
    background: rgba(26, 115, 232, 0.1);
    color: var(--primary-color);
}

.stat-icon.bg-success-subtle {
    background: rgba(52, 168, 83, 0.1);
    color: var(--success-color);
}

.stat-icon.bg-info-subtle {
    background: rgba(66, 133, 244, 0.1);
    color: #4285f4;
}

.stat-icon.bg-warning-subtle {
    background: rgba(251, 188, 5, 0.1);
    color: var(--warning-color);
}

.stat-icon.bg-secondary-subtle {
    background: rgba(95, 99, 104, 0.1);
    color: var(--text-secondary);
}

.stat-icon.bg-danger-subtle {
    background: rgba(234, 67, 53, 0.1);
    color: var(--danger-color);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main Chart Area */
.orgchart-main {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.orgchart-toolbar {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
}

/* Search Box */
.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box .form-control {
    padding-left: 2.75rem;
    border-radius: var(--radius-pill);
    background: #fff;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-results.visible {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-light);
}

.search-result-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
}

.search-result-icon.active {
    background: rgba(52, 168, 83, 0.1);
    color: var(--success-color);
}

.search-result-icon.inactive {
    background: rgba(95, 99, 104, 0.1);
    color: var(--text-muted);
}

.search-result-name {
    font-weight: 500;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Legend */
.orgchart-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.active {
    background: var(--success-color);
}

.legend-dot.inactive {
    background: var(--text-muted);
}

/* Chart Wrapper */
.orgchart-wrapper {
    min-height: 500px;
    max-height: calc(100vh - 400px);
    overflow: auto;
    padding: 2rem;
    position: relative;
    background:
        radial-gradient(circle, #e5e5e5 1px, transparent 1px);
    background-size: 20px 20px;
}

.orgchart-container {
    min-width: 100%;
    min-height: 100%;
    display: flex;
    justify-content: center;
}

/* Loading State */
.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state i,
.error-state i {
    font-size: 4rem;
    color: var(--text-muted);
}

/* Org Chart Tree */
.orgchart-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s ease;
}

.orgchart-tree.horizontal {
    flex-direction: row;
    align-items: flex-start;
}

/* Level container for side-by-side departments */
.org-level-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
}

.orgchart-tree.horizontal .org-level-container {
    flex-direction: column;
    align-items: flex-start;
}

.org-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.orgchart-tree.horizontal .org-node-wrapper {
    flex-direction: row;
    align-items: flex-start;
}

.org-node-children {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
    position: relative;
    padding-top: 1.5rem;
}

.orgchart-tree.horizontal .org-node-children {
    flex-direction: row;
    margin-top: 0;
    margin-left: 2rem;
    padding-top: 0;
    padding-left: 1.5rem;
}

/* Connection Lines */
.org-node-children::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 1.5rem;
    background: var(--border-color);
}

.orgchart-tree.horizontal .org-node-children::before {
    top: 50%;
    left: 0;
    width: 1.5rem;
    height: 2px;
}

/* Lines from level container to each node */
.org-level-container > .org-node-wrapper::before {
    content: '';
    position: absolute;
    top: -1.5rem;
    left: 50%;
    width: 2px;
    height: 1.5rem;
    background: var(--border-color);
}

.orgchart-tree.horizontal .org-level-container > .org-node-wrapper::before {
    top: 50%;
    left: -1.5rem;
    width: 1.5rem;
    height: 2px;
}

/* Horizontal line connecting siblings at same level */
.org-node-children > .org-level-container::before {
    content: '';
    position: absolute;
    top: -1.5rem;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--border-color);
}

/* Don't show horizontal line for single child */
.org-node-children > .org-level-container:has(> .org-node-wrapper:only-child)::before {
    display: none;
}

.orgchart-tree.horizontal .org-node-children > .org-level-container::before {
    top: 25%;
    bottom: 25%;
    left: -1.5rem;
    right: auto;
    width: 2px;
    height: auto;
}

/* Don't show connection lines on root level */
.orgchart-tree > .org-level-container > .org-node-wrapper::before {
    display: none;
}

/* Org Node Card */
.org-node-card {
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0;
    min-width: 200px;
    max-width: 240px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.org-node-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.org-node-card.active {
    border-color: var(--success-color);
}

.org-node-card.inactive {
    border-color: var(--text-muted);
    opacity: 0.8;
}

.org-node-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

.org-node-card.dragging {
    opacity: 0.5;
    transform: rotate(3deg);
}

.org-node-card.drag-over {
    border-color: #f97316;
    border-style: dashed;
    background: #fff7ed;
}

/* Node Header */
.node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.node-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.node-status.active {
    background: var(--success-color);
}

.node-status.inactive {
    background: var(--text-muted);
}

.node-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.org-node-card:hover .node-actions {
    opacity: 1;
}

.node-action-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.node-action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* Node Body */
.node-body {
    padding: 1rem;
    text-align: center;
}

.node-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #4285f4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    color: #fff;
    font-size: 1.25rem;
}

.node-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-parent-info {
    font-size: 0.75rem;
    color: #f97316;
    background: rgba(249, 115, 22, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.node-parent-info i {
    font-size: 0.7rem;
}

.node-manager {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.node-stats {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.node-stat {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Expand Button */
.node-expand-btn {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.node-expand-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.node-expand-btn i {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.node-expand-btn.expanded i {
    transform: rotate(180deg);
}

/* Root Drop Zone */
.drop-zone-root {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1rem 2rem;
    background: #fff;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.drop-zone-root.visible {
    opacity: 1;
    visibility: visible;
}

.drop-zone-root.drag-over {
    border-color: #f97316;
    background: #fff7ed;
    color: #f97316;
}

/* Details Sidebar */
.details-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.details-sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Detail Header */
.detail-header {
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.detail-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), #4285f4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: #fff;
    font-size: 1.75rem;
}

.detail-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Detail Sections */
.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}

.detail-info {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* Manager Card */
.manager-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.manager-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
}

.manager-info {
    display: flex;
    flex-direction: column;
}

.manager-info a {
    text-decoration: none;
}

.manager-info a:hover {
    text-decoration: underline;
}

/* Employee List */
.employee-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.employee-list .employee-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.employee-list .employee-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.875rem;
}

.employee-list .employee-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.employee-list .employee-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.employee-list .employee-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-sm {
    font-size: 0.625rem;
    padding: 0.2rem 0.4rem;
}

/* Child Department List */
.child-dept-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.child-dept-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
}

.child-dept-item:hover {
    background: rgba(26, 115, 232, 0.1);
}

.child-dept-item span:first-of-type {
    flex: 1;
}

/* Detail Actions */
.detail-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Minimap */
.minimap {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 150px;
    height: 100px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.minimap-content {
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle, var(--border-color) 1px, transparent 1px);
    background-size: 10px 10px;
}

.minimap-viewport {
    position: absolute;
    background: rgba(26, 115, 232, 0.2);
    border: 2px solid var(--primary-color);
    border-radius: 2px;
}

/* Notification Toast */
.notification-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.chart-wrap {
    position: relative;
    height: 240px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Print Styles */
@media print {
    .orgchart-header,
    .orgchart-toolbar,
    .details-sidebar,
    .minimap,
    .drop-zone-root,
    .node-actions,
    .node-expand-btn {
        display: none !important;
    }

    .orgchart-wrapper {
        max-height: none;
        overflow: visible;
        background: #fff;
    }

    .org-node-card {
        break-inside: avoid;
    }
}

/* Responsive */
@media (max-width: 992px) {
    .details-sidebar {
        width: 100%;
        right: -100%;
    }

    .orgchart-legend {
        display: none;
    }

    .search-box {
        max-width: none;
    }
}

@media (max-width: 768px) {
    .orgchart-toolbar .d-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .zoom-controls {
        justify-content: center;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1rem;
    }
}

/* Move Modal Styling */
.move-option {
    cursor: pointer;
    transition: all 0.2s ease;
}

.move-option:hover {
    background-color: var(--bg-light);
    border-color: var(--primary-color) !important;
}

.move-option.selected {
    background-color: rgba(26, 115, 232, 0.05);
    border-color: var(--primary-color) !important;
}

.move-option-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.move-option .form-check-input {
    margin-top: 0.75rem;
}

/* Drag visual feedback improvements */
.org-node-card.dragging {
    opacity: 0.6;
    transform: scale(0.95) rotate(2deg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.org-node-card.drag-over {
    border: 3px dashed #f97316 !important;
    background: #fff7ed;
    transform: scale(1.02);
}

.drop-zone-root {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.5rem 3rem;
    background: #fff;
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.drop-zone-root.visible {
    opacity: 1;
    visibility: visible;
    animation: bounceIn 0.3s ease;
}

.drop-zone-root.drag-over {
    border-color: #f97316;
    background: #fff7ed;
    color: #f97316;
    transform: translateX(-50%) scale(1.05);
}

.drop-zone-root i {
    font-size: 1.5rem;
}

@keyframes bounceIn {
    0% {
        transform: translateX(-50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* ============================================
   Employee Org Chart Specific Styles
   ============================================ */
.org-node-card.employee-card .node-icon.employee-avatar-icon {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
}

.org-node-card.employee-card .node-icon.employee-avatar-icon i {
    font-size: 1.5rem;
}

.node-position {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.node-position i {
    font-size: 0.7rem;
    color: #8b5cf6;
}

.node-department {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
}

.node-department i {
    font-size: 0.65rem;
}

.node-email {
    cursor: pointer;
}

.node-email:hover {
    color: var(--primary-color);
}

/* Employee Detail Sidebar Icon */
.detail-icon.employee-detail-icon {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

/* Clickable reports in sidebar */
.clickable-report {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-report:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

/* Org Chart Tabs Styling */
.orgchart-tabs {
    border-bottom: 2px solid var(--border-color);
}

.orgchart-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.orgchart-tabs .nav-link:hover {
    color: var(--primary-color);
    border-color: transparent;
    background-color: rgba(26, 115, 232, 0.05);
}

.orgchart-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

.orgchart-tabs .nav-link i {
    font-size: 1.1rem;
}

/* ============================================
   Project Management (Projects, Board, Gantt)
   ============================================ */
.projects-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.page-header-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.project-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.project-member-badge {
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary-color);
    border: 1px solid rgba(26, 115, 232, 0.2);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.projects-container .empty-state i {
    opacity: 0.6;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.project-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.project-card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.project-card-body {
    padding: 1rem;
    flex: 1;
}

.project-card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-tile {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    height: 100%;
}

.project-status-badge {
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-planning { background: rgba(26,115,232,0.12); color: #1a73e8; }
.status-active { background: rgba(52,168,83,0.12); color: #34a853; }
.status-onhold { background: rgba(251,188,4,0.12); color: #c38b00; }
.status-completed { background: rgba(52,168,83,0.12); color: #1f8c44; }
.status-cancelled { background: rgba(234,67,53,0.12); color: #b23b2d; }

.priority-badge, .priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.priority-low { background: rgba(52,168,83,0.12); color: #2f8f46; }
.priority-medium { background: rgba(26,115,232,0.12); color: #1a73e8; }
.priority-high { background: rgba(234,67,53,0.12); color: #c33b2d; }
.priority-critical { background: rgba(234,67,53,0.18); color: #9f271c; border: 1px solid rgba(234,67,53,0.3); }

.project-card .project-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.project-card .project-title a:hover {
    color: var(--primary-color);
}

.project-stats .project-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-secondary);
}

.project-card .team-avatars {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-secondary);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-circle.more {
    background: rgba(26, 115, 232, 0.12);
    color: #1a73e8;
}

.avatar-circle.xs {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.projects-container .list-view .project-card {
    flex-direction: row;
}

/* Kanban */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.kanban-column {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-column-body {
    padding: 0.85rem;
    flex: 1;
    background: var(--bg-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.kanban-column-body.drag-over {
    border: 2px dashed var(--primary-color);
    background: rgba(26, 115, 232, 0.05);
}

.kanban-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.kanban-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.75rem;
    cursor: grab;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.kanban-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.kanban-card.dragging {
    opacity: 0.75;
    box-shadow: var(--shadow-lg);
}

.kanban-title {
    font-weight: 700;
    color: var(--text-primary);
}

.kanban-meta .due-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.task-type {
    background: rgba(0,0,0,0.05);
    color: var(--text-secondary);
}

.notification-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1050;
    box-shadow: var(--shadow-md);
}

/* Gantt */
.gantt-card {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.gantt-wrapper {
    position: relative;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.gantt-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.gantt-header-spacer {
    flex: 0 0 260px;
    border-right: 1px solid var(--border-color);
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
}

.gantt-header-cell {
    text-align: center;
    padding: 0.35rem 0.25rem;
    border-right: 1px solid var(--border-color);
    flex: 0 0 auto;
    min-width: 10px;
}

.gantt-header-day {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.gantt-header-sub {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.gantt-body {
    position: relative;
    min-height: 320px;
    background: #fff;
}

.gantt-row {
    display: grid;
    grid-template-columns: 260px 1fr;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    min-height: 56px;
}

.gantt-row:nth-child(odd) {
    background: #fafafa;
}

.gantt-row-label {
    padding: 0.75rem;
    border-right: 1px solid var(--border-color);
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
}

.gantt-bar {
    position: absolute;
    top: 6px;
    height: 32px;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    color: #fff;
    padding: 4px 10px 4px 8px;
}

.gantt-row-track {
    position: relative;
    height: 44px;
}

.gantt-bar-title {
    position: relative;
    z-index: 2;
    font-weight: 700;
    font-size: 0.9rem;
}

.gantt-bar-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: rgba(255,255,255,0.6);
    border-radius: 0 0 6px 6px;
}

.gantt-bar {
    user-select: none;
    touch-action: none;
    cursor: grab;
}

.gantt-bar.dragging {
    cursor: grabbing;
    opacity: 0.85;
}

.gantt-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    z-index: 3;
}

.gantt-handle-right {
    right: 0;
    cursor: ew-resize;
    background: rgba(255,255,255,0.15);
    border-radius: 0 6px 6px 0;
}

.gantt-milestone {
    position: absolute;
    top: 8px;
    width: 14px;
    height: 14px;
    transform: rotate(45deg);
    border: 2px solid #fff;
    box-shadow: var(--shadow-sm);
}

.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(234, 67, 53, 0.7);
    pointer-events: none;
}

.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 6px;
}

/* Mail handler */
.mail-status-badge {
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
}

.sla-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    background: #fff;
}

.sla-ok {
    color: #1f8c44;
    border-color: rgba(52, 168, 83, 0.35);
    background: rgba(52, 168, 83, 0.08);
}

.sla-overdue {
    color: #b23b2d;
    border-color: rgba(234, 67, 53, 0.35);
    background: rgba(234, 67, 53, 0.08);
}

/* ============================================
   Library
   ============================================ */
.library-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    min-height: 70vh;
}

.library-left .card,
.library-right .card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.library-tree {
    max-height: calc(100vh - 340px);
    overflow: auto;
    padding-right: 0.25rem;
}

.library-tree-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.55rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    margin-bottom: 0.25rem;
}

.library-tree-item:hover {
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary-color);
}

.library-tree-item.active {
    background: rgba(26, 115, 232, 0.12);
    color: var(--primary-color);
    border: 1px solid rgba(26, 115, 232, 0.15);
}

.lib-access-badge {
    font-weight: 700;
    color: var(--text-secondary);
    border: 1px solid rgba(60,64,67,0.15);
}

.library-toolbar {
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.library-section-title {
    margin: 0.75rem 0;
    font-weight: 700;
    color: var(--text-primary);
}

.library-page .table thead th {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.library-page .doc-meta {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

@media (max-width: 992px) {
    .library-shell {
        grid-template-columns: 1fr;
    }
    .library-tree {
        max-height: 260px;
    }
}

/* ============================================
   Meetings
   ============================================ */
.meeting-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.meeting-page #meetingCalendar {
    min-height: 520px;
}

.meeting-subtitle {
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.25rem 0 0.5rem 0;
}

.meeting-status {
    font-weight: 700;
    border: 1px solid rgba(60,64,67,0.15);
    color: var(--text-secondary);
}

.meeting-attendance {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 0.75rem;
    max-height: 260px;
    overflow: auto;
}

.meeting-report-hint {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-light);
    padding: 0.75rem;
    color: var(--text-primary);
}

/* Meeting report preview */
.report-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.report-preview-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 0.9rem 1rem;
}

.report-preview-title {
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.report-preview-body {
    color: var(--text-secondary);
}

.report-preview-kpi {
    color: var(--text-primary);
}

.report-preview-tabs .nav-link {
    border-radius: 999px;
    font-weight: 700;
}

.report-preview-content {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.report-preview-markdown {
    color: var(--text-primary);
}

.report-preview-paragraph {
    margin-bottom: 0.6rem;
}

.report-preview-list {
    margin-bottom: 0.6rem;
}

.report-preview-spacer {
    height: 0.5rem;
}

.report-preview-h1 { font-size: 1.1rem; font-weight: 800; margin: 0.2rem 0 0.6rem; }
.report-preview-h2 { font-size: 1.0rem; font-weight: 800; margin: 0.2rem 0 0.6rem; }
.report-preview-h3 { font-size: 0.95rem; font-weight: 800; margin: 0.2rem 0 0.6rem; }

@media (max-width: 992px) {
    .report-preview-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Chat
   ============================================ */
.chat-shell {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1rem;
    min-height: 72vh;
}

.chat-sidebar .card,
.chat-main .card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.chat-section-title {
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.chat-channel-list {
    overflow: auto;
    max-height: 42vh;
    padding-right: 0.25rem;
}

.chat-channel-item {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    color: var(--text-secondary);
}

.chat-channel-item:hover {
    background: rgba(26, 115, 232, 0.08);
    color: var(--primary-color);
}

.chat-channel-item.active {
    background: rgba(26, 115, 232, 0.12);
    border-color: rgba(26, 115, 232, 0.16);
    color: var(--primary-color);
}

.chat-channel-name {
    font-weight: 700;
    color: inherit;
}

.chat-header {
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.chat-messages {
    overflow: auto;
    padding: 1rem;
    background: #fff;
}

.chat-msg {
    display: flex;
    margin-bottom: 0.75rem;
}

.chat-msg.mine {
    justify-content: flex-end;
}

.chat-msg-bubble {
    max-width: min(740px, 92%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    padding: 0.6rem 0.75rem;
    box-shadow: var(--shadow-sm);
}

.chat-msg.mine .chat-msg-bubble {
    border-color: rgba(26, 115, 232, 0.22);
    background: rgba(26, 115, 232, 0.06);
}

.chat-msg-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.chat-msg-sender {
    font-weight: 800;
    color: var(--text-secondary);
}

.chat-msg-body {
    white-space: pre-wrap;
    color: var(--text-primary);
}

.chat-msg-att {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-att-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-attachment-thumb img {
    width: auto;
    height: auto;
    max-width: 220px;
    max-height: 140px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(60,64,67,0.12);
    box-shadow: var(--shadow-sm);
    display: block;
}

.chat-messages.chat-drag-over {
    outline: 2px dashed rgba(26, 115, 232, 0.45);
    outline-offset: -8px;
    background: rgba(26, 115, 232, 0.04);
}

.chat-attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(60,64,67,0.18);
    color: var(--text-secondary);
    text-decoration: none;
    width: fit-content;
}

.chat-attachment:hover {
    border-color: rgba(26, 115, 232, 0.25);
    color: var(--primary-color);
    background: rgba(26, 115, 232, 0.06);
}

.chat-msg-reactions {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.chat-react-chip {
    border: 1px solid rgba(60,64,67,0.18);
    background: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-react-chip:hover {
    border-color: rgba(26, 115, 232, 0.25);
    background: rgba(26, 115, 232, 0.06);
    color: var(--primary-color);
}

.chat-react-chip.active {
    border-color: rgba(26, 115, 232, 0.35);
    background: rgba(26, 115, 232, 0.10);
    color: var(--primary-color);
}

.chat-react-add {
    border: 1px dashed rgba(60,64,67,0.22);
    background: transparent;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-react-add:hover {
    border-color: rgba(26, 115, 232, 0.25);
    color: var(--primary-color);
    background: rgba(26, 115, 232, 0.06);
}

.chat-msg-status {
    margin-top: 0.25rem;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-emoji-picker {
    width: 250px;
    max-width: calc(100vw - 16px);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    z-index: 2000;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.25rem;
}

.chat-emoji-item {
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 0.3rem 0;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-emoji-item:hover {
    background: rgba(26, 115, 232, 0.08);
    border-color: rgba(26, 115, 232, 0.16);
}

@media (max-width: 992px) {
    .chat-shell {
        grid-template-columns: 1fr;
    }
    .chat-channel-list {
        max-height: 260px;
    }
}

/* Fix select option readability in some browsers/OS themes */
.meeting-page .form-select,
.meeting-page .form-control,
#meetingModal .form-select,
#meetingModal .form-control,
#reportModal .form-select,
#reportModal .form-control {
    color: #202124 !important;
    background-color: #fff !important;
    -webkit-text-fill-color: #202124;
    color-scheme: light;
}

.meeting-page .form-select option,
#meetingModal .form-select option,
#reportModal .form-select option {
    color: #202124 !important;
    background-color: #fff !important;
}

#meetingModal .table,
#meetingModal .table th,
#meetingModal .table td,
#reportModal .table,
#reportModal .table th,
#reportModal .table td {
    color: #202124;
}
