/* ============================================================
   ZAFSEL BILLING — Component Styles
   ============================================================ */

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 9px 18px; border-radius: var(--radius-md); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); transition: all var(--dur-fast) ease; white-space: nowrap;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0.1);
  opacity: 0; transition: opacity var(--dur-fast); border-radius: inherit;
}
.btn:active::after { opacity: 1; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.3); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.4); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,0.15); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 24px; font-size: var(--fs-lg); border-radius: var(--radius-lg); }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-md); }
.btn-icon-sm { width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm); font-size: var(--fs-sm); }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: var(--sp-5); animation: fadeIn 0.3s var(--ease-out); transition: box-shadow var(--dur-normal) ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-flat { box-shadow: none; }
.card-flat:hover { box-shadow: none; }

/* ── Stat Cards (Dashboard) ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-5); margin-bottom: var(--sp-6); }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: var(--sp-5); position: relative; overflow: hidden; transition: all var(--dur-normal) ease;
  animation: fadeInUp 0.4s var(--ease-out) both;
}
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 60ms; }
.stat-card:nth-child(3) { animation-delay: 120ms; }
.stat-card:nth-child(4) { animation-delay: 180ms; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-gradient); opacity: 0; transition: opacity var(--dur-normal);
}
.stat-card:hover::before { opacity: 1; }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center;
  justify-content: center; font-size: 20px; margin-bottom: var(--sp-3);
}
.stat-card .stat-icon.blue { background: var(--accent-light); }
.stat-card .stat-icon.green { background: var(--success-bg); }
.stat-card .stat-icon.orange { background: var(--warning-bg); }
.stat-card .stat-icon.red { background: var(--danger-bg); }
.stat-card .stat-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: var(--fw-medium); }
.stat-card .stat-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: var(--fw-bold); margin: var(--sp-1) 0; animation: countUp 0.5s var(--ease-out); }
.stat-card .stat-change { font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ── Form Elements ── */
.form-group { margin-bottom: var(--sp-3); }
.form-label { display: block; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); margin-bottom: var(--sp-1); text-transform: uppercase; letter-spacing: 0.05em; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px; background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); color: var(--text-primary); font-size: var(--fs-sm);
  transition: all var(--dur-fast) ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); background: var(--bg-secondary); }
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; gap: var(--sp-3); }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-input-sm { padding: 6px 8px; font-size: var(--fs-xs); }

/* ── Section Titles ── */
.section-title {
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2); border-bottom: 2px solid var(--border-color);
  display: flex; align-items: center; gap: var(--sp-2);
}
.section-title::before {
  content: ''; display: inline-block; width: 3px; height: 13px;
  background: var(--accent-gradient); border-radius: 2px;
}

/* ── Items Grid (invoice form) ── */
.items-header {
  display: grid; grid-template-columns: 2fr 1fr 0.6fr 0.6fr 0.8fr 0.6fr 0.8fr 0.5fr 1fr 28px;
  gap: 4px; margin-bottom: var(--sp-2);
}
.items-header span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: var(--fw-semibold); }
.item-row {
  display: grid; grid-template-columns: 2fr 1fr 0.6fr 0.6fr 0.8fr 0.6fr 0.8fr 0.5fr 1fr 28px;
  gap: 4px; padding: var(--sp-2) 0; border-bottom: 1px solid var(--border-color); animation: fadeIn 0.2s ease;
}
.item-row input { padding: 5px 6px; font-size: 11px; }
.item-row .item-amount { display: flex; align-items: center; font-size: 11px; color: var(--accent); font-weight: var(--fw-semibold); padding: 0 4px; }
.remove-row-btn {
  width: 26px; height: 26px; border-radius: var(--radius-sm); display: flex; align-items: center;
  justify-content: center; color: var(--text-muted); font-size: 11px; transition: all var(--dur-fast) ease; align-self: center;
}
.remove-row-btn:hover { background: var(--danger-bg); color: var(--danger); }
.add-item-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); width: 100%; border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md); color: var(--text-muted); font-size: var(--fs-xs); cursor: pointer;
  transition: all var(--dur-normal) ease; margin-top: var(--sp-3); font-weight: var(--fw-medium);
}
.add-item-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Tax Summary ── */
.tax-summary {
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: var(--sp-4); margin-top: var(--sp-4);
}
.tax-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.tax-row.total {
  border-top: 2px solid var(--border-color); margin-top: var(--sp-2); padding-top: var(--sp-3);
  font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--accent);
}

/* ── Actions Bar ── */
.bill-actions {
  display: flex; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); margin-top: var(--sp-5); flex-wrap: wrap;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
  animation: fadeIn 0.2s ease; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); padding: var(--sp-6); width: 90%; max-width: 560px;
  max-height: 85vh; overflow-y: auto; animation: fadeInScale 0.25s var(--ease-out);
  box-shadow: var(--shadow-lg);
}
.modal h2 { font-family: var(--font-display); font-size: var(--fs-xl); margin-bottom: var(--sp-5); }
.modal-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-5); }

