/* ═══════════════════════════════════════════════════
   Face Recognition System - Global Styles
   Dark theme, professional UI
═══════════════════════════════════════════════════ */

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --border:      #30363d;
  --accent:      #58a6ff;
  --accent-dim:  #1f6feb;
  --green:       #3fb950;
  --green-dim:   #196c2e;
  --red:         #f85149;
  --red-dim:     #6e1a1a;
  --yellow:      #d29922;
  --yellow-dim:  #3d2b00;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --radius:      8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Navigation ─────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 32px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand .icon { font-size: 1.4rem; }

.navbar-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.navbar-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text);
  background: var(--surface2);
}

.navbar-links a.active {
  color: var(--accent);
}

.navbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.live { background: var(--green); animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Main Layout ────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ─── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
}

/* ─── Stat Cards ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .value {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card.blue   .value { color: var(--accent); }
.stat-card.green  .value { color: var(--green); }
.stat-card.red    .value { color: var(--red); }
.stat-card.yellow .value { color: var(--yellow); }

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: border-color 0.15s;
  font-family: inherit;
}

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

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--accent-dim);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); color: #000; }

.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green-dim);
}
.btn-success:hover:not(:disabled) { background: var(--green); color: #000; }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red-dim);
}
.btn-danger:hover:not(:disabled) { background: var(--red); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }

.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

/* ─── Camera ─────────────────────────────────────── */
.camera-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
}

.camera-container video,
.camera-container canvas {
  display: block;
  width: 100%;
}

.camera-container canvas.overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.camera-container .camera-label {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0,0,0,0.7);
  color: var(--green);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 1px;
  border: 1px solid var(--green);
}

.camera-container .fps-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.7);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: monospace;
}

/* ─── Badge ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-blue   { background: rgba(31,111,235,0.2); color: var(--accent); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }

/* ─── Table ──────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead {
  background: var(--surface2);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: 12px 16px;
  vertical-align: middle;
}

/* ─── Alert/Toast ────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  cursor: pointer;
}

.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--yellow); }
.toast.info    { border-left: 4px solid var(--accent); }

.toast .toast-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.toast .toast-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.toast .toast-msg   { color: var(--text-muted); font-size: 0.82rem; }

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

/* ─── Progress ───────────────────────────────────── */
.progress {
  background: var(--surface2);
  border-radius: 20px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent-dim);
  border-radius: 20px;
  transition: width 0.3s;
}

.progress-bar.success { background: var(--green); }

/* ─── Grid Layout ────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .navbar-links a span { display: none; }
}

/* ─── Face Thumbnail List ────────────────────────── */
.face-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.face-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  position: relative;
}

.face-card img,
.face-card .face-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: block;
  object-fit: cover;
  background: var(--border);
}

.face-card .face-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.face-card .face-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.face-card .face-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.face-card .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--red-dim);
  color: var(--red);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.face-card:hover .delete-btn { display: flex; }

/* ─── Loading Overlay ────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--radius);
  z-index: 10;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Misc ───────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-green    { color: var(--green); }
.text-red      { color: var(--red); }
.text-accent   { color: var(--accent); }
.text-center   { text-align: center; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.gap-8         { gap: 8px; }
.flex          { display: flex; }
.flex-between  { display: flex; justify-content: space-between; align-items: center; }
.flex-center   { display: flex; align-items: center; gap: 8px; }
.empty-state   { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.divider       { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
