/* style.css — SuperBill Generator */

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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #eff6ff;
  --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;
  --red: #dc2626;
  --red-light: #fef2f2;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Top Nav ── */
.top-nav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.top-nav .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--blue);
  text-decoration: none;
  margin-right: 32px;
}
.top-nav a {
  text-decoration: none;
  color: var(--gray-500);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 16px 12px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.top-nav a:hover { color: var(--gray-800); }
.top-nav a.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Main Content ── */
#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* ── Page Headers ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger {
  background: #fff;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: var(--red-light); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-icon {
  padding: 5px 8px;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--gray-500);
  font-size: 0.8rem;
}
.btn-icon:hover { background: var(--gray-100); color: var(--blue); }
.btn-danger-icon { color: var(--red); }
.btn-danger-icon:hover { background: var(--red-light); color: var(--red); }

/* ── Forms ── */
.form-section {
  margin-bottom: 24px;
}
.form-section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-200);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ── Searchable Dropdown ── */
.searchable-dropdown {
  position: relative;
}
.searchable-dropdown input {
  width: 100%;
}
.dropdown-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  z-index: 2;
}
.dropdown-clear:hover { color: var(--gray-700); }
.dropdown-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 50;
}
.dropdown-list.open { display: block; }
.dropdown-item {
  padding: 7px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.dropdown-item:hover, .dropdown-item.highlighted {
  background: var(--blue-light);
}
.dropdown-item .code { font-weight: 600; margin-right: 6px; }
.dropdown-item .category {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-left: 4px;
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--gray-200);
}
.data-table td {
  padding: 10px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--gray-50); }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .actions .btn-icon { margin-left: 4px; }

/* ── Filter Row ── */
.filter-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-row .form-group { min-width: 150px; }
.filter-row select, .filter-row input {
  padding: 7px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
}

/* ── Search Box ── */
.search-box {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 16px;
}
.search-box:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* ── Messages ── */
.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}
.msg.show { display: block; }
.msg-success { background: var(--green-light); color: var(--green); border: 1px solid #bbf7d0; }
.msg-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }

/* ── Back Link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gray-500);
  font-size: 0.85rem;
  text-decoration: none;
  margin-bottom: 14px;
}
.back-link:hover { color: var(--blue); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
  font-size: 0.95rem;
}

/* ── Checkbox in table ── */
.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--blue);
}

/* ── Batch Bar ── */
.batch-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--blue-light);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
}
.batch-bar.show { display: flex; }
.batch-bar span { color: var(--blue); font-weight: 500; }

/* ── Logo Preview ── */
.logo-preview {
  max-width: 80px;
  max-height: 80px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-top: 6px;
}
.logo-preview-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.logo-preview-container .btn-sm { flex-shrink: 0; }

/* ── Settings ── */
.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.settings-section p {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #app { padding: 24px 16px 48px; }
  .form-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

@media (max-width: 640px) {
  .top-nav { padding: 0 12px; }
  .top-nav a { padding: 14px 8px; font-size: 0.82rem; }
  #app { padding: 16px 12px 40px; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filter-row { flex-direction: column; }
}
