/* ==========================================================================
   CSS Design System & Stylesheet for QR Flow
   ========================================================================== */

/* --- CSS Custom Variables (Design Tokens) --- */
:root {
  --font-family: 'Inter', sans-serif;
  
  /* Theme Transitions */
  --transition-speed: 0.3s;
  --transition-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* Shared Sizes & Spacings */
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.15);
}

/* --- Dark Theme Variables (Default) --- */
html[data-theme="dark"] {
  --bg-app: #080f1e;
  --bg-surface: #0f172a;
  --bg-surface-glass: rgba(15, 23, 42, 0.75);
  --bg-input: #1e293b;
  --border-color: #334155;
  --border-glow: rgba(59, 130, 246, 0.15);
  
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.15);
  
  --secondary: #06b6d4;
  --secondary-hover: #0891b2;
  
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --danger-hover: #dc2626;

  --placeholder-color: #475569;
  --scroll-thumb: #334155;
}

/* --- Light Theme Variables --- */
html[data-theme="light"] {
  --bg-app: #f0f7ff;
  --bg-surface: #ffffff;
  --bg-surface-glass: rgba(255, 255, 255, 0.85);
  --bg-input: #f8fafc;
  --border-color: #cbd5e1;
  --border-glow: rgba(29, 78, 216, 0.08);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-inverse: #ffffff;
  
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: rgba(29, 78, 216, 0.08);
  
  --secondary: #0891b2;
  --secondary-hover: #0e7490;
  
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.08);
  
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.08);
  
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --danger-hover: #b91c1c;

  --placeholder-color: #94a3b8;
  --scroll-thumb: #cbd5e1;
}

/* --- Base Resets & Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 10px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

.app-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Typography Helpers --- */
span.required {
  color: var(--danger);
  margin-left: 2px;
}

.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.bg-primary-soft { background-color: var(--primary-soft); }
.bg-success-soft { background-color: var(--success-soft); }
.bg-warning-soft { background-color: var(--warning-soft); }

/* --- App Header & Logo --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  font-size: 2.2rem;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 8px var(--border-glow));
}

.fa-spin-hover:hover {
  animation: fa-spin 2s linear infinite;
}

.logo-text h1 {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.logo-text h1 span {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Header Actions & Icon Buttons --- */
.btn-icon {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-speed) var(--transition-bounce);
}

.btn-icon:hover {
  transform: scale(1.08) rotate(15deg);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 12px var(--border-glow);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* --- Tab Navigation --- */
.app-nav {
  display: flex;
  gap: 0.75rem;
  background-color: var(--bg-surface);
  padding: 0.4rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  align-self: flex-start;
}

.nav-tab {
  background: transparent;
  border: none;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.6rem 1.2rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-speed);
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* --- Cards System (Glassmorphism) --- */
.card {
  background-color: var(--bg-surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.05);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* --- Grid System --- */
.grid-two-columns {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .grid-two-columns {
    grid-template-columns: 1fr;
  }
}

.grid-two-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.grid-three-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .grid-two-inputs, .grid-three-inputs {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* --- Form Fields & Inputs --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group textarea,
.form-group select,
.form-group input[type="text"] {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 1rem;
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-speed);
}

.form-group textarea:focus,
.form-group select:focus,
.form-group input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--border-glow);
  background-color: var(--bg-surface);
}

.form-group textarea::placeholder {
  color: var(--placeholder-color);
}

.input-counter {
  align-self: flex-end;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Accordion Component */
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 0.75rem 0;
  border-top: 1px dashed var(--border-color);
  margin-top: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color var(--transition-speed);
  user-select: none;
}

.accordion-header:hover {
  color: var(--text-main);
}

.accordion-header .arrow-icon {
  transition: transform var(--transition-speed) var(--transition-bounce);
}

.accordion-header.active .arrow-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-speed) ease-out, opacity var(--transition-speed);
  opacity: 0;
  display: flex;
  flex-direction: column;
}

.accordion-content.show {
  max-height: 500px; /* high enough limit */
  opacity: 1;
  padding-top: 0.5rem;
}