/* ── Toast ── */
.toast-container { position: fixed; top: var(--sp-5); right: var(--sp-5); z-index: 9999; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  padding: var(--sp-3) var(--sp-5); border-radius: var(--radius-md); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); animation: slideIn 0.3s var(--ease-out); min-width: 260px;
  box-shadow: var(--shadow-lg); backdrop-filter: blur(8px);
}
.toast-success { background: #166534; color: #bbf7d0; }
.toast-error { background: #991b1b; color: #fecaca; }
.toast-warning { background: #92400e; color: #fde68a; }
.toast-info { background: #1e40af; color: #bfdbfe; }

/* ── Saved List ── */
.saved-list { max-height: 240px; overflow-y: auto; margin-bottom: var(--sp-4); }
.saved-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); margin-bottom: var(--sp-2); font-size: var(--fs-sm);
  cursor: pointer; transition: all var(--dur-fast) ease;
}
.saved-item:hover { border-color: var(--accent); background: var(--accent-light); }
.saved-item .del-btn { color: var(--text-muted); font-size: 12px; padding: 4px 8px; border-radius: var(--radius-sm); }
.saved-item .del-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* ── Logo Upload ── */
.logo-upload-area {
  width: 80px; height: 80px; border: 2px dashed var(--border-color); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  overflow: hidden; position: relative; background: var(--bg-tertiary); flex-shrink: 0;
  transition: border-color var(--dur-fast) ease;
}
.logo-upload-area:hover { border-color: var(--accent); }
.logo-upload-area img { width: 100%; height: 100%; object-fit: contain; }
.logo-upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.logo-upload-area .placeholder { font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.3; }

/* ── Collapsible sections ── */
.section-toggle { cursor: pointer; user-select: none; }
.section-toggle::after { content: '▾'; margin-left: auto; font-size: 10px; transition: transform 0.2s; }
.section-toggle.collapsed::after { transform: rotate(-90deg); }
.section-body { overflow: hidden; transition: max-height 0.3s ease; }
.section-body.collapsed { max-height: 0 !important; padding: 0; }

/* ── Preview Overlay (full-screen) ── */
.preview-overlay {
  position: fixed; inset: 0; z-index: 2000; background: var(--bg-primary);
  display: flex; flex-direction: column; animation: fadeIn 0.25s var(--ease-out);
}
.preview-overlay-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-6); background: var(--bg-glass);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.preview-overlay-body { flex: 1; overflow: auto; display: flex; justify-content: center; padding: var(--sp-6); background: var(--bg-tertiary); }
.preview-overlay-paper { background: #fff; box-shadow: 0 8px 40px rgba(0,0,0,0.15); width: fit-content; height: fit-content; }

/* ── Data Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 2px solid var(--border-color);
}
.data-table td {
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
.data-table tbody tr { transition: background var(--dur-fast) ease; }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ── Status Badge ── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: 0.02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ── Search Input ── */
.search-input-wrap {
  position: relative; display: flex; align-items: center;
}
.search-input-wrap .search-icon {
  position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.search-input-wrap input {
  padding: 9px 12px 9px 36px; background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); color: var(--text-primary); font-size: var(--fs-sm);
  width: 280px; transition: all var(--dur-fast) ease;
}
.search-input-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); width: 320px; }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: var(--sp-4); opacity: 0.5; }
.empty-state h3 { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--text-secondary); margin-bottom: var(--sp-2); }
.empty-state p { font-size: var(--fs-sm); max-width: 360px; margin: 0 auto; }

/* ── Chart placeholder ── */
.chart-container { position: relative; height: 240px; }
.chart-bar-group { display: flex; align-items: flex-end; gap: 6px; height: 100%; padding: 0 var(--sp-4); }
.chart-bar {
  flex: 1; background: var(--accent-gradient); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px; transition: all var(--dur-normal) var(--ease-out); position: relative; cursor: pointer;
}
.chart-bar:hover { opacity: 0.85; transform: scaleY(1.02); transform-origin: bottom; }
.chart-bar .chart-tooltip {
  position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  padding: 2px 8px; font-size: 10px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--dur-fast);
}
.chart-bar:hover .chart-tooltip { opacity: 1; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-5); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Share dropdown ── */
.share-menu {
  position: absolute; top: 100%; right: 0; margin-top: var(--sp-2);
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: var(--sp-2); min-width: 200px;
  box-shadow: var(--shadow-lg); z-index: 50; animation: fadeIn 0.15s ease;
}
.share-menu-item {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md); font-size: var(--fs-sm); color: var(--text-secondary);
  cursor: pointer; transition: all var(--dur-fast) ease;
}
.share-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.share-menu-item .share-icon { width: 20px; text-align: center; }
