/* TaskPulse Pure Self-Contained CSS - Zero External CDN Dependencies Required */

:root {
  --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bg-dark: #0b0f19;
  --card-bg: rgba(21, 28, 44, 0.85);
  --card-border: rgba(255, 255, 255, 0.1);
  --input-bg: #0f172a;
  --input-border: #334155;
  --brand-main: #6366f1;
  --brand-hover: #4f46e5;
  --emerald-main: #10b981;
  --amber-main: #d97706;
  --rose-main: #f43f5e;
  --purple-main: #a855f7;
  --text-white: #f8fafc;
  --text-slate: #94a3b8;
  --text-muted: #64748b;
  --nav-bg: rgba(11, 15, 25, 0.92);
  --modal-bg: #151c2c;
  --task-card-bg: rgba(15, 23, 42, 0.9);
  --table-head-bg: rgba(15, 23, 42, 0.95);
  --table-border: rgba(255, 255, 255, 0.06);
  --table-text: #e2e8f0;
  --badge-bg: rgba(255, 255, 255, 0.04);
  --note-bg: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-dark: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --input-bg: #f1f5f9;
  --input-border: #cbd5e1;
  --brand-main: #4f46e5;
  --brand-hover: #4338ca;
  --emerald-main: #059669;
  --amber-main: #d97706;
  --rose-main: #e11d48;
  --purple-main: #9333ea;
  --text-white: #0f172a;
  --text-slate: #475569;
  --text-muted: #64748b;
  --nav-bg: rgba(255, 255, 255, 0.95);
  --modal-bg: #ffffff;
  --task-card-bg: #ffffff;
  --table-head-bg: #e2e8f0;
  --table-border: #e2e8f0;
  --table-text: #1e293b;
  --badge-bg: #f1f5f9;
  --note-bg: #f8fafc;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 70px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
}

/* Glassmorphism utility */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.glass-nav {
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Offline Banner */
#offline-banner {
  background: linear-gradient(90deg, #d97706, #b45309);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#offline-banner.hidden {
  display: none !important;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 20px;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pwa-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-subtitle {
  font-size: 0.68rem;
  color: var(--text-slate);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #4f46e5, #4338ca);
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-slate);
  border: 1px solid var(--input-border);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  color: var(--text-white);
  background: #334155;
}

/* Edit Task Button - Pure White Text */
.edit-task-btn {
  color: #ffffff !important;
  background: var(--brand-main) !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  font-weight: 700;
  transition: all 0.2s ease;
}

.edit-task-btn:hover {
  color: #ffffff !important;
  background: var(--brand-hover) !important;
  transform: translateY(-1px);
}

/* Theme Mode Toggle Button - Inverted High Contrast Colors */
#theme-toggle-btn {
  transition: all 0.25s ease;
  font-weight: 700;
}

/* Dark mode -> Light button background & dark text color */
[data-theme="dark"] #theme-toggle-btn {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] #theme-toggle-btn:hover {
  background: #f8fafc !important;
  color: #020617 !important;
}

[data-theme="dark"] #theme-toggle-btn svg {
  color: #0f172a !important;
}

/* Light mode -> Dark button background & light text color */
[data-theme="light"] #theme-toggle-btn {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.25);
}

[data-theme="light"] #theme-toggle-btn:hover {
  background: #1e293b !important;
  color: #ffffff !important;
}

[data-theme="light"] #theme-toggle-btn svg {
  color: #fbbf24 !important;
}

.pwa-install-highlight {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(99, 102, 241, 0.15)) !important;
  color: #34d399 !important;
  border: 1px solid rgba(52, 211, 153, 0.4) !important;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.2);
  transition: all 0.2s ease;
}

.pwa-install-highlight:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(99, 102, 241, 0.3)) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.installable-ready {
  animation: pulseBtn 2s infinite;
}

