/* INVOBILLING — components.css : buttons, inputs, cards, tables, badges, etc */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  transition: all .15s ease;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; gap: 6px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }
.btn-icon.btn-sm { padding: 6px; width: 32px; height: 32px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
[data-theme="dark"] .btn-primary { color: var(--bg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-accent {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(1.05); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--border-strong); }
.btn-outline-primary:hover { background: var(--bg-hover); }
[data-theme="dark"] .btn-outline-primary { color: var(--text); }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-label .opt { color: var(--text-subtle); font-weight: 500; font-size: 11px; }
.field-hint { font-size: 11.5px; color: var(--text-muted); }
.field-error { font-size: 11.5px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input-sm { padding: 6px 9px; font-size: 12.5px; }
.input[readonly] { background: var(--bg-soft); color: var(--text-muted); cursor: not-allowed; }
.input.error, .select.error, .textarea.error { border-color: var(--danger); }

.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

/* Checkbox & radio */
.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
}
.checkbox input, .radio input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: 22px; transition: .2s;
}
.switch-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 { font-size: 1.05rem; }
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Stat / quick-action cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-card .stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 700; font-family: var(--font-display); letter-spacing: -0.02em; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Tables */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  background: var(--bg-soft);
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-soft); }
.table .col-right { text-align: right; }
.table .col-center { text-align: center; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

/* Search input */
.search-input {
  position: relative;
  flex: 1;
  max-width: 360px;
  min-width: 180px;
}
.search-input svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.search-input input { padding-left: 34px; }

/* Section heading */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.section-heading h2 { font-size: 1.1rem; }
.section-heading .actions { display: flex; gap: 8px; }

/* Avatar / logo upload */
.logo-uploader {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-preview {
  width: 80px; height: 80px;
  border-radius: var(--radius);
  border: 2px dashed var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  color: var(--text-subtle);
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* Pill segmented control */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 3px;
  background: var(--bg-soft);
  gap: 2px;
}
.segmented button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
  transition: all .15s ease;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Tab bar (mobile invoice editor) */
.tab-bar {
  display: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
}
.tab-bar button {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
}
.tab-bar button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Progress / bar */
.bar { height: 6px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

/* Alert */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
}
.alert-info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.alert svg { flex-shrink: 0; margin-top: 1px; }

/* Divider */
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--text-subtle);
  padding: 4px;
  display: inline-flex;
  align-items: center;
}
.drag-handle:active { cursor: grabbing; }

/* Tooltip-ish */
.tip { position: relative; }
.tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff;
  padding: 4px 8px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  margin-bottom: 6px;
  z-index: 10;
  pointer-events: none;
}
