/* ==========================================================================
   Design System & Stylesheet - Engineering Work Tracker
   ========================================================================== */

/* Imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* Variables & Themes */
:root {
  --font-primary: 'Inter', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette (Dark Theme Default) */
  --bg-base: #0f172a;          /* slate-900 */
  --bg-surface: #1e293b;       /* slate-800 */
  --bg-surface-elevated: #334155; /* slate-700 */
  --bg-glass: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6); /* Indigo focus */
  
  --text-primary: #f8fafc;     /* slate-50 */
  --text-secondary: #94a3b8;   /* slate-400 */
  --text-muted: #64748b;       /* slate-500 */
  
  /* Brand & Semantic Colors */
  --primary: #6366f1;          /* Indigo-500 */
  --primary-hover: #4f46e5;    /* Indigo-600 */
  --primary-light: rgba(99, 102, 241, 0.15);
  
  --accent-cyan: #06b6d4;      /* Cyan-500 */
  --accent-purple: #a855f7;    /* Purple-500 */
  
  --status-pending: #f59e0b;   /* Amber-500 */
  --status-progress: #3b82f6;  /* Blue-500 */
  --status-testing: #a855f7;   /* Purple-500 */
  --status-completed: #10b981; /* Emerald-500 */
  --status-rejected: #ef4444;  /* Red-500 */
  --status-purchase: #ec4899;  /* Pink-500 */
  
  --status-pending-light: rgba(245, 158, 11, 0.15);
  --status-progress-light: rgba(59, 130, 246, 0.15);
  --status-testing-light: rgba(168, 85, 247, 0.15);
  --status-completed-light: rgba(16, 185, 129, 0.15);
  --status-purchase-light: rgba(236, 72, 153, 0.15);
  
  /* Layout Constants */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.3);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Light Theme overrides */
[data-theme="light"] {
  --bg-base: #f8fafc;          /* slate-50 */
  --bg-surface: #ffffff;       /* white */
  --bg-surface-elevated: #f1f5f9; /* slate-100 */
  --bg-glass: rgba(255, 255, 255, 0.8);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --text-primary: #0f172a;     /* slate-900 */
  --text-secondary: #475569;   /* slate-600 */
  --text-muted: #94a3b8;       /* slate-400 */
  
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.05), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.1);
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* Common Layout Components */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2rem;
  margin-top: var(--header-height);
  transition: padding var(--transition-normal);
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
}

/* --- Login Page --- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 40%),
              var(--bg-base);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: rgba(15, 23, 42, 0.3);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input-no-icon {
  padding-left: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap; /* Prevent button text wrapping on mobile */
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  width: 100%;
}

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

.btn-secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--text-muted);
}

.login-demo-info {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-align: left;
}

.login-demo-title {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.login-demo-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0.25rem;
  color: var(--text-muted);
}

.error-message {
  color: var(--status-rejected);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  display: none; /* Controlled dynamically */
}

/* --- Header / Navbar --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 50;
  border-bottom: 1px solid var(--border-color);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background-color: var(--primary-light);
}

.nav-link.active {
  color: var(--primary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--border-color);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--primary-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  width: fit-content;
}

.logout-btn {
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.logout-btn:hover {
  color: var(--status-rejected);
}

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

.metric-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.metric-icon {
  width: 24px;
  height: 24px;
  opacity: 0.8;
}

.metric-value {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
}

.metric-card.pending::after { background: var(--status-pending); }
.metric-card.progress::after { background: var(--status-progress); }
.metric-card.testing::after { background: var(--status-testing); }
.metric-card.purchase::after { background: var(--status-purchase); }
.metric-card.completed::after { background: var(--status-completed); }

.charts-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

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

.chart-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-bar-container {
  height: 8px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

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

/* Activity logs */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 350px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

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

.activity-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.activity-info {
  flex: 1;
}

.activity-text {
  font-size: 0.875rem;
  color: var(--text-primary);
}

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

/* --- Requests List / Table View --- */
.list-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-filter-group {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  min-width: 250px;
  padding: 0.6rem 1rem 0.6rem 2.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
}

.filter-select {
  padding: 0.6rem 2rem 0.6rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.925rem;
}

.data-table th {
  background-color: rgba(15, 23, 42, 0.3);
  padding: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

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

.data-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.pending { background: var(--status-pending-light); color: var(--status-pending); }
.status-badge.in-progress { background: var(--status-progress-light); color: var(--status-progress); }
.status-badge.testing { background: var(--status-testing-light); color: var(--status-testing); }
.status-badge.pending-purchase { background: var(--status-purchase-light); color: var(--status-purchase); }
.status-badge.completed { background: var(--status-completed-light); color: var(--status-completed); }

.priority-badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.priority-badge.low { color: var(--text-secondary); background: rgba(148, 163, 184, 0.15); }
.priority-badge.medium { color: var(--status-progress); background: var(--status-progress-light); }
.priority-badge.high { color: var(--status-pending); background: var(--status-pending-light); }
.priority-badge.urgent { color: var(--status-rejected); background: rgba(239, 68, 68, 0.15); }

/* --- Kanban View --- */
.kanban-view-btn {
  cursor: pointer;
  background-color: var(--bg-surface-elevated);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color var(--transition-fast);
  white-space: nowrap;
}

.kanban-view-btn:hover {
  background-color: var(--text-muted);
}

.kanban-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  min-height: 600px;
}

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

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

