:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.78);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);

  --status-todo: #64748b;
  --status-progress: #3b82f6;
  --status-review: #f59e0b;
  --status-done: #10b981;
  --status-overdue: #ef4444;

  --font-family: 'Inter', 'Noto Sans Thai', 'Noto Sans Lao', 'Noto Sans SC', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

/* LIGHT THEME OVERRIDES */
body.light-theme {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-color: rgba(0, 0, 0, 0.12);
  --border-highlight: rgba(99, 102, 241, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  background-image:
    radial-gradient(circle at 10% 10%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(236, 72, 153, 0.08) 0%, transparent 45%);
}

body.light-theme .navbar {
  background: rgba(255, 255, 255, 0.92);
}

body.light-theme .select-box,
body.light-theme .search-input,
body.light-theme .form-input,
body.light-theme .form-textarea,
body.light-theme .form-select {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0, 0, 0, 0.18);
}

body.light-theme .btn-secondary,
body.light-theme .btn-back {
  background: #e2e8f0;
  color: #1e293b;
}

body.light-theme .kanban-col {
  background: rgba(241, 245, 249, 0.9);
}

body.light-theme .task-card,
body.light-theme .todo-task-item {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .task-card-title,
body.light-theme .todo-task-title {
  color: #0f172a;
}

body.light-theme .modal-content {
  background: #ffffff;
  color: #0f172a;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(99, 102, 241, 0.18) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(236, 72, 153, 0.15) 0%, transparent 45%);
  background-attachment: fixed;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-red { color: #f87171 !important; }
.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(16px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  border: 1px solid var(--border-highlight);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.nav-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.brand-icon img { width: 100%; height: 100%; object-fit: cover; }
.brand-icon.lg { width: 56px; height: 56px; font-size: 28px; }

.brand-title {
  font-size: 1.25rem; font-weight: 700;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-subtitle { font-size: 0.775rem; color: var(--text-secondary); }

.nav-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.control-group { display: flex; align-items: center; gap: 6px; }

.user-badge-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-highlight);
  padding: 4px 12px 4px 6px;
  border-radius: var(--radius-full);
}

.select-box {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none; cursor: pointer;
  font-family: inherit;
}
.select-box:hover { border-color: var(--accent-primary); }

.view-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.view-btn {
  background: transparent; border: none;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.view-btn.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 10px; font-size: 0.85rem; }
.search-input {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 8px 12px 8px 32px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem; outline: none;
  font-family: inherit; width: 160px;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff; border: none;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.7);
  color: var(--text-primary); border: 1px solid var(--border-color);
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 0.825rem; cursor: pointer;
  font-family: inherit;
}

.nav-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  background: rgba(51, 65, 85, 0.7);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: all 0.2s ease;
}
.btn-back:hover {
  background: rgba(99, 102, 241, 0.3);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 7px 12px; border-radius: var(--radius-sm);
  font-size: 0.825rem; cursor: pointer;
  font-family: inherit;
}

.btn-whatsapp {
  background: #25D366; color: #fff; border: none;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
}

/* LAYOUT & CARDS */
.main-container { max-width: 1400px; margin: 0 auto; padding: 24px; }
.view-section { display: flex; flex-direction: column; gap: 24px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat-card { padding: 20px; display: flex; align-items: center; justify-content: space-between; }
.stat-value { font-size: 1.8rem; font-weight: 800; margin-top: 4px; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.icon-indigo { background: rgba(99, 102, 241, 0.2); }
.icon-blue { background: rgba(59, 130, 246, 0.2); }
.icon-green { background: rgba(16, 185, 129, 0.2); }
.icon-red { background: rgba(239, 68, 68, 0.2); }

/* TASK STATUS PROPORTION BAR */
.proportion-bar-container {
  display: flex;
  height: 16px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
.prop-segment {
  height: 100%;
  transition: width 0.4s ease;
}
.prop-todo { background: #64748b; }
.prop-progress { background: #3b82f6; }
.prop-review { background: #f59e0b; }
.prop-done { background: #10b981; }
.prop-overdue { background: #ef4444; }

/* TO-DO TASKS BLOCK */
.todo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.todo-task-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-left: 4px solid #64748b;
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.todo-task-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
}
.todo-task-item.urgent { border-left-color: #ef4444; }
.todo-task-item.medium { border-left-color: #f59e0b; }

.todo-task-title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }

/* Clickable Stat Cards */
.clickable-card {
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.clickable-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}
.clickable-card.active-card-filter {
  border: 2px solid #38bdf8 !important;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4) !important;
}

.workload-section { padding: 24px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.section-title { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.member-workload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.member-workload-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
  cursor: pointer; transition: all 0.2s ease;
}
.member-workload-card:hover { border-color: var(--accent-primary); }

.member-info-row { display: flex; align-items: center; gap: 12px; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color); }
.avatar-lg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent-primary); }

.assignees-avatars-row {
  display: flex;
  align-items: center;
}
.assignees-avatars-row img {
  margin-right: -8px;
  border: 2px solid var(--bg-surface);
}

.progress-bg { width: 100%; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.4s ease; }

.main-section { padding: 24px; }
.filter-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.875rem; }
.task-table th { text-align: left; padding: 12px 14px; background: rgba(15, 23, 42, 0.8); color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border-color); }
.task-table td { padding: 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.task-table tr:hover td { background: rgba(51, 65, 85, 0.35); }

.member-banner { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.member-banner-info { display: flex; align-items: center; gap: 16px; }
.member-banner-name { font-size: 1.3rem; font-weight: 700; }
.member-banner-role { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }

.kanban-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; align-items: start; }
.kanban-col { background: rgba(15, 23, 42, 0.75); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 520px; }
.kanban-col-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.col-title { font-weight: 700; font-size: 0.95rem; }
.col-todo { color: var(--status-todo); }
.col-progress { color: var(--status-progress); }
.col-review { color: var(--status-review); }
.col-done { color: var(--status-done); }
.col-badge { background: rgba(255, 255, 255, 0.1); padding: 2px 10px; border-radius: var(--radius-full); font-size: 0.8rem; font-weight: 600; }

.task-list { display: flex; flex-direction: column; gap: 12px; }

.task-card {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; transition: all 0.2s ease;
}
.task-card:hover { transform: translateY(-2px); border-color: var(--accent-primary); }
.task-card.overdue { border-left: 4px solid var(--status-overdue); }
.task-card.due-soon { border-left: 4px solid var(--status-review); }

.task-card-title { font-weight: 600; font-size: 0.95rem; line-height: 1.4; color: var(--text-primary); }
.task-card-desc { font-size: 0.825rem; color: var(--text-secondary); line-height: 1.5; }
.task-card-img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 6px; margin-top: 4px; }

.badge { font-size: 0.725rem; font-weight: 600; padding: 3px 8px; border-radius: 4px; display: inline-flex; align-items: center; gap: 4px; }
.badge-overdue { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-due-soon { background: rgba(245, 158, 11, 0.2); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.3); }

.task-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.775rem; color: var(--text-muted); padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.06); }

/* Assignee Checkbox Grid in Task Modal */
.assignees-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  max-height: 140px;
  overflow-y: auto;
}
.assignee-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* MODALS */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-content {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); width: 100%; max-width: 560px;
  padding: 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.btn-icon { background: none; border: none; color: var(--text-secondary); font-size: 1.2rem; cursor: pointer; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.form-input, .form-textarea, .form-select {
  background: rgba(15, 23, 42, 0.8); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-primary); font-size: 0.9rem; outline: none; font-family: inherit;
}
.form-input:disabled { opacity: 0.6; cursor: not-allowed; background: rgba(15, 23, 42, 0.4); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.modal-actions { display: flex; gap: 10px; }

.member-chip { display: flex; align-items: center; gap: 12px; background: rgba(15, 23, 42, 0.6); padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.sms-success-box { text-align: center; padding: 24px; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3); border-radius: var(--radius-md); }

/* PRINT STYLES FOR PDF EXPORT */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .no-print, .navbar, .modal-overlay:not(#reportModal) {
    display: none !important;
  }
  .modal-overlay#reportModal {
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }
  .modal-content.print-modal {
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
  }
  .report-area {
    color: #000000 !important;
  }
  .task-table th, .task-table td {
    color: #000000 !important;
    border-color: #cccccc !important;
  }
}
