/* =====================================================
   reportTracker.css - Report Manager Page Styles
   ธีม: Clean White + Green Accent
   ===================================================== */

/* ── VARIABLES ── */
:root {
  --primary:      #f8fafc;
  --surface:      #ffffff;
  --surface2:     #f1f5f9;
  --surface3:     #e2e8f0;
  --accent:       #10b981;
  --accent-light: #d1fae5;
  --accent-dark:  #059669;
  --accent2:      #f59e0b;
  --accent2-light:#fef3c7;
  --accent3:      #ef4444;
  --blue:         #3b82f6;
  --purple:       #8b5cf6;
  --text:         #111827;
  --text-muted:   #6b7280;
  --text-light:   #9ca3af;
  --border:       #e5e7eb;
  --border-accent: rgba(16,185,129,0.25);
  --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.1);
  --radius:       12px;
  --radius-sm:    8px;
  --transition:   0.15s ease;
  --unread-bg:    #fef3c7;
  --unread-border: #f59e0b;
}

/* ── BASE ── */
* { box-sizing: border-box; }

body {
  background: var(--primary);
  font-family: 'Kanit', sans-serif;
  color: var(--text-muted);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-header p {
  color: var(--text-muted);
  margin: 4px 0 0;
  font-size: 14px;
}

/* ── DATE RANGE SECTION ── */
.date-range-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.date-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.date-range-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.date-range-title .icon {
  font-size: 1.1rem;
}

.date-range-label {
  background: var(--accent-light);
  color: var(--accent-dark);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.date-range-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.date-input-group label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.date-input-group input[type="date"] {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.date-input-group input[type="date"]:focus {
  outline: none;
  background: var(--accent-light);
}

.quick-range-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.quick-range-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  transition: all var(--transition);
}

.quick-range-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

.quick-range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
}

/* ── SUMMARY CARDS ── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sum-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.sum-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-accent);
}

.sum-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sum-content {
  flex: 1;
}

.sum-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.sum-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.card-hint {
  font-size: 12px;
  background: var(--surface2);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ── SALES GRID ── */
.sales-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.sales-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.sales-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.sales-card.active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.sales-card.has-unread::before {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  background: var(--accent2);
  border-radius: 50%;
}

.sales-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.sales-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sales-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── FILTER SECTION ── */
.filter-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.filter-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.filter-group select,
.filter-group input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── BUTTONS ── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-export {
  background: transparent;
  color: var(--accent2);
  border: 1px solid rgba(245,158,11,0.3);
}

.btn-export:hover {
  background: var(--accent2-light);
  border-color: var(--accent2);
}

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

.btn-success:hover {
  background: var(--accent-dark);
}

/* ── REPORTS CONTAINER ── */
.reports-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--surface);
}

.report-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.report-item.unread {
  background: var(--unread-bg);
  border-color: var(--unread-border);
  border-left: 3px solid var(--accent2);
}

.report-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.report-info {
  flex: 1;
  min-width: 0;
}

.report-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.report-sales {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.report-date {
  font-size: 13px;
  color: var(--text-muted);
}

.report-details {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.report-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-status {
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-unread {
  background: var(--accent2-light);
  color: #b45309;
}

.badge-read {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* ── PAGINATION ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}

.page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ── MODAL ── */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  z-index: 1;
  color: var(--text-muted);
}

.close-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-badges {
  display: flex;
  gap: 6px;
}

.modal-body {
  padding: 24px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.info-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.info-section {
  margin-bottom: 24px;
}

.note-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.comment-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.comment-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}

.comments-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.comment-item {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 10px;
}

.comment-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 13px;
}

.comment-author {
  font-weight: 600;
  color: var(--accent-dark);
}

.comment-date {
  color: var(--text-light);
}

.comment-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

#commentInput {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

#commentInput:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── LOADING ── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── FOOTER ── */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
  font-size: 13px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .date-range-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .date-range-controls {
    width: 100%;
  }

  .date-input-group {
    flex: 1;
    min-width: 140px;
  }

  .quick-range-btns {
    width: 100%;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .sales-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .report-item {
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .report-status {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
}