/* ==========================================================================
   BillApp — components.css
   Buttons, cards, inputs, list items, FAB, toast, modal, badges.
   ========================================================================== */

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard),
              background var(--duration-fast) var(--ease-standard);
  user-select: none;
  -webkit-user-select: none;
}

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

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn--accent {
  background: var(--color-accent);
  color: #fff;
}

.btn--outline {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn--ghost {
  background: transparent;
  color: var(--color-primary);
}

.btn--danger {
  background: transparent;
  color: var(--color-danger);
}

.btn--icon {
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
}

.btn--block {
  width: 100%;
}

.btn--sm {
  min-height: 38px;
  padding: 0 var(--space-4);
  font-size: var(--font-size-sm);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* FAB ----------------------------------------------------------------------*/
.fab {
  position: fixed;
  right: var(--space-5);
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  z-index: 25;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-pill);
  border: 0;
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab svg {
  width: 26px;
  height: 26px;
}

.fab:active {
  transform: scale(0.94);
}

/* Cards --------------------------------------------------------------------*/
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

.nav-tile {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  text-align: left;
  border: 0;
  width: 100%;
}

.nav-tile:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.nav-tile__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-tile__icon svg {
  width: 24px;
  height: 24px;
}

.nav-tile__body {
  flex: 1;
  min-width: 0;
}

.nav-tile__title {
  font-size: var(--font-size-base);
  font-weight: 600;
}

.nav-tile__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.stat-card__value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-primary);
}

.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Forms ----------------------------------------------------------------------*/
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

.field__input,
.field__select,
.field__textarea {
  min-height: 48px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.field__textarea {
  min-height: 88px;
  padding: var(--space-3);
  resize: vertical;
}

.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(20, 83, 45, 0.15);
}

.field__input:read-only {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.field__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
}

.field__error {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 480px) {
  .form-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* List items ---------------------------------------------------------------*/
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
}

.list-item__body {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item__meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* Search bar -----------------------------------------------------------------*/
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-4);
  min-height: 46px;
  box-shadow: var(--shadow-sm);
}

.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.search-bar input {
  border: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  height: 44px;
}

.search-bar input:focus {
  outline: none;
}

/* Empty state ----------------------------------------------------------------*/
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 56px;
  height: 56px;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}

/* Badge ------------------------------------------------------------------------*/
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

.badge--accent {
  background: rgba(214, 137, 16, 0.15);
  color: var(--color-accent-dark);
}

/* Toast ----------------------------------------------------------------------*/
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  background: #1c2733;
  color: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.toast--success { background: var(--color-success); }
.toast--error { background: var(--color-danger); }
.toast--warning { background: var(--color-warning); }

/* Modal / sheet ----------------------------------------------------------------*/
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-sheet__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.modal-sheet__body {
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.modal-sheet__actions {
  display: flex;
  gap: var(--space-3);
}

.modal-sheet__actions .btn {
  flex: 1;
}

/* Autocomplete -------------------------------------------------------------------*/
.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 40;
}

.autocomplete__option {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.autocomplete__option:last-child {
  border-bottom: 0;
}

.autocomplete__option:active,
.autocomplete__option.is-active {
  background: var(--color-surface-alt);
}

.autocomplete__option-title {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.autocomplete__option-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Legal documents ------------------------------------------------------------*/
.legal-doc__meta {
  border-left: 3px solid var(--color-primary);
}

.legal-doc__lang-section + .legal-doc__lang-section {
  margin-top: var(--space-5);
}

.legal-doc__lang-heading {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-3);
}

.legal-doc__lead {
  font-weight: 500;
}

.legal-doc__heading {
  font-size: var(--font-size-base);
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}

.legal-doc__lang-heading + .legal-doc__heading {
  margin-top: 0;
}

.legal-doc__list {
  margin: 0 0 var(--space-2);
  padding-left: var(--space-5);
}

.legal-doc__list li {
  margin-bottom: var(--space-2);
}

.legal-doc__divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

.legal-accept__row {
  padding: 0;
  overflow: hidden;
}

.legal-accept__row-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  border: 0;
  background: none;
  padding: var(--space-4);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.legal-accept__row-body {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
}
