/* ===== CSS Variables & Theme ===== */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-sidebar: #f1f3f5;
  --bg-hover: #e9ecef;
  --bg-input: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --border: #dee2e6;
  --border-light: #e9ecef;
  --primary: #4263eb;
  --primary-light: #dbe4ff;
  --primary-hover: #3b5bdb;
  --green: #2f9e44;
  --green-light: #d3f9d8;
  --orange: #e8590c;
  --orange-light: #ffe8cc;
  --red: #e03131;
  --red-light: #ffe3e3;
  --yellow: #f08c00;
  --yellow-light: #fff3bf;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-width: 260px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #1a1b26;
  --bg-card: #24283b;
  --bg-sidebar: #1f2335;
  --bg-hover: #2d3148;
  --bg-input: #2a2e42;
  --text: #c0caf5;
  --text-secondary: #9aa5ce;
  --text-muted: #565f89;
  --border: #33364d;
  --border-light: #2a2e42;
  --primary: #7aa2f7;
  --primary-light: #2e3a5f;
  --primary-hover: #89b0ff;
  --green: #9ece6a;
  --green-light: #1f2e1f;
  --orange: #ff9e64;
  --orange-light: #3a2e22;
  --red: #f7768e;
  --red-light: #3a1f2a;
  --yellow: #e0af68;
  --yellow-light: #3a3320;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.4);
}

/* ===== Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* ===== Layout ===== */
#app {
  display: flex;
  height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 20px;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: left;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 16px;
}

.sidebar-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 8px;
}

.stat-item {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--border-light);
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.tag-chip:hover, .tag-chip.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== Buttons ===== */
.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-block {
  width: 100%;
}

.btn-today {
  padding: 6px 14px;
  font-size: 13px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.btn-today:hover {
  background: var(--primary);
  color: #fff;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.menu-toggle {
  display: none;
}

/* ===== Main ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-display {
  text-align: center;
  min-width: 160px;
}

.date-display h2 {
  font-size: 18px;
  font-weight: 700;
}

.date-display span {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  margin-left: auto;
}

.search-input {
  width: 240px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ===== Views ===== */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  text-align: center;
  transition: all var(--transition);
  background: var(--bg-card);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-content {
  color: var(--text-muted);
  font-size: 14px;
}

.drop-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.drop-hint {
  font-size: 12px;
  margin-top: 4px;
}

.drop-hint code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
}

/* ===== Timeline ===== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-hour {
  display: flex;
  align-items: flex-start;
  min-height: 60px;
  position: relative;
}

.timeline-hour-label {
  width: 60px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 4px;
  text-align: right;
  padding-right: 12px;
  position: sticky;
  left: 0;
}

.timeline-hour-content {
  flex: 1;
  border-left: 2px solid var(--border-light);
  padding-left: 16px;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-hour.current .timeline-hour-label {
  color: var(--primary);
}

.timeline-hour.current .timeline-hour-content {
  border-left-color: var(--primary);
}

/* ===== Task Card ===== */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.task-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.task-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border);
}

.task-card.priority-high::before { background: var(--orange); }
.task-card.priority-urgent::before { background: var(--red); }
.task-card.priority-low::before { background: var(--text-muted); }

.task-card.done {
  opacity: 0.55;
}

.task-card.done .task-title {
  text-decoration: line-through;
}

.task-card.cancelled {
  opacity: 0.4;
}

.task-card.cancelled .task-title {
  text-decoration: line-through;
}

.task-card.overdue:not(.done):not(.cancelled) {
  border-color: var(--red);
  background: var(--red-light);
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.task-checkbox:hover {
  border-color: var(--primary);
}

.task-card.done .task-checkbox {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.task-card.done .task-checkbox::after {
  content: '✓';
  font-size: 13px;
  font-weight: 700;
}

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}

.task-time {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.task-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-hover);
  border-radius: 10px;
  color: var(--text-secondary);
}

.task-priority-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.task-priority-badge.urgent { background: var(--red-light); color: var(--red); }
.task-priority-badge.high { background: var(--orange-light); color: var(--orange); }
.task-priority-badge.low { background: var(--bg-hover); color: var(--text-muted); }

.task-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  white-space: pre-wrap;
}

.task-status-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* ===== Task List (All Tasks / Overdue) ===== */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-group-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 16px;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.list-group-header:first-child {
  margin-top: 0;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 14px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border var(--transition);
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group textarea {
  resize: vertical;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.modal-footer-right {
  display: flex;
  gap: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .menu-toggle {
    display: flex;
  }

  .search-input {
    width: 140px;
  }

  .date-display {
    min-width: 120px;
  }

  .date-display h2 {
    font-size: 16px;
  }

  .main-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .view-container {
    padding: 16px;
  }

  .timeline-hour-label {
    width: 44px;
    padding-right: 8px;
  }
}
