/* ============================================================
   COMPONENTS.CSS — Buttons, Cards, Badges, Modals, Toasts
============================================================ */

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.88em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #1a1a2e;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success-dim);
  color: var(--success);
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: #fff;
}

.btn-warning {
  background: var(--warning-dim);
  color: var(--warning);
  border-color: var(--warning);
}

.btn-sm  { padding: 5px 10px; font-size: 0.80em; }
.btn-xs  { padding: 3px 7px;  font-size: 0.75em; }
.btn-lg  { padding: 11px 22px; font-size: 1.0em; }
.btn-full{ width: 100%; justify-content: center; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  display: block;
}

.card-title {
  font-size: 1.0em;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title-text { flex: 1; }

/* Only add margin between stacked cards, not inside grids */
.card + .card { margin-top: 16px; }
.card { box-sizing: border-box; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Role badges */
.badge-role-administrator { background: rgba(155,89,182,0.2); color: #9b59b6; }
.badge-role-manager        { background: rgba(231,76,60,0.2);  color: #e74c3c; }
.badge-role-manager_assistant { background: rgba(230,126,34,0.2); color: #e67e22; }
.badge-role-sales          { background: rgba(52,152,219,0.2); color: #3498db; }
.badge-role-accounts       { background: rgba(39,174,96,0.2);  color: #27ae60; }
.badge-role-installer      { background: rgba(149,165,166,0.2);color: #95a5a6; }

/* Status badges */
.badge-draft              { background: rgba(127,140,141,0.2); color: #7f8c8d; }
.badge-pending_approval   { background: rgba(243,156,18,0.2);  color: #f39c12; }
.badge-returned           { background: rgba(231,76,60,0.2);   color: #e74c3c; }
.badge-approved           { background: rgba(39,174,96,0.2);   color: #27ae60; }
.badge-emailed_to_client  { background: rgba(52,152,219,0.2);  color: #3498db; }
.badge-modified           { background: rgba(230,126,34,0.2);  color: #e67e22; }
.badge-accepted           { background: rgba(39,174,96,0.2);   color: #27ae60; }
.badge-confirmed          { background: rgba(46,204,113,0.2);  color: #2ecc71; }
.badge-ready_to_schedule  { background: rgba(52,152,219,0.2);  color: #3498db; }
.badge-schedule_pending   { background: rgba(155,89,182,0.2);  color: #9b59b6; }
.badge-more_info_needed   { background: rgba(243,156,18,0.2);  color: #f39c12; }
.badge-scheduled          { background: rgba(52,73,94,0.3);    color: #85c1e9; }
.badge-completed          { background: rgba(39,174,96,0.2);   color: #27ae60; }
.badge-invoiced           { background: rgba(232,197,71,0.2);  color: #e8c547; }
.badge-closed             { background: rgba(39,174,96,0.3);   color: #1e8449; }
.badge-lost               { background: rgba(231,76,60,0.15);  color: #e74c3c; }

/* ── MODAL ───────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  display: none;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s ease;
}

.modal-lg  { max-width: 800px; }
.modal-xl  { max-width: 1100px; }

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

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05em;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3em;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── TOASTS ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88em;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  border-left: 4px solid;
}

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

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

.toast-msg { color: var(--text-primary); flex: 1; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88em;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-info    { background: var(--info-dim);    border-color: var(--info);    color: var(--text-primary); }
.alert-success { background: var(--success-dim); border-color: var(--success); color: var(--text-primary); }
.alert-warning { background: var(--warning-dim); border-color: var(--warning); color: var(--text-primary); }
.alert-danger  { background: var(--danger-dim);  border-color: var(--danger);  color: var(--text-primary); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5em; margin-bottom: 12px; opacity: 0.5; }
.empty-msg  { font-size: 1.0em; font-weight: 500; }
.empty-sub  { font-size: 0.85em; margin-top: 6px; }

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

/* ── CONFIRM DIALOG ──────────────────────────────────────── */
.confirm-modal {
  max-width: 400px;
}
.confirm-msg {
  font-size: 0.95em;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Prevent margin collapse inside grid containers */
[style*="display:grid"] > .card,
[style*="display: grid"] > .card {
  margin-top: 0 !important;
}
