/* ============================================================
   COMPONENTS.CSS — Buttons, Modals, Toast, Item rows, Badges
   ============================================================ */

/* ── Buttons ── */
.btn {
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-body);
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}

.btn-primary:hover {
  box-shadow: 0 8px 20px rgba(126, 34, 206, .4);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
}

.btn-success:hover {
  box-shadow: 0 8px 20px rgba(16, 185, 129, .35);
}

.btn-info {
  background: linear-gradient(135deg, var(--info), #2563eb);
  color: white;
}

.btn-info:hover {
  box-shadow: 0 8px 20px rgba(59, 130, 246, .35);
}

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: white;
}

.btn-warning:hover {
  box-shadow: 0 8px 20px rgba(245, 158, 11, .35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
}

.btn-danger:hover {
  box-shadow: 0 8px 20px rgba(239, 68, 68, .35);
}

.btn-ghost {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-secondary {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: white;
}

.btn-secondary:hover {
  box-shadow: 0 8px 20px rgba(100, 116, 139, .35);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.action-buttons .btn {
  width: 100%;
}

/* ── Item rows (line items) ── */
.items-container {
  margin-bottom: 15px;
}

.item-row {
  background: #f9fafb;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 2px solid #e5e7eb;
  transition: var(--transition);
}

.item-row:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(126, 34, 206, .1);
  transform: translateX(3px);
}

.item-row-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 0;
}

.item-description {
  grid-column: 1/-1;
  margin-top: 10px;
}

.item-total-display {
  font-weight: 800;
  color: var(--success);
  font-size: 13px;
  margin-top: 6px;
  text-align: right;
}

/* ── Template/Color pickers ── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.tpl-btn {
  padding: 12px 6px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  background: white;
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  font-family: var(--font-body);
}

.tpl-btn:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(126, 34, 206, .1);
}

.tpl-btn.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
}

.tpl-icon {
  font-size: 18px;
  display: block;
  margin-bottom: 4px;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.color-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 3px solid transparent;
  transition: var(--transition);
  position: relative;
}

.color-option:hover {
  transform: scale(1.15);
  border-color: #1e293b;
}

.color-option.active {
  border-color: #1e293b;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .15);
}

.color-option.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

/* ── Badges ── */
.badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.admin {
  background: var(--danger);
  color: white;
}

.badge.user {
  background: var(--info);
  color: white;
}

.badge.inactive {
  background: #94a3b8;
  color: white;
}

.feature-badge {
  display: inline-block;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  margin-left: 6px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .65);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease-out;
}

.modal-box h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 6px;
}

.modal-sub {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--font-body);
  margin-bottom: 14px;
  transition: border-color .2s;
}

.modal-input:focus {
  border-color: var(--primary);
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

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

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
}

.loading-content {
  background: white;
  padding: 32px;
  border-radius: 16px;
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 14px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  padding: 14px 22px;
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, .25);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: var(--z-overlay);
  font-weight: 700;
  font-size: 14px;
  animation: slideUp .3s ease-out;
}

.toast.show {
  display: flex;
}

.toast.error {
  background: linear-gradient(135deg, var(--danger), #dc2626);
}

.toast.info {
  background: linear-gradient(135deg, var(--info), #2563eb);
}

.toast.warn {
  background: linear-gradient(135deg, var(--warning), #d97706);
}

/* ── Stats cards (admin, dashboard) ── */
.stats-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-card.success {
  background: linear-gradient(135deg, var(--success), #059669);
}

.stat-card.warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
}

.stat-value {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 3px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: .9;
}

/* ── Sub status badges ── */
.sub-status {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
}

.sub-status.nolimit {
  background: #ede9fe;
  color: #6b21a8;
}

.sub-status.active {
  background: #dcfce7;
  color: #166534;
}

.sub-status.expiring {
  background: #fef3c7;
  color: #92400e;
}

.sub-status.expired {
  background: #fee2e2;
  color: #991b1b;
}

.sub-status.trial {
  background: #e0f2fe;
  color: #0369a1;
}

/* Plan badges */
.plan-badge {
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.plan-badge.trial {
  background: #e0f2fe;
  color: #0369a1;
}

.plan-badge.starter {
  background: #dcfce7;
  color: #166534;
}

.plan-badge.pro {
  background: #ede9fe;
  color: #6b21a8;
}

.plan-badge.business {
  background: #fef3c7;
  color: #92400e;
}

.plan-badge.enterprise {
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  color: white;
}

/* ── User / billing table ── */
.user-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}

.user-table th {
  background: var(--dark);
  color: white;
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.user-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

.user-table tr:hover td {
  background: #fff5f5;
}

.add-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 80px auto;
  gap: 8px;
  margin-bottom: 20px;
  align-items: end;
}

/* ── Exp tabs ── */
.exp-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.exp-tab {
  padding: 10px 20px;
  background: rgba(255, 255, 255, .1);
  border: 2px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}

.exp-tab.active {
  background: white;
  color: var(--primary);
  border-color: white;
}