/* style.css - ระบบดีไซน์สไตล์ Light Mode Glassmorphism & Neon Glow */

:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.5);
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    
    --neon-red: rgba(239, 68, 68, 0.85);
    --neon-red-glow: 0 0 12px rgba(239, 68, 68, 0.4);
    
    --neon-orange: rgba(249, 115, 22, 0.85);
    --neon-orange-glow: 0 0 12px rgba(249, 115, 22, 0.4);
    
    --neon-cyan: rgba(6, 182, 212, 0.85);
    --neon-cyan-glow: 0 0 12px rgba(6, 182, 212, 0.4);

    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Sarabun', sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background-color: #f1f5f9;
}

/* Background gradient blobs to create depth for glassmorphism */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: 
        radial-gradient(circle at 10% 20%, rgba(224, 231, 255, 0.6) 0%, transparent 40%),
        radial-gradient(circle at 90% 10%, rgba(219, 234, 254, 0.7) 0%, transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(254, 215, 226, 0.5) 0%, transparent 50%),
        linear-gradient(to bottom right, #f8fafc, #e2e8f0);
}

.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* Glassmorphism Panel Base */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: 
        0 4px 30px rgba(0, 0, 0, 0.03),
        inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

/* Header Styles */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    flex-wrap: wrap;
    gap: 20px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Role Switcher */
.role-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switcher-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.role-select-control {
    min-width: 220px;
    font-weight: 600;
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.2);
    background: white url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>") no-repeat right 16px center;
    background-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: var(--transition);
}

.role-select-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-title-row h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.15);
}

.btn-danger-outline {
    background: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: #ef4444;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--border-radius-sm);
}

/* SECTION 1: MANAGER VIEWS - Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
}

.count-total::before { background-color: #6366f1; }
.count-done::before { background-color: #10b981; }
.count-warning::before { background-color: #f59e0b; }
.count-overdue::before { background-color: #ef4444; }

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-icon {
    font-size: 32px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Warning Pulse and Overdue Blinking for icons */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes blink {
    0% { opacity: 1; background-color: rgba(254, 226, 226, 0.8); }
    50% { opacity: 0.6; background-color: rgba(239, 68, 68, 0.25); }
    100% { opacity: 1; background-color: rgba(254, 226, 226, 0.8); }
}

.warning-pulse {
    animation: pulse 2s infinite ease-in-out;
}

.overdue-blink {
    animation: pulse 1s infinite ease-in-out;
    background: rgba(254, 226, 226, 0.8) !important;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    margin-bottom: 24px;
}

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

.chart-card {
    padding: 24px;
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.chart-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* All Tasks Table Card */
.tasks-table-card {
    padding: 24px;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.table-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.form-control {
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.7);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input.form-control {
    min-width: 200px;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: rgba(255, 255, 255, 0.4);
}

.tasks-table th, .tasks-table td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 14px;
}

.tasks-table th {
    background: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    color: var(--text-secondary);
}

.tasks-table tbody tr {
    transition: var(--transition);
}

.tasks-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* Kanban Board Container */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 680px) {
    .kanban-board {
        grid-template-columns: 1fr;
    }
}

.kanban-column {
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 550px;
    transition: var(--transition);
}

.kanban-column.drag-over {
    background: rgba(255, 255, 255, 0.7);
    border: 2px dashed var(--primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.column-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.04);
}

.column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.todo-dot { background-color: #64748b; }
.progress-dot { background-color: #3b82f6; }
.review-dot { background-color: #eab308; }
.done-dot { background-color: #10b981; }

.column-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    flex-grow: 1;
}

.column-count {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.column-cards-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 450px;
}

/* Kanban Cards & Glowing Borders */
.task-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
    padding: 16px;
    cursor: grab;
    user-select: none;
    position: relative;
    transition: 
        transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
        box-shadow 0.25s ease,
        border-color 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-card:active {
    cursor: grabbing;
}

.task-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    box-shadow: none !important;
}

.task-card:hover {
    transform: translateY(-4px) scale(1.01);
}

/* Neon glow based on priority */
.task-card.priority-high {
    border: 2px solid var(--neon-red);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02), var(--neon-red-glow);
}
.task-card.priority-high:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.04), 0 0 16px rgba(239, 68, 68, 0.6);
}

.task-card.priority-medium {
    border: 2px solid var(--neon-orange);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02), var(--neon-orange-glow);
}
.task-card.priority-medium:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.04), 0 0 16px rgba(249, 115, 22, 0.6);
}

.task-card.priority-low {
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02), var(--neon-cyan-glow);
}
.task-card.priority-low:hover {
    box-shadow: 0 8px 16px rgba(0,0,0,0.04), 0 0 16px rgba(6, 182, 212, 0.6);
}

