﻿:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0 0 100px 0;
  line-height: 1.5;
}

.app-header {
  background: var(--surface);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--primary);
}

.version-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.version-control select {
  padding: 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.app-main {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.stat-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: normal;
}

.stat-card p {
  margin: 0;
  font-size: 1.5rem;
  font-weight: bold;
}

.color-green {
  color: var(--green);
}

.color-orange {
  color: var(--orange);
}

.color-red {
  color: var(--red);
}

.color-blue {
  color: var(--blue);
}

.filter-section {
  background: var(--surface);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.filter-section input[type="text"],
.filter-section select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 150px;
}

.checkbox-filters {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.checkbox-filters label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.action-bar {
  margin-bottom: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pagination-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.pagination-left,
.pagination-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pagination-left label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-left select {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
}

#page-info,
#page-range-info {
  color: var(--text-light);
  font-size: 0.9rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1300px;
  font-size: 0.9rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

th {
  background: #f1f5f9;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

th[data-sort]:hover {
  background: #e2e8f0;
}

td {
  vertical-align: middle;
}

tr.row-fav {
  background: #fffbeb;
}

select.table-input,
input[type="text"].table-input,
input[type="date"].table-input {
  width: 100%;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-sizing: border-box;
}

.deadline-text-input {
  min-width: 150px;
}

input[type="checkbox"].fav-star {
  appearance: none;
  width: 20px;
  height: 20px;
  cursor: pointer;
  position: relative;
}

input[type="checkbox"].fav-star::before {
  content: "☆";
  font-size: 20px;
  color: #ccc;
  position: absolute;
  top: -3px;
  left: 0;
}

input[type="checkbox"].fav-star:checked::before {
  content: "★";
  color: var(--orange);
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
  margin-top: 0.3rem;
}

.tag-urgent {
  background: #fffbeb;
  color: var(--orange);
  border: 1px solid #fcd34d;
}

.tag-overdue {
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fca5a5;
}

.floating-save {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: #f1f5f9;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border-radius: 50px;
}

/* Modal & Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: min(90vw, 760px);
  text-align: center;
  line-height: 1.4;
}

.toast.show {
  opacity: 1;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1001;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.text-center {
  text-align: center;
}

.loading-text {
  padding: 3rem;
  color: var(--text-light);
}

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

  .app-main {
    margin: 1rem auto;
  }

  .pagination-bar {
    align-items: stretch;
  }

  .pagination-left,
  .pagination-right {
    width: 100%;
    justify-content: space-between;
  }

  .floating-save {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .floating-save .btn-large {
    width: 100%;
  }
}
