:root {
    /* Color Palette - Minimalist Green */
    --bg-dark: #18181b; /* Zinc 900 */
    --bg-panel: rgba(39, 39, 42, 0.7); /* Zinc 800 */
    --bg-panel-hover: rgba(63, 63, 70, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-main: #f4f4f5; /* Zinc 50 */
    --text-muted: #a1a1aa; /* Zinc 400 */
    
    --primary: #10b981; /* Emerald 500 */
    --primary-hover: #059669; /* Emerald 600 */
    --accent: #34d399; /* Emerald 400 */
    
    /* Status Colors */
    --status-todo: #71717a;
    --status-inprogress: #f59e0b;
    --status-inreview: #3b82f6;
    --status-done: #10b981;
    
    /* Priority Colors */
    --priority-low: #38bdf8;
    --priority-medium: #facc15;
    --priority-high: #f43f5e;
    
    /* Alert Colors */
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    /* Glassmorphism */
    --glass-blur: blur(12px);
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    /* Layout */
    --sidebar-width: 250px;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Prompt', sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(16, 185, 129, 0.1), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(52, 211, 153, 0.08), transparent 30%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { font-weight: 600; }
.text-muted { color: var(--text-muted); }

/* Glass Panel Utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
}

/* Layout Container */
.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2rem;
}
.logo ion-icon { color: var(--primary); font-size: 1.8rem; }

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: 300px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view-mode-badge {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.user-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-icon {
    font-size: 2rem;
    color: var(--text-muted);
}

.glass-select, .glass-input {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    outline: none;
    font-size: 0.9rem;
}

.glass-select {
    cursor: pointer;
}

.glass-select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

/* Views Container */
.view-section {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}
.view-section.active { display: flex; }

.view-section::-webkit-scrollbar { width: 8px; }
.view-section::-webkit-scrollbar-track { background: transparent; }
.view-section::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

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

/* Dashboard View */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card.clickable {
    cursor: pointer;
}

.stat-card.clickable:hover {
    transform: translateY(-4px);
    background: var(--bg-panel-hover);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.dashboard-widgets {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.widget {
    padding: 1.5rem;
}

.widget-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.member-progress-list, .activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Progress Item */
.progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Activity Item */
.activity-item {
    display: flex;
    gap: 0.75rem;
    font-size: 0.875rem;
}
.activity-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    min-width: 45px;
}
.activity-desc { flex: 1; }
.activity-user { color: var(--primary); font-weight: 500; }

/* Dashboard Detail Modal List */
.detail-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
}
.detail-list-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}
.detail-item-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.detail-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Kanban Board */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.kanban-board {
    display: flex;
    gap: 1rem;
    height: calc(100% - 60px);
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.column-title {
    font-size: 1rem;
    font-weight: 600;
}

.task-count {
    background: rgba(255,255,255,0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

.task-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    min-height: 150px;
}
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

/* Task Card */
.task-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    cursor: grab;
    transition: var(--transition);
    position: relative;
}

.task-card:hover {
    transform: translateY(-2px);
    background: var(--bg-panel-hover);
    box-shadow: 0 8px 12px -1px rgba(0,0,0,0.2);
}

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

.task-priority-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: var(--border-radius-md) 0 0 var(--border-radius-md);
}

.priority-high { background-color: var(--priority-high); }
.priority-medium { background-color: var(--priority-medium); }
.priority-low { background-color: var(--priority-low); }

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

.task-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
}

.task-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.task-assignee {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.assignee-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-category-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.task-deadline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.task-deadline.overdue {
    color: var(--danger);
    font-weight: 600;
}
.task-deadline.due-soon {
    color: var(--status-inprogress);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

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

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    transform: translateY(20px);
    transition: var(--transition);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.close-btn:hover { color: var(--text-main); }

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.required { color: var(--danger); }

input[type="text"], input[type="date"], select, textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-sm);
    outline: none;
    font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
}

textarea { resize: vertical; }

.modal-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.footer-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    font-size: 0.95rem;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }

.w-100 { width: 100%; }

/* Dragging state */
.task-card.dragging {
    opacity: 0.5;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}
.task-list.drag-over {
    background: rgba(255,255,255,0.05);
    border-radius: var(--border-radius-md);
}

/* Responsiveness */
@media (max-width: 900px) {
    .dashboard-widgets { grid-template-columns: 1fr; }
    .kanban-board { flex-direction: column; height: auto; }
    .kanban-column { min-height: 300px; }
}

/* Login Screen & Auth */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.1), transparent 50%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.login-overlay.active { display: flex; }

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
}

.text-center { text-align: center; }
.justify-center { justify-content: center; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.ml-2 { margin-left: 0.5rem; }

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Chat System */
.floating-chat-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    z-index: 1000;
    transition: var(--transition);
}
.floating-chat-btn:hover {
    transform: scale(1.1);
}
.chat-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 50%;
    padding: 0.2rem 0.5rem;
    transform: translate(25%, -25%);
}

.chat-sidebar {
    position: fixed;
    bottom: 90px;
    right: 2rem;
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}
.chat-sidebar.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-view {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: var(--transition);
    background: transparent;
}
.chat-view.active {
    transform: translateX(0);
}
#chat-list-view.chat-view { transform: translateX(-100%); }
#chat-list-view.chat-view.active { transform: translateX(0); }

/* Chat List */
#chat-list-view {
    padding: 0.5rem;
    overflow-y: auto;
}
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.chat-list-item:hover {
    background: rgba(255,255,255,0.05);
}
.chat-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
}
.chat-info h4 { font-size: 0.95rem; margin-bottom: 0.2rem; }
.chat-info p { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* Chat Room */
.room-header {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--border-color);
}

.messages-container {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.message.sent { align-self: flex-end; align-items: flex-end; }
.message.received { align-self: flex-start; align-items: flex-start; }

.message-sender {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}
.message.sent .message-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}
.message.received .message-bubble {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}
.message-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    gap: 4px;
}
.message.sent .message-time {
    justify-content: flex-end;
}
.read-receipt {
    font-size: 0.8rem;
}
.read-receipt.read {
    color: var(--primary);
}
.read-receipt.unread {
    color: var(--text-muted);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border-color);
}
.chat-input-area input {
    flex: 1;
    background: rgba(255,255,255,0.05);
}

/* 📱 Mobile Responsive (Responsive Design) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 0.5rem;
    }
    
    .sidebar {
        width: 100%;
        padding: 0.5rem 1rem;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .logo {
        margin-bottom: 0;
        font-size: 1.2rem;
    }
    
    .main-nav {
        flex-direction: row;
        gap: 0.25rem;
        margin-top: 0;
    }
    
    .nav-item {
        padding: 0.5rem;
    }
    
    .nav-item span {
        display: none; /* ซ่อนข้อความโชว์แค่ไอคอนในมือถือ */
    }
    
    .sidebar-bottom {
        display: flex;
        flex-direction: row;
        width: 100%;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .sidebar-bottom button {
        margin-top: 0 !important;
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .kanban-column {
        min-width: 280px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-content {
        padding: 1rem;
        width: 95%;
        margin: auto;
    }
    
    .chat-sidebar {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .user-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
}