/* Card Header */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.task-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.priority-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.priority-badge.badge-high {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.priority-badge.badge-medium {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}
.priority-badge.badge-low {
    background: rgba(6, 182, 212, 0.15);
    color: #0891b2;
}

.task-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Card Alerts and Date Indicators */
.card-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.card-deadline-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.deadline-icon {
    font-size: 12px;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-card-action {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-card-action:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.05);
}

.btn-card-action.btn-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Warning and Overdue Alert styles */
.badge-alert {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    width: fit-content;
}

.badge-alert.overdue {
    background-color: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-alert.warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Blinking animations for cards */
@keyframes borderPulseWarning {
    0% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 10px rgba(245, 158, 11, 0.3); }
    50% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 18px rgba(245, 158, 11, 0.75); }
    100% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 10px rgba(245, 158, 11, 0.3); }
}

@keyframes borderBlinkOverdue {
    0% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 10px rgba(239, 68, 68, 0.35); border-color: rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 20px rgba(239, 68, 68, 0.85); border-color: rgba(239, 68, 68, 1); }
    100% { box-shadow: 0 4px 10px rgba(0,0,0,0.02), 0 0 10px rgba(239, 68, 68, 0.35); border-color: rgba(239, 68, 68, 0.5); }
}

/* Applying animations */
.task-card.alert-state-overdue {
    animation: borderBlinkOverdue 1.5s infinite ease-in-out;
}

.task-card.alert-state-warning {
    animation: borderPulseWarning 2s infinite ease-in-out;
}

/* Badges for status in Manager Table */
.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

.status-badge.todo { background: #e2e8f0; color: #475569; }
.status-badge.in-progress { background: #dbeafe; color: #1e40af; }
.status-badge.review { background: #fef3c7; color: #92400e; }
.status-badge.done { background: #d1fae5; color: #065f46; }

/* Modal Overlay & Animations */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 580px;
    padding: 32px;
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    line-height: 1;
}

.btn-close-modal:hover {
    color: #ef4444;
}

/* Forms styling in modal */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 16px;
}

.col-6 {
    width: 50%;
}

.required {
    color: #ef4444;
}

textarea.form-control {
    resize: none;
    font-family: inherit;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Footer styling */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 16px;
}

.footer-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Member Management Styling */
.action-buttons-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.5);
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.member-item:hover {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(0, 0, 0, 0.1);
}

.member-name-input {
    flex-grow: 1;
    border: 1px solid transparent;
    background: transparent;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.member-name-input:not(:disabled) {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.member-item-actions {
    display: flex;
    gap: 6px;
}

.btn-member-edit, .btn-member-delete {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-member-edit {
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
}

.btn-member-edit:hover {
    background: var(--primary);
    color: white;
}

.btn-member-delete {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}

.btn-member-delete:hover {
    background: #ef4444;
    color: white;
}

/* App Navigation Tabs */
.app-tabs-nav {
    display: flex;
    padding: 6px 12px;
    gap: 8px;
    margin-bottom: 8px;
    border-radius: var(--border-radius-md);
    flex-wrap: wrap;
}

.tab-button {
    border: none;
    background: transparent;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.25);
}

.tab-button.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

/* Custom Donut Chart & Legend Layout */
.chart-flex-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    margin-top: 10px;
}

.chart-canvas-wrapper {
    position: relative;
    width: 170px;
    height: 170px;
    flex-shrink: 0;
}

.donut-custom-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    padding: 2px 0;
}

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

.legend-name {
    flex-grow: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.legend-percentage {
    font-weight: 700;
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 14px;
    min-width: 45px;
    text-align: right;
}

/* Organization Chart Tree Layout */
.org-chart-wrapper {
    padding: 40px 20px;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    min-height: 480px;
}

/* Custom Scrollbar for Org Chart Wrapper */
.org-chart-wrapper::-webkit-scrollbar {
    height: 8px;
}
.org-chart-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}
.org-chart-wrapper::-webkit-scrollbar-thumb {
    background: rgba(79, 70, 229, 0.2);
    border-radius: 4px;
}
.org-chart-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 70, 229, 0.4);
}

.org-tree {
    display: inline-block;
    white-space: nowrap;
    text-align: center;
}

.org-tree ul {
    padding-top: 20px;
    position: relative;
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding-left: 0;
    border-left: none;
}

.org-tree li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px 10px 0 10px;
    list-style-type: none;
}

/* Vertical connector from parent to children */
.org-tree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid rgba(79, 70, 229, 0.3);
    width: 0;
    height: 20px;
}

/* Horizontal connector lines */
.org-tree li::before, .org-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid rgba(79, 70, 229, 0.3);
    width: 50%;
    height: 20px;
}
.org-tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid rgba(79, 70, 229, 0.3);
}

/* Disconnect connectors for single child / boundaries */
.org-tree li:only-child::after, .org-tree li:only-child::before {
    display: none;
}

.org-tree li:only-child {
    padding-top: 0;
}

.org-tree li:first-child::before, .org-tree li:last-child::after {
    border: 0 none;
}

.org-tree li:last-child::before {
    border-right: 2px solid rgba(79, 70, 229, 0.3);
    border-radius: 0 5px 0 0;
}