.kanban-column {
  background-color: rgba(15, 23, 42, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.kanban-column-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kanban-column-count {
  font-size: 0.75rem;
  background: var(--bg-surface-elevated);
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  color: var(--text-secondary);
}

.kanban-column.pending .kanban-column-header { border-bottom-color: var(--status-pending); }
.kanban-column.progress .kanban-column-header { border-bottom-color: var(--status-progress); }
.kanban-column.testing .kanban-column-header { border-bottom-color: var(--status-testing); }
.kanban-column.pending-purchase .kanban-column-header { border-bottom-color: var(--status-purchase); }
.kanban-column.completed .kanban-column-header { border-bottom-color: var(--status-completed); }

.kanban-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 500px;
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

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

.kanban-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
}

.kanban-card-tag {
  background: var(--bg-surface-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* --- Detail & Edit Modals --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

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

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: transform var(--transition-normal);
}

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

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-btn {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  transition: color var(--transition-fast);
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Info Detail Grid inside Modal */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.detail-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 500;
}

.detail-full-width {
  grid-column: span 2;
}

.notes-section {
  background-color: rgba(15, 23, 42, 0.2);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
}

.notes-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.notes-content {
  font-size: 0.9rem;
  white-space: pre-wrap;
}

/* Form Styles */
.form-card {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.form-title-row {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

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

.form-full-width {
  grid-column: span 2;
}

.form-select {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: rgba(15, 23, 42, 0.3);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
}

.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: rgba(15, 23, 42, 0.3);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input:disabled, .form-select:disabled {
  background-color: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color);
  color: var(--text-secondary);
  cursor: not-allowed;
  opacity: 0.8;
}

.form-label-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  min-height: 38px;
  margin-bottom: 0.5rem;
  width: 100%;
}

/* --- Settings Page --- */
.settings-section {
  margin-bottom: 2.5rem;
}

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

.settings-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Code Panel */
.code-panel {
  background-color: #090d16;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: #a78bfa;
  overflow-x: auto;
  max-height: 300px;
  margin-top: 1rem;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(15, 23, 42, 0.5);
  padding: 0.5rem 1rem;
  margin: -1.25rem -1.25rem 1rem -1.25rem;
  border-bottom: 1px solid var(--border-color);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.copy-btn {
  background: var(--bg-surface-elevated);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.copy-btn:hover {
  background-color: var(--text-muted);
}

.guide-step {
  margin-bottom: 1.25rem;
}

.guide-step-num {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  text-align: center;
  line-height: 24px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.guide-step-title {
  font-weight: 600;
  display: inline-block;
}

.guide-step-content {
  margin-left: 2rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* User administration list in Settings */
.user-admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-admin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

/* Theme Toggle Button in Header */
.theme-toggle-btn {
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
}

.notification-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: white;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.notification-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.notification-toast.success { background-color: var(--status-completed); }
.notification-toast.error { background-color: var(--status-rejected); }
.notification-toast.info { background-color: var(--status-progress); }

/* ==========================================================================
   Responsive Design & Mobile Support
   ========================================================================== */

/* Hamburger menu button style */
.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.menu-toggle-btn:hover {
  background-color: var(--bg-surface-elevated);
}

/* User Management grid layout in settings page */
.settings-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

/* Media Queries */
@media (max-width: 992px) {
  .main-content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 1rem;
  }

  /* Show mobile menu button */
  .menu-toggle-btn {
    display: block;
  }

  /* Turn navbar into sliding sidebar */
  .header-nav {
    position: fixed;
    top: var(--header-height);
    right: -100%;
    width: 280px;
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    flex-direction: column;
    align-items: flex-start;
    padding: 2rem 1.5rem;
    gap: 1rem;
    transition: right var(--transition-normal);
    z-index: 99;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }

  /* When mobile menu is active */
  .header-nav.active {
    right: 0;
  }

  .nav-link {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  .theme-toggle-btn {
    align-self: flex-start;
    padding: 0.75rem 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .theme-toggle-btn::after {
    content: 'เปลี่ยนธีม (Toggle Theme)';
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
  }

  /* Profile container inside mobile menu */
  .user-profile {
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 1.5rem;
    margin-top: auto;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .user-details {
    margin-right: auto;
    margin-left: 0.5rem;
  }

  .logout-btn {
    padding: 0.75rem;
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--status-rejected);
    border-radius: var(--radius-sm);
  }

  /* User Management grid layout inside Settings on mobile */
  .settings-grid-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* Modals adjustments for mobile */
  .modal-content {
    margin: 1rem;
    width: calc(100% - 2rem);
    max-height: 85vh;
  }

  .modal-header, .modal-body, .modal-footer {
    padding: 1.25rem;
  }

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

  .form-label-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-height: auto;
  }

  .form-full-width {
    grid-column: span 1;
  }

  /* Stack modal footer buttons vertically on mobile to prevent squishing and wrapping */
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .modal-footer .btn {
    width: 100%;
    margin-right: 0 !important;
    margin-left: 0 !important;
    justify-content: center;
  }

  /* Visual ordering for stacked buttons */
  .modal-footer button[type="submit"] {
    order: 1; /* Save on top */
  }
  #modal-cancel-btn {
    order: 2; /* Close in middle */
  }
  #modal-delete-btn {
    order: 3; /* Delete at bottom */
  }

  /* Detail grid layout in modal */
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .detail-full-width {
    grid-column: span 1;
  }

  /* Actions list items layout */
  .list-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
  }

  .search-filter-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-input-wrapper {
    width: 100%;
  }

  .search-input {
    width: 100%;
    min-width: 0;
  }

  .filter-select {
    width: 100%;
  }

  .kanban-view-btn {
    width: 100%;
    justify-content: center;
  }
}
