/* ============================================================
   COMPONENTS — buttons, cards, forms, modals
   ============================================================ */

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--f-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-primary:hover { background: var(--red-600); border-color: var(--red-600); transform: translateY(-1px); box-shadow: var(--sh-red); }
.btn-primary:active { transform: translateY(0); }

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

.btn-light {
  background: var(--white);
  color: var(--red);
  border-color: var(--white);
}
.btn-light:hover { background: var(--ink); color: var(--white); border-color: var(--ink); }

.btn-ghost-light {
  background: transparent;
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}
.btn-ghost-light:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--white); }

.btn-danger {
  background: var(--error-bg);
  color: var(--red);
  border-color: transparent;
}
.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-block { width: 100%; }
.btn-lg {
  font-family: var(--f-display);
  font-size: var(--fs-lg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: var(--r-md);
}

/* Icon-only buttons (header) */
.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

/* ── Cards & Forms ─────────────────────────────────── */
.card-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  box-shadow: var(--sh-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.span-2 { grid-column: 1 / -1; }

.form-heading {
  font-family: var(--f-display);
  font-size: var(--fs-xl);
  letter-spacing: 0.04em;
  margin: var(--sp-6) 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1.5px solid var(--border);
}
.form-heading:first-child { margin-top: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.field label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-mid);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--f-body);
  font-size: var(--fs-base);
  color: var(--text);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--red);
  background: var(--bg-card);
  box-shadow: var(--focus-ring);
}
.field input:invalid:not(:placeholder-shown),
.field select:invalid:not([value=""]) {
  border-color: var(--red);
}
.field textarea {
  resize: vertical;
  min-height: 110px;
  font-family: var(--f-body);
}

.field.consent { margin-top: var(--sp-3); }
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-mid);
  cursor: pointer;
  line-height: 1.6;
}
.check input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--red);
  cursor: pointer;
  flex-shrink: 0;
}
.check a { color: var(--red); font-weight: 600; }
.check a:hover { text-decoration: underline; }

/* Password toggle */
.pw-wrap {
  position: relative;
}
.pw-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  border-radius: var(--r-sm);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.pw-eye:hover { color: var(--text); background: var(--bg-alt); }
.pw-wrap input { padding-right: 44px; }

/* ── Alerts ────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--sp-4);
  border-left: 3px solid;
}
.alert-error { background: var(--error-bg); color: var(--red); border-color: var(--red); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }

/* ── Modals ────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.modal-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-height: calc(100vh - var(--sp-7));
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl);
  overflow: hidden;
  animation: modal-in var(--dur-slow) var(--ease-spring);
}
.modal-box-sm { max-width: 440px; }
.modal-box-md { max-width: 540px; }
.modal-box-lg { max-width: 760px; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--f-display);
  font-size: var(--fs-xl);
  letter-spacing: 0.04em;
  font-weight: 400;
}
.modal-x {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--bg-alt);
  color: var(--text-mid);
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.modal-x:hover { background: var(--red); color: var(--white); transform: rotate(90deg); }

.modal-body { padding: var(--sp-6); }
.modal-body-scroll {
  overflow-y: auto;
  max-height: 56vh;
  -webkit-overflow-scrolling: touch;
}
.modal-foot {
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Login modal specifics */
.login-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-3);
  background: linear-gradient(135deg, var(--red) 0%, var(--red-700) 100%);
  border-radius: var(--r-lg);
  color: var(--white);
  box-shadow: var(--sh-red);
}
.login-sub {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-mid);
  margin-bottom: var(--sp-5);
}
.login-foot {
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-soft);
  margin-top: var(--sp-4);
  letter-spacing: 0.04em;
}

/* ── Toasts ────────────────────────────────────────── */
.toast-region {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  box-shadow: var(--sh-lg);
  white-space: nowrap;
  max-width: calc(100vw - var(--sp-6));
  animation: toast-in var(--dur-slow) var(--ease-spring);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Tables (admin) ────────────────────────────────── */
.table-wrap {
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.data-table th {
  background: var(--bg-alt);
  padding: 14px 16px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-alt); }
.data-table .empty-row {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mid);
  font-style: italic;
}

.cat-tag {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--red-glow);
  color: var(--red);
  letter-spacing: 0.04em;
  display: inline-block;
}
.status-pill {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0.04em;
  display: inline-block;
}
.status-pending { background: var(--warning-bg); color: var(--warning); }
.status-paid { background: var(--success-bg); color: var(--success); }

.btn-sm {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: none;
  margin-right: 6px;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.btn-edit { background: var(--bg-alt); color: var(--text); }
.btn-edit:hover { background: var(--ink); color: var(--white); }
.btn-del { background: var(--error-bg); color: var(--red); }
.btn-del:hover { background: var(--red); color: var(--white); }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-7);
}
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-family: var(--f-mono);
  transition: all var(--dur-fast) var(--ease-out);
}
.page-btn:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.page-btn[aria-current="page"] {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