@keyframes pulseBtn {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* App Layout Container */
.app-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Stats Overview Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 992px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-slate);
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.total { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.stat-icon.progress { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.completed { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.notes { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}

/* Filter Control Bar */
.filter-bar {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .filter-controls {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

.search-wrapper {
  position: relative;
}

.search-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-slate);
  width: 16px;
  height: 16px;
}

.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-white);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrapper .form-control {
  padding-left: 38px;
}

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

/* View Switcher Tabs */
.view-tabs {
  display: flex;
  align-items: center;
  background: #0f172a;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid #1e293b;
  width: fit-content;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-slate);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--brand-main);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Kanban Board Columns (3 Columns) */
.kanban-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .kanban-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kanban-column {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 400px;
}

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

.column-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-title.todo { color: var(--text-slate); }
.column-title.progress { color: var(--amber-main); }
.column-title.completed { color: var(--emerald-main); }

.task-count {
  background: #0f172a;
  color: var(--text-slate);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid #1e293b;
}

/* Task Cards */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.task-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.25s ease;
  position: relative;
}

.task-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-code {
  font-size: 0.7rem;
  font-weight: 800;
  font-family: monospace;
  color: var(--brand-main);
  background: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #1e293b;
}

.priority-pill {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
}

.priority-pill.urgent { background: rgba(244, 63, 94, 0.2); color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.3); }
.priority-pill.high { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.priority-pill.medium { background: rgba(99, 102, 241, 0.2); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
.priority-pill.low { background: rgba(148, 163, 184, 0.2); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }

.task-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.35;
}

.task-desc {
  font-size: 0.75rem;
  color: var(--text-slate);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.assignee-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #090d16;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #1e293b;
  width: fit-content;
}

.assignee-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-main);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.assignee-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #e2e8f0;
}

/* Latest Note Box inside Task Card */
.task-notes-preview {
  background: #060911;
  border-left: 3px solid var(--amber-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notes-header {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--amber-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notes-content {
  color: #cbd5e1;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Actions Footer */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.status-select {
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}

.status-select:focus {
  border-color: var(--brand-main);
}

.btn-icon {
  background: #1e293b;
  color: var(--text-white);
  border: 1px solid #334155;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--brand-main);
  color: #fff;
  border-color: var(--brand-main);
}

.btn-icon.delete:hover {
  background: var(--rose-main);
  border-color: var(--rose-main);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}

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

.modal-card {
  background: var(--modal-bg);
  border: 1px solid var(--card-border);
  color: var(--text-white);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

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

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

.modal-title {
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-slate);
  font-size: 1.2rem;
  cursor: pointer;
  font-weight: bold;
}

.close-btn:hover {
  color: #fff;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-white);
}

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

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--card-border);
}

/* Toast Messages */
#toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  #toast-container {
    bottom: 24px;
  }
}

.toast {
  background: rgba(99, 102, 241, 0.95);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

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

/* Mobile Bottom Navigation */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid var(--card-border);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-slate);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 700;
}

.mobile-nav-item.active {
  color: var(--brand-main);
}

@media (min-width: 768px) {
  .mobile-nav {
    display: none;
  }
}

/* Mobile View Header & Create Task Button Responsiveness */
@media (max-width: 768px) {
  header {
    padding: 8px 10px !important;
  }

  .header-container {
    gap: 6px !important;
    width: 100%;
  }

  .brand-subtitle {
    display: none !important;
  }

  .brand-text h1 {
    font-size: 0.95rem !important;
  }

  .logo-icon {
    width: 32px !important;
    height: 32px !important;
  }

  .header-actions {
    gap: 4px !important;
    flex-wrap: nowrap;
    margin-left: auto;
  }

  .header-actions .btn-secondary,
  .header-actions .btn-primary {
    padding: 6px 8px !important;
    font-size: 0.7rem !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  #theme-text,
  #pwa-install-btn span {
    display: none !important;
  }
}

@media (max-width: 400px) {
  .logo-brand {
    gap: 4px !important;
  }
  
  .header-actions .btn-primary span {
    font-size: 0.68rem !important;
  }
}