/* Custom Color Picker Component */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.25rem 0.5rem;
  gap: 0.5rem;
  transition: border-color var(--transition-speed);
}

.color-picker-wrapper:focus-within {
  border-color: var(--primary);
}

.color-picker-wrapper input[type="color"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: 50%;
}
.color-picker-wrapper input[type="color"]::-moz-color-swatch {
  border: 1px solid var(--border-color);
  border-radius: 50%;
}

.color-picker-wrapper input[type="text"] {
  border: none !important;
  background: transparent !important;
  padding: 0.25rem 0 !important;
  font-family: monospace;
  font-size: 0.9rem;
  width: 100%;
}

/* Custom Range Input */
.range-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 46px; /* align with input fields height */
}

.range-wrapper input[type="range"] {
  flex-grow: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-wrapper span {
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

/* --- Buttons --- */
.btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-speed) var(--transition-bounce);
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-lg {
  font-size: 1.05rem;
  padding: 0.9rem 1.75rem;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.25);
}
.btn-secondary:hover {
  background-color: var(--secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}

.btn-success {
  background-color: var(--success);
  color: var(--text-inverse);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
  background-color: var(--success);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

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

.btn-outline-danger {
  background-color: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--danger);
}
.btn-outline-danger:hover {
  border-color: var(--danger);
  color: var(--text-inverse);
  background-color: var(--danger);
}

/* --- QR Preview Box --- */
.qr-preview-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-grow: 1;
  padding: 1.5rem 0;
  min-height: 280px;
}

.qr-output-box {
  background-color: #ffffff; /* QR codes usually need high contrast background */
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  width: 240px;
  height: 240px;
  position: relative;
  border: 1px solid var(--border-color);
  transition: transform var(--transition-speed) var(--transition-bounce);
}

html[data-theme="dark"] .qr-output-box {
  /* In dark mode, we keep QR background white for scan reliability, but can add subtle border */
  border-color: rgba(255, 255, 255, 0.1);
}

.qr-output-box:hover {
  transform: scale(1.03);
}

.qr-output-box canvas, .qr-output-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b; /* dark gray for readability on light QR box background */
  text-align: center;
  gap: 0.75rem;
  padding: 1rem;
}

.placeholder-icon {
  font-size: 3rem;
  color: #cbd5e1;
  animation: pulse-placeholder 2s infinite ease-in-out;
}

@keyframes pulse-placeholder {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

.qr-placeholder p {
  font-size: 0.85rem;
  font-weight: 500;
}

.preview-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.preview-actions button {
  flex: 1;
  min-width: 130px;
}

/* --- Batch Tab (CSV Drag and Drop) --- */
.drag-drop-card {
  border: 2px dashed var(--border-color);
  background-color: var(--bg-surface-glass);
  cursor: pointer;
  transition: all var(--transition-speed);
  position: relative;
  display: block;
  text-align: center;
  padding: 3rem 1.5rem;
  user-select: none;
}

.drag-drop-card:hover, .drag-drop-card.dragover {
  border-color: var(--primary);
  background-color: var(--primary-soft);
}

.file-input-hidden {
  display: none !important;
}

.drag-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  pointer-events: none;
}

.csv-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.csv-preview-table th {
  background: var(--bg-card);
  padding: 8px 12px;
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  text-align: left;
}

.csv-preview-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: monospace;
  font-size: 0.82rem;
}

.csv-preview-table tr:hover {
  background: var(--bg-input);
}

.drag-icon {
  font-size: 3.5rem;
  color: var(--text-muted);
  transition: color var(--transition-speed), transform var(--transition-speed) var(--transition-bounce);
}

.drag-drop-card:hover .drag-icon, .drag-drop-card.dragover .drag-icon {
  color: var(--primary);
  transform: translateY(-8px);
}

.drag-drop-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.drag-drop-content p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.file-limits {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  opacity: 0.7;
}

/* Mapping Card & File Info */
.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.file-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--primary);
}

.mapping-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-color);
}