.org-tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Org Node Card */
.org-node-card {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--glass-border);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.03);
    min-width: 220px;
    max-width: 240px;
    position: relative;
    transition: var(--transition);
    text-align: left;
    white-space: normal; /* Allow text wrapping */
}

/* Connectors from card bottom */
.org-node-card.has-children::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 2px solid rgba(79, 70, 229, 0.3);
    width: 0;
    height: 20px;
    z-index: 10;
}

.org-node-card:hover {
    transform: translateY(-4px);
}

/* Neon Glow & Borders based on role */
.org-node-card.pos-head {
    border: 2px solid var(--neon-red);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.05), var(--neon-red-glow);
}
.org-node-card.pos-head:hover {
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.15), 0 0 16px rgba(239, 68, 68, 0.6);
}

.org-node-card.pos-officer {
    border: 2px solid rgba(59, 130, 246, 0.85);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.05), 0 0 12px rgba(59, 130, 246, 0.3);
}
.org-node-card.pos-officer:hover {
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.15), 0 0 16px rgba(59, 130, 246, 0.5);
}

.org-node-card.pos-operator {
    border: 2px solid rgba(139, 92, 246, 0.85);
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.05), 0 0 12px rgba(139, 92, 246, 0.3);
}
.org-node-card.pos-operator:hover {
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.15), 0 0 16px rgba(139, 92, 246, 0.5);
}

.org-node-card.pos-labour {
    border: 2px solid rgba(16, 185, 129, 0.85);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.05), 0 0 12px rgba(16, 185, 129, 0.3);
}
.org-node-card.pos-labour:hover {
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.15), 0 0 16px rgba(16, 185, 129, 0.5);
}

/* Avatar Node Styling */
.org-node-avatar-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.org-node-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.org-node-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-grow: 1;
}

.org-node-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.3;
}

.org-node-position {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    text-transform: uppercase;
}

.org-node-position.pos-head { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.org-node-position.pos-officer { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.org-node-position.pos-operator { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.org-node-position.pos-labour { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.org-node-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Avatar Upload Preview inside Modal */
.org-avatar-preview-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px dashed rgba(79, 70, 229, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.02);
    position: relative;
    transition: var(--transition);
}

.org-avatar-preview-wrapper:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.org-avatar-preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#org-avatar-placeholder {
    font-size: 32px;
    color: var(--text-muted);
}

/* Attendance Table Styles */
.attendance-table th, .attendance-table td {
    padding: 12px 16px;
}

.attendance-time-cell {
    text-align: center !important;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.attendance-time-cell:hover {
    background: rgba(79, 70, 229, 0.06);
    color: var(--primary);
}

.attendance-time-cell.empty {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

.attendance-time-cell.disabled-cell {
    cursor: not-allowed;
}

.attendance-time-cell.disabled-cell:hover {
    background: transparent;
    color: inherit;
}

.attendance-duration-col {
    font-weight: 700;
    text-align: center !important;
    color: var(--text-primary);
}

/* Time Picker Digital Spinner Modals */
.time-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.btn-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-spinner:hover {
    background: var(--primary);
    color: white;
}

.time-display-num {
    font-size: 44px;
    font-weight: 700;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.04);
    padding: 6px 18px;
    border-radius: var(--border-radius-md);
    min-width: 80px;
    text-align: center;
    color: var(--text-primary);
}

.preset-times-grid {
    margin: 16px 0;
}

/* Custom Export Dropdown */
.export-dropdown-container {
    position: relative;
    display: inline-block;
}

.export-menu {
    position: absolute;
    bottom: 42px;
    left: 0;
    min-width: 220px;
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
    animation: fadeIn 0.25s ease;
}

.export-menu.active {
    display: flex;
}

.export-menu button {
    background: transparent;
    border: none;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.export-menu button:hover {
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
}

/* print styling for PDF exports */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    .app-background,
    .main-header,
    .app-tabs-nav,
    .section-title-row button,
    .section-title-row .action-buttons-group,
    .table-filters,
    .app-footer,
    .card-actions,
    .modal-overlay,
    .manager-only-ui,
    .export-dropdown-container {
        display: none !important;
    }
    .app-container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
    .glass-panel {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    .view-section {
        display: block !important;
    }
    .tab-content {
        display: none !important;
    }
    .tab-content.active {
        display: block !important;
    }
    .chart-card {
        page-break-inside: avoid;
    }
    .tasks-table-card {
        page-break-before: always;
    }
    table {
        border-collapse: collapse !important;
    }
    th, td {
        border: 1px solid #ddd !important;
        color: black !important;
    }
}

/* Detail info text inside lists */
.tasks-table td a, .tasks-table td strong {
    font-weight: 600;
    color: var(--text-primary);
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .col-6 {
        width: 100%;
    }
    .main-header {
        flex-direction: column;
        align-items: stretch;
    }
    .role-switcher {
        flex-direction: column;
        align-items: flex-start;
    }
    .switcher-buttons {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    .app-footer {
        flex-direction: column;
        text-align: center;
    }
}
