/* ===== Barcode Label Generator - Styles ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Top Navigation ===== */
.navbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.navbar .brand svg { width: 28px; height: 28px; }
.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 40px;
  list-style: none;
}
.nav-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ===== Layout ===== */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Cards ===== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}
.card-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-900);
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-left: 4px solid var(--primary);
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.stat-card .stat-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.stat-card .stat-info p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: var(--gray-900); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--gray-200);
}
tbody td {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
tbody tr:hover { background: var(--gray-50); }

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: var(--gray-50);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone .upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  color: var(--gray-400);
}
.upload-zone:hover .upload-icon { color: var(--primary); }
.upload-zone h3 {
  font-size: 1.1rem;
  color: var(--gray-700);
  margin-bottom: 8px;
}
.upload-zone p {
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ===== Manual Entry Grid ===== */
.manual-entries {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 500px;
  overflow-y: auto;
}
.entry-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}
.entry-row input {
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.85rem;
}
.entry-row input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== Settings Form ===== */
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-input-group input[type="color"] {
  width: 44px;
  height: 38px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

/* ===== Label Preview ===== */
.preview-area {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.label-preview-box {
  border: 1px solid #ccc;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}
.label-preview-box .barcode-img {
  max-width: 100%;
  height: auto;
}
.label-preview-box .label-text {
  font-size: 12px;
  margin-top: 4px;
  color: #000;
  word-break: break-all;
}

/* ===== Page Grid ===== */
.labels-page-preview {
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 80vh;
}
.labels-grid {
  display: grid;
  gap: 0;
  padding: 10mm;
}
.label-cell {
  border: 1px dashed var(--gray-300);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  page-break-inside: avoid;
}
.label-cell .barcode-img { max-width: 95%; height: auto; }
.label-cell .lbl-text {
  font-size: 10px;
  margin-top: 2px;
  word-break: break-all;
  line-height: 1.2;
}

/* ===== Templates ===== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.template-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.template-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.template-card h4 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--gray-800);
}
.template-card p {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-warning { background: #fefce8; color: #854d0e; }

/* ===== Checkbox/Toggle ===== */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; }
  .nav-links { margin-left: 16px; gap: 0; }
  .nav-links a { padding: 8px 10px; font-size: 0.8rem; }
  .main-content { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .entry-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ===== Print Styles ===== */
@media print {
  .navbar, .no-print { display: none !important; }
  .main-content { padding: 0; max-width: 100%; }
  .labels-page-preview { border: none; max-height: none; }
  .label-cell { border: none; }
}

/* ===== Misc ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.8rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none; }