/* CadCan Design System — style.css */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap');

:root {
  --color-primary: #2D5CFF;
  --color-primary-hover: #1E4ADB;
  --color-primary-light: #E8EFFF;
  --color-bg: #F4F6FB;
  --color-surface: #FFFFFF;
  --color-text: #1F1F2B;
  --color-text-secondary: #6B7280;
  --color-border: #E5E7EB;
  --color-success: #10B981;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;
  --color-info: #3B82F6;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font-body: 'Lato', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

/* Layout */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 260px;
  height: 100vh;
  background: #1a1f36;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar .logo {
  padding: 24px 20px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}

.sidebar .nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar .nav-item.active {
  background: rgba(45,92,255,0.15);
  color: var(--color-primary);
  border-left: 3px solid var(--color-primary);
}

.sidebar .nav-item i { width: 20px; text-align: center; }

.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar .user-info {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.main-content {
  margin-left: 260px;
  padding: 32px;
  overflow-y: auto;
  min-height: 100vh;
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

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

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.stat-card .stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-card .stat-label {
  color: var(--color-text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
}

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

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary-light);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* Tables */
.table-wrapper { overflow-x: auto; }

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

.data-table th {
  background: #F9FAFB;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-secondary);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #F3F4F6;
}

.data-table tr:hover td { background: #F9FAFB; }

/* Badges */
.badge {
  display: inline-block;
  border-radius: var(--radius-lg);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
}

.badge-pending    { background: #FEF3C7; color: var(--color-warning); }
.badge-in_progress { background: var(--color-primary-light); color: var(--color-primary); }
.badge-completed  { background: #D1FAE5; color: var(--color-success); }
.badge-on_hold,
.badge-rescan_needed { background: #FEE2E2; color: var(--color-danger); }
.badge-billed     { background: #DBEAFE; color: var(--color-info); }

/* Forms */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45,92,255,0.15);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* Filters */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title { font-size: 24px; font-weight: 700; }

/* Login */
.login-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 15vh;
  min-height: 100vh;
  background: var(--color-bg);
}

.login-page .login-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-page .logo-text {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: 4px;
}

.login-page .subtitle {
  text-align: center;
  color: var(--color-text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-page .error-msg {
  background: #FEE2E2;
  color: var(--color-danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  display: none;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1a1f36;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  min-width: 240px;
  max-width: 360px;
}

.toast.toast-success { background: var(--color-success); }
.toast.toast-error   { background: var(--color-danger); }
.toast.toast-info    { background: var(--color-info); }

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

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 32px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { margin-bottom: 20px; font-size: 20px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 24px;
}

.pagination .page-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 13px;
}

.pagination .page-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--color-text-secondary);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Badge count */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Utilities */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar .logo-text,
  .sidebar .nav-item span { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 14px; }
  .sidebar { width: 72px; }
  .main-content { margin-left: 72px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
}

/* Logo */
.logo-container { padding: 20px; }
.logo-img { height: 32px; width: auto; }

/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: white; border-radius: 12px; padding: 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 1rem; }
.kpi-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: #111827; line-height: 1.2; }
.kpi-label { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }

/* Flag Grid */
.flag-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .flag-grid { grid-template-columns: repeat(2, 1fr); } }
.flag-card { background: white; border-radius: 12px; padding: 1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; text-align: center; border-left: 4px solid transparent; }
.flag-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.flag-card.danger { border-left-color: #EF4444; background: #FEF2F2; }
.flag-card.warning { border-left-color: #F59E0B; background: #FFFBEB; }
.flag-card.info { border-left-color: #6366F1; background: #EEF2FF; }
.flag-count { font-size: 2rem; font-weight: 700; line-height: 1; }
.flag-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; margin-top: 0.25rem; }
.flag-card.danger .flag-count { color: #EF4444; }
.flag-card.warning .flag-count { color: #F59E0B; }
.flag-card.info .flag-count { color: #6366F1; }

/* Flag Pills */
.flag-pills { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.flag-pill { padding: 0.375rem 0.875rem; border-radius: 9999px; border: 1px solid #d1d5db; background: white; font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all 0.15s; color: #374151; }
.flag-pill:hover { border-color: var(--color-primary); color: var(--color-primary); }
.flag-pill.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* Chart */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { background: white; border-radius: 12px; padding: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.chart-card h3 { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 600; color: #374151; }
.chart-card canvas { width: 100% !important; max-height: 300px; }

/* Date Range Bar */
.date-range-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; padding: 1rem 1.25rem; background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); flex-wrap: wrap; }
.date-range-bar label { font-size: 0.85rem; font-weight: 600; color: #374151; white-space: nowrap; }

/* Section Titles */
.section-title { font-size: 1.15rem; font-weight: 700; color: #111827; margin: 0; display: flex; align-items: center; gap: 0.75rem; }
.section-title .count-badge { background: var(--color-primary); color: white; font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 9999px; }

/* Pending Queue */
.pending-section { margin-top: 1.5rem; }
.pending-filters { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; flex-wrap: wrap; }

/* Days Waiting Colors */
.days-green { color: #10B981; font-weight: 600; }
.days-yellow { color: #F59E0B; font-weight: 600; }
.days-orange { color: #F97316; font-weight: 600; }
.days-red { color: #EF4444; font-weight: 600; }

/* Filters bar responsive */
.filters-bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }

/* Action Buttons */
.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  color: #6b7280;
  transition: color 0.15s, background 0.15s;
  font-size: 0.9rem;
}
.action-btn:hover { color: var(--color-primary); background: #f3f4f6; }
.action-btn.hold-active { color: #F59E0B; }
.action-btn.danger:hover { color: #EF4444; }
.actions-cell { display: flex; gap: 2px; align-items: center; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal-content {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.2s ease;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  color: #111827;
}
.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.modal-textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.5;
}
.modal-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Tab Bar */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 1rem;
}
.tab-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tab-btn:hover {
  color: var(--color-primary);
}
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-btn .count-badge {
  background: #e5e7eb;
  color: #374151;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}
.tab-btn.active .count-badge {
  background: var(--color-primary);
  color: white;
}

/* CSV Upload */
.csv-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}
.csv-dropzone:hover, .csv-dropzone.dragover {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.05);
}
.csv-dropzone i {
  font-size: 2rem;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}
.csv-dropzone p {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
}
.csv-preview {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.csv-preview table {
  width: 100%;
  font-size: 0.8rem;
}
.csv-preview th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}
.csv-preview td {
  padding: 0.375rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
}
.csv-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #6b7280;
}
.csv-stats strong {
  color: #111827;
}

/* Completed Section */
.completed-section { margin-top: 0; }
.completed-filters { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.completed-pagination { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; font-size: 0.85rem; color: #6b7280; }

/* Delete Confirmation Modal */
.delete-modal .modal-content {
  max-width: 420px;
}
.delete-modal .modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FEE2E2;
  color: #EF4444;
  font-size: 1.25rem;
  margin: 0 auto 1rem auto;
}
.delete-modal .modal-message {
  text-align: center;
  color: #374151;
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}
.delete-modal .modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* Enhanced Search Box */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrapper .search-icon {
  position: absolute;
  left: 10px;
  color: #9ca3af;
  font-size: 0.85rem;
  pointer-events: none;
}
.search-wrapper input {
  padding-left: 32px !important;
}

/* Clear Filters Button */
.btn-clear-filters {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-clear-filters:hover {
  border-color: #EF4444;
  color: #EF4444;
  background: #FEF2F2;
}

/* Office Analytics Section */
.analytics-section {
  margin-top: 2rem;
  margin-bottom: 1rem;
}
.analytics-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1rem;
}
.chart-grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .chart-grid-2x2 { grid-template-columns: 1fr; }
}

/* Flag pill toggle state (multi-select) */
.flag-pill.toggled {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* Action button delete variant */
.action-btn.delete-btn:hover {
  color: #EF4444;
  background: #FEF2F2;
}

/* Improved filters bar layout */
.filters-bar-enhanced {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 1rem;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.filters-bar-enhanced .filter-group {
  display: flex;
  gap: 6px;
  align-items: center;
}
.filters-bar-enhanced .filter-divider {
  width: 1px;
  height: 24px;
  background: #d1d5db;
  margin: 0 4px;
}

/* Batch Selection */
.row-select {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}
.batch-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  animation: slideDown 0.2s ease;
}
.batch-bar-danger {
  background: #FEF2F2;
  border: 1px solid #FECACA;
}
.batch-bar-info {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.data-table th:first-child,
.data-table td:first-child {
  text-align: center;
}