/* Progress Section */
.card-progress {
  text-align: center;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.progress-bar-bg {
  height: 12px;
  background-color: var(--bg-input);
  border-radius: 6px;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  border-radius: 6px;
  transition: width 0.15s ease-out;
}

.progress-eta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-actions {
  margin-top: 0.5rem;
}

/* Batch Results Stats Dashboard */
.batch-results-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

/* Results Gallery */
.card-results-gallery {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-gallery-header .card-title {
  margin-bottom: 0;
}

.gallery-actions {
  display: flex;
  gap: 0.6rem;
}

.qr-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.gallery-item {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  text-align: center;
  transition: all var(--transition-speed);
}

.gallery-item:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.gallery-item-qr-box {
  background-color: #ffffff;
  border-radius: var(--border-radius-sm);
  padding: 0.4rem;
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-item-qr-box img, .gallery-item-qr-box canvas {
  max-width: 100%;
  max-height: 100%;
}

.gallery-item-label {
  font-size: 0.75rem;
  font-weight: 600;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-main);
}

.gallery-item-tooltip {
  visibility: hidden;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background-color: #0f172a;
  color: #ffffff;
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  white-space: normal;
  max-width: 180px;
  z-index: 10;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  pointer-events: none;
}

.gallery-item:hover .gallery-item-tooltip {
  visibility: visible;
  opacity: 0.95;
}

.gallery-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.pagination-info {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* --- Tabs View Toggling --- */
.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-panel.active {
  display: block;
}

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

/* --- Modals / Overlays --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1.5rem;
  animation: fadeInModal 0.25s ease-out;
}

.modal-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  max-width: 600px;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUpModal 0.3s var(--transition-bounce);
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpModal {
  from { transform: translateY(40px); }
  to { transform: translateY(0); }
}

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

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-speed);
}

.modal-close-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.print-preview-modal-box {
  background-color: var(--bg-input);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.print-preview-modal-box .placeholder-icon {
  font-size: 2.2rem;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-input);
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 1.5rem;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}

/* --- Print Only Elements --- */
.print-only {
  display: none;
}

/* ==========================================================================
   PRINT STYLES (@media print)
   ========================================================================== */
@media print {
  /* Hide standard web structure completely */
  .no-print, 
  .no-print * {
    display: none !important;
  }
  
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
    margin: 0;
    padding: 0;
  }
  
  .print-only {
    display: block !important;
  }

  /* Sheet Layout Configurations */
  .print-page {
    page-break-after: always;
    margin: 0;
    padding: 0;
    box-shadow: none;
    box-sizing: border-box;
    display: grid;
    /* Grid structure will be customized inline by JS for each layout */
    justify-items: center;
    align-items: center;
  }
  
  .print-page:last-child {
    page-break-after: avoid;
  }

  /* Universal Sticker/Label Styling */
  .print-label {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    background-color: #ffffff;
    border: 1px dashed #dddddd; /* subtle dashed border for cutting aid */
    padding: 4px;
    width: 100%;
    height: 100%;
  }

  .print-label-title {
    font-size: 8pt;
    font-weight: 700;
    margin-bottom: 2px;
    text-transform: uppercase;
    color: #000000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 90%;
  }

  .print-label-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    /* sizing handled by JS dynamically */
  }

  .print-label-qr img, .print-label-qr canvas {
    max-width: 100%;
    max-height: 100%;
  }

  .print-label-text {
    font-size: 7pt;
    font-family: monospace;
    color: #333333;
    margin-top: 2px;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* max 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 95%;
  }
}

/* ==========================================================================
   SMTP Server & Email Dispatch Components
   ========================================================================== */

/* --- Status Badge in Header --- */
.smtp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-speed);
}

.smtp-status-badge:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

.smtp-status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  display: inline-block;
  transition: background-color var(--transition-speed);
}

.smtp-status-badge.status-connected {
  border-color: rgba(16, 185, 129, 0.4);
  background-color: var(--success-soft);
  color: var(--success);
}

.smtp-status-badge.status-connected .status-dot {
  background-color: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: pulse-dot 2s infinite;
}

