/* ====================================================
   LabTable AI - Modern Glassmorphism & Persian Design System
   ==================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --success: #10b981;
  --success-dark: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-dark: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --excel-green: #107c41;
  --excel-hover: #0b5a2f;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.88);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, Tahoma, sans-serif;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  direction: rtl;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.brand-text h1 span {
  color: var(--primary);
  font-size: 1.15rem;
  font-weight: 900;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-glow {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.15);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Main Layout Grid */
.main-layout {
  max-width: 1600px;
  margin: 1.25rem auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 1.5rem;
  flex: 1;
  width: 100%;
}

@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Panels */
.panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  position: relative;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header h2 svg {
  color: var(--primary);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-icon-circle {
  width: 64px;
  height: 64px;
  background: #e0e7ff;
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.dropzone:hover .upload-icon-circle {
  transform: scale(1.1);
  background: #c7d2fe;
}

.dropzone-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.dropzone-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 320px;
}

/* Image Preview Inside Dropzone */
.image-preview-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0.5rem;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
  color: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.preview-actions {
  display: flex;
  gap: 0.35rem;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-danger-action {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: var(--transition);
  height: 26px;
  font-family: var(--font-family);
}

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

.image-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  animation: fadeIn 0.25s ease;
}

.file-status-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-family);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-dark);
}

.btn-danger-ghost:hover {
  background: var(--danger);
}

.image-viewport {
  width: 100%;
  height: 300px;
  background: #0f172a;
  border-radius: var(--radius-sm);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.image-viewport img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
  user-select: none;
}

/* Options / Details */
.options-box details {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
}

.options-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.options-box summary:hover {
  color: var(--text-main);
}

.options-content {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.options-content label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.options-content textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary-border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: none;
}

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

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

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

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

.btn-excel:hover {
  background: var(--excel-hover);
}

/* Right Panel States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 1rem;
  text-align: center;
  padding: 3rem 1.5rem;
}

.empty-icon-box {
  width: 96px;
  height: 96px;
  background: #f1f5f9;
  color: #94a3b8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-state p {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 420px;
}

/* Loading & Scanner State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  gap: 1.25rem;
  text-align: center;
  padding: 2.5rem;
}

.scanner-container {
  width: 90px;
  height: 110px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.scanner-icon {
  color: #64748b;
}

.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #3b82f6;
  box-shadow: 0 0 12px 3px #3b82f6;
  animation: laser-scan 2s ease-in-out infinite alternate;
}

@keyframes laser-scan {
  0% { top: 5%; }
  100% { top: 92%; }
}

.loading-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.loading-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 520px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  transition: var(--transition);
}

.step-label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}

.step-line {
  flex: 1;
  height: 3px;
  background: #e2e8f0;
  margin-bottom: 1.2rem;
  transition: var(--transition);
}

.step-item.active .step-circle {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}

.step-item.active .step-label {
  color: var(--primary);
}

.step-line.active {
  background: var(--primary);
}

/* Results Content */
.results-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Metadata Card */
.meta-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.meta-card .card-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem 1rem;
}

.meta-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.meta-key {
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.meta-value {
  color: #0f172a;
  font-weight: 700;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 0.25rem;
}

.stat-negative .stat-value {
  color: #16a34a;
}

.stat-suspect .stat-value {
  color: #d97706;
}

.stat-positive .stat-value {
  color: #dc2626;
}

/* Table Toolbar */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box svg {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}

.search-box input {
  width: 100%;
  padding: 0.45rem 2.2rem 0.45rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.edit-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Data Table */
.table-responsive {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 480px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.85rem;
}

.data-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 0.75rem 0.85rem;
  border-bottom: 2px solid #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: #1e293b;
  transition: background 0.15s ease;
}

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

.data-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  background: #eff6ff;
  border-radius: 4px;
}

/* Status Badges in Table */
.tag-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.tag-negative {
  background: var(--success-bg);
  color: var(--success-dark);
  border: 1px solid var(--success-border);
}

.tag-suspect {
  background: var(--warning-bg);
  color: var(--warning-dark);
  border: 1px solid var(--warning-border);
}

.tag-positive {
  background: var(--danger-bg);
  color: var(--danger-dark);
  border: 1px solid var(--danger-border);
}

.btn-del-row {
  background: transparent;
  color: #94a3b8;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-del-row:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 520px;
  overflow: hidden;
  z-index: 1001;
  animation: modal-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.35rem;
  color: #94a3b8;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.form-control {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
