/* ===== VARIABLES ===== */
:root {
  --primary: #78b943;
  --primary-dark: #5a9a2e;
  --primary-light: #a4d47a;
  --secondary: #2c3e50;
  --accent: #e67e22;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-muted: #bdc3c7;
  --border: #e1e5e9;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;
  --transition: all 0.3s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { 
  font-family: 'Inter', -apple-system, sans-serif; 
  background: var(--bg); 
  color: var(--text); 
  line-height: 1.6;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #78b943 0%, #2c3e50 100%);
  padding: 1rem;
}
.login-container {
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.login-logo h1 {
  font-size: 1.8rem;
  color: var(--secondary);
  font-weight: 700;
}
.login-logo p {
  color: var(--text-light);
  font-size: 0.9rem;
}
.login-form .form-group { margin-bottom: 1.2rem; }
.error-text { color: var(--danger); text-align: center; margin-top: 1rem; font-size: 0.85rem; }

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--secondary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-header span,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-info span { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.85rem; }
.sidebar.collapsed .nav-item i { margin-right: 0; font-size: 1.2rem; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header i { font-size: 1.5rem; color: var(--primary-light); }
.sidebar-header span { font-size: 1.2rem; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.7);
  transition: var(--transition);
  margin: 2px 8px;
  border-radius: var(--radius-sm);
}
.nav-item:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-item.active { color: white; background: var(--primary); font-weight: 500; }
.nav-item i { width: 24px; text-align: center; margin-right: 0.75rem; font-size: 1rem; }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 0.5rem; }
.user-info i { font-size: 1.5rem; }
.sidebar-footer .btn-icon { color: rgba(255,255,255,0.7); }
.sidebar-footer .btn-icon:hover { color: white; }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: var(--transition);
  min-height: 100vh;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.top-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar h2 { font-size: 1.3rem; font-weight: 600; }
.top-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.today-date { color: var(--text-light); font-size: 0.9rem; }

.content { padding: 1.5rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; padding: 0.8rem; }
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-light);
  padding: 0.4rem;
  border-radius: 50%;
  transition: var(--transition);
}
.btn-icon:hover { color: var(--primary); background: rgba(120,185,67,0.1); }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}
.form-group label i { margin-right: 0.3rem; color: var(--text-light); }
.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: var(--transition);
  background: white;
  color: var(--text);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(120,185,67,0.15);
}
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.search-box {
  position: relative;
  max-width: 350px;
}
.search-box input {
  padding-left: 2.5rem;
}
.search-box i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
  flex-shrink: 0;
}
.stat-icon.green { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-icon.blue { background: linear-gradient(135deg, var(--info), #2980b9); }
.stat-icon.orange { background: linear-gradient(135deg, var(--warning), var(--accent)); }
.stat-icon.red { background: linear-gradient(135deg, var(--danger), #c0392b); }
.stat-icon.purple { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.stat-info h4 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-info p { font-size: 0.8rem; color: var(--text-light); margin-top: 0.15rem; }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }
.table { width: 100%; }
.table th {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.table tr:hover { background: #f8faf5; }
.table tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger { background: #ffebee; color: #c62828; }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-secondary { background: #f5f5f5; color: #616161; }
.badge-primary { background: #e8f5e9; color: var(--primary-dark); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}
.modal.modal-lg { max-width: 900px; }
.modal.modal-sm { max-width: 450px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 2000; }
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

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

/* ===== PAGE SPECIFIC ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

/* Check-in page */
.checkin-container { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.checkin-search { margin-bottom: 1rem; }
.checkin-client-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0.5rem;
}
.checkin-client-card:hover { border-color: var(--primary); background: #f8faf5; }
.checkin-client-card.selected { border-color: var(--primary); background: #e8f5e9; }
.client-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--primary-light);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.client-avatar.expired { background: var(--danger); }
.client-avatar.walkin-avatar { background: var(--warning); }
.client-details h4 { font-size: 0.95rem; font-weight: 600; }
.client-details p { font-size: 0.8rem; color: var(--text-light); }

.today-checkins-list { max-height: 500px; overflow-y: auto; }
.checkin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.checkin-item:last-child { border-bottom: none; }
.checkin-item-info { display: flex; align-items: center; gap: 0.75rem; }
.checkin-item-time { font-size: 0.8rem; color: var(--text-light); }
.checkin-item-products {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* Client Profile */
.client-profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.client-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  flex-shrink: 0;
}
.client-profile-info h2 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.client-profile-info p { color: var(--text-light); font-size: 0.9rem; }

.tab-nav, .tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Charts */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-state p { font-size: 1rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .checkin-container { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .modal { max-width: 100%; margin: 0.5rem; }
  .page-header { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  html { font-size: 13px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ===== LOADING ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EVALUATION COMPARISON ===== */
.eval-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.eval-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #f8f9fa;
  border-radius: var(--radius-sm);
}
.eval-metric-label { font-size: 0.85rem; color: var(--text-light); }
.eval-metric-value { font-weight: 600; }
.eval-metric-diff { font-size: 0.75rem; margin-left: 0.3rem; }
.eval-metric-diff.positive { color: var(--success); }
.eval-metric-diff.negative { color: var(--danger); }

/* Quick actions */
.quick-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-width: 120px;
}
.quick-action-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-action-btn i { font-size: 1.5rem; color: var(--primary); }
.quick-action-btn span { font-size: 0.8rem; font-weight: 500; }