.smtp-status-badge.status-disconnected {
  border-color: rgba(245, 158, 11, 0.4);
  background-color: var(--warning-soft);
  color: var(--warning);
}

.smtp-status-badge.status-disconnected .status-dot {
  background-color: var(--warning);
}

.smtp-status-badge.status-checking {
  border-color: var(--border-color);
  color: var(--text-muted);
}

.smtp-status-badge.status-checking .status-dot {
  background-color: var(--primary);
  animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* --- Single & Batch Email Options --- */
.email-hint-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--primary-soft);
  color: var(--primary);
  padding: 0.65rem 0.9rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  margin-top: 0.6rem;
  line-height: 1.4;
}

.email-hint-box code {
  background-color: rgba(0, 0, 0, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
}

.email-settings-panel {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
  transition: border-color var(--transition-speed);
}

.email-settings-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.email-settings-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

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

.email-settings-details {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Switch Toggle Styling --- */
.custom-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.custom-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.custom-toggle input:checked + .toggle-slider {
  background-color: var(--primary);
}

.custom-toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* --- Gallery Item Email Info & Status --- */
.gallery-item-email-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
}

.gallery-item-email-badge.badge-sent {
  background-color: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.gallery-item-email-badge.badge-failed {
  background-color: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.gallery-item-email-badge.badge-pending {
  background-color: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.gallery-item-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 6px;
  width: 100%;
}

.btn-card-action {
  flex: 1;
  padding: 4px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-card-action:hover {
  background-color: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* --- Email Preview Modal Styling --- */
.modal-container.modal-lg {
  max-width: 680px;
}

.email-meta-header {
  background-color: var(--bg-input);
  border-radius: var(--border-radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--border-color);
}

.email-meta-header strong {
  color: var(--text-main);
  width: 60px;
  display: inline-block;
}

.email-html-wrapper {
  background-color: #f4f6f9;
  border-radius: var(--border-radius-md);
  padding: 1rem;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

/* --- Server Info Modal Helpers --- */
.server-active-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: var(--success-soft);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.2rem;
}

.server-warning-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: var(--warning-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 1.2rem;
}

.server-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.server-info-table td {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border-color);
}

.command-intro {
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 0.6rem;
}

.code-terminal-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #0b1120;
  color: #38bdf8;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  font-family: monospace;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  border: 1px solid #1e293b;
}

.server-help-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  background-color: var(--bg-input);
  padding: 0.75rem;
  border-radius: var(--border-radius-sm);
}

/* --- Email Logs & Error Diagnostics Modal Styles --- */
.badge-counter {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 9999px;
  padding: 1px 6px;
  line-height: 1.2;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.logs-tabs-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.logs-tab-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.logs-tab-btn:hover {
  background: var(--bg-surface-glass);
  color: var(--text-main);
}

.logs-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.logs-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  gap: 0.35rem;
}

.filter-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.logs-tools {
  display: flex;
  gap: 0.4rem;
}

.logs-entries-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 4px;
}

.log-entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.2s;
}

.log-entry-card.is-error {
  border-left: 4px solid #ef4444;
  background: rgba(239, 68, 68, 0.03);
}

.log-entry-card.is-success {
  border-left: 4px solid #10b981;
  background: rgba(16, 185, 129, 0.03);
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.log-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
}

.log-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.log-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.log-time {
  color: var(--text-muted);
  font-family: monospace;
  font-size: 0.75rem;
}

.log-recipient {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.log-recipient small {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 0.35rem;
}

.log-error-desc {
  font-size: 0.82rem;
  color: #ef4444;
  font-family: monospace;
  background: rgba(239, 68, 68, 0.08);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  word-break: break-word;
}

.log-suggestion {
  font-size: 0.8rem;
  color: var(--text-main);
  background: var(--bg-surface-glass);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.log-suggestion i {
  color: #f59e0b;
  margin-top: 2px;
}

.server-logs-pre {
  background: #0f172a;
  color: #f8fafc;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  padding: 1rem;
  border-radius: var(--border-radius-sm);
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #1e293b;
}

.server-log-path {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-logs {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
