/* ============================================================
   JOSAY — HARMONIVITA  ·  Design System v2
   components.css — Buttons, Cards, Forms, Modals, Badges,
                    Tables, Tabs, Toasts, Alerts
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 0.5rem 1.0625rem;
  font-size: var(--sz-sm); font-weight: 600; font-family: var(--font);
  border-radius: var(--r-md); border: 1.5px solid transparent;
  cursor: pointer; transition: all var(--t); white-space: nowrap;
  line-height: 1; text-decoration: none;
}
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-sm  { padding: 0.375rem 0.75rem; font-size: var(--sz-xs); border-radius: var(--r); }
.btn-lg  { padding: 0.6875rem 1.375rem; font-size: var(--sz-base); }
.btn-xl  { padding: 0.875rem 1.875rem; font-size: var(--sz-lg); font-weight: 700; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--brand-dark); color: var(--white); border-color: var(--brand-dark);
}
.btn-primary:hover { background: #0d2419; border-color: #0d2419; color: var(--white); box-shadow: 0 4px 12px rgba(10,24,18,0.25); }

.btn-green {
  background: var(--brand-green); color: var(--white); border-color: var(--brand-green);
}
.btn-green:hover { background: #15803d; color: var(--white); box-shadow: 0 4px 12px rgba(22,163,74,0.3); }

.btn-outline {
  background: var(--white); color: var(--text); border-color: var(--border);
}
.btn-outline:hover { background: var(--n100); border-color: var(--n300); }

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

.btn-danger {
  background: var(--danger); color: var(--white); border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,0.25); }

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

/* Loading */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon button */
.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: var(--r); background: transparent; border-color: var(--border);
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--n100); color: var(--text); }
.btn-icon-sm { width: 28px; height: 28px; }
.btn-icon-lg { width: 40px; height: 40px; border-radius: var(--r-md); }

/* ════════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}
.card-header {
  padding: var(--s4) var(--s6);
  border-bottom: 1px solid var(--border-lt);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}
.card-header h3, .card-header h4 { margin: 0; font-size: var(--sz-base); font-weight: 700; }
.card-body   { padding: var(--s6); }
.card-footer {
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--border-lt);
  background: var(--n50);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* Metric / stat card */
.stat-card {
  background: var(--white);
  border-radius: var(--r-xl); border: 1px solid var(--border);
  box-shadow: var(--sh-xs); overflow: hidden; cursor: pointer;
  transition: box-shadow var(--t), transform var(--t);
  position: relative;
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-card-body { padding: var(--s5) var(--s6) var(--s5); }
.stat-card-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 2.5px;
  background: var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.stat-card-accent-green  { background: #22c55e; }
.stat-card-accent-amber  { background: #f59e0b; }
.stat-card-accent-red    { background: #f43f5e; }
.stat-card-accent-violet { background: #8b5cf6; }
.stat-card-accent-teal   { background: #14b8a6; }
.stat-card-accent-blue   { background: #3b82f6; }

.stat-label {
  font-size: var(--sz-xs); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: var(--s3);
  display: flex; align-items: center; gap: var(--s2);
}
.stat-label-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.stat-value {
  font-size: 1.75rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.04em; line-height: 1; margin-bottom: var(--s2);
}
.stat-sub { font-size: var(--sz-xs); color: var(--text-muted); }
.stat-sub.up   { color: var(--success); }
.stat-sub.down { color: var(--danger); }
.stat-sub.warn { color: var(--warning); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }

/* ════════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: var(--s4); }
.form-label {
  display: block; font-size: var(--sz-sm); font-weight: 600; color: var(--text);
  margin-bottom: var(--s2);
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.5625rem 0.875rem;
  font-size: var(--sz-sm); font-family: var(--font); color: var(--text);
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--r-md); transition: border-color var(--t), box-shadow var(--t);
  outline: none; line-height: 1.5;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-green-mid);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-faint); }
.form-input.err, .form-select.err, .form-textarea.err {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.08);
}
.form-textarea { resize: vertical; min-height: 96px; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23888480' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.625rem center; background-size: 1.125em;
  padding-right: 2.25rem;
}
.form-hint  { font-size: var(--sz-xs); color: var(--text-muted); margin-top: var(--s1); }
.form-error { font-size: var(--sz-xs); color: var(--danger); margin-top: var(--s1); display: none; }
.form-error.show { display: block; }

.form-check { display: flex; align-items: flex-start; gap: var(--s2); cursor: pointer; }
.form-check input { width: 1rem; height: 1rem; accent-color: var(--brand-green); margin-top: 2px; flex-shrink: 0; cursor: pointer; }
.form-check-label { font-size: var(--sz-sm); color: var(--text-sec); }

/* Switch/toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) 0; }
.toggle-info .toggle-label { font-size: var(--sz-sm); font-weight: 500; color: var(--text); }
.toggle-info .toggle-sub   { font-size: var(--sz-xs); color: var(--text-muted); margin-top: 1px; }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--n300); border-radius: var(--r-full);
  cursor: pointer; transition: background var(--t);
}
.switch input:checked + .switch-track { background: var(--brand-green); }
.switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: white; border-radius: 50%;
  transition: transform var(--t);
}
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* ════════════════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(10,24,18,0.55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: var(--s4);
}
.modal-overlay.active { display: flex; animation: fadein 0.15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { opacity:0; transform:translateY(18px); } to { opacity:1; transform:none; } }

.modal {
  background: var(--white); border-radius: var(--r-2xl);
  box-shadow: var(--sh-xl); width: 100%; max-width: 500px;
  max-height: 90vh; display: flex; flex-direction: column;
  animation: slideup 0.2s ease;
}
.modal-sm { max-width: 380px; }
.modal-lg { max-width: 660px; }
.modal-xl { max-width: 840px; }

.modal-header {
  padding: var(--s5) var(--s6) var(--s4);
  border-bottom: 1px solid var(--border-lt);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h3, .modal-header h4 { margin: 0; font-size: var(--sz-lg); }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--r);
  border: 1.5px solid var(--border); background: var(--n100);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; flex-shrink: 0;
  transition: all var(--t);
}
.modal-close:hover { background: var(--n200); color: var(--text); }
.modal-body { padding: var(--s6); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--s4) var(--s6); border-top: 1px solid var(--border-lt);
  background: var(--n50); border-radius: 0 0 var(--r-2xl) var(--r-2xl);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s3); flex-shrink: 0;
}
.modal-footer-between { justify-content: space-between; }

/* ════════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 0.2rem 0.575rem; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }
.badge-gray    { background: var(--n100); color: var(--n600); border: 1px solid var(--n200); }
.badge-green   { background: var(--brand-green-bg); color: var(--brand-green); border: 1px solid var(--success-border); }
.badge-dark    { background: var(--n800); color: var(--white); border-color: var(--n800); }

/* ════════════════════════════════════════════════════════════
   TABLES
════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--r-xl); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: var(--sz-sm); }
thead { background: var(--n50); }
th {
  text-align: left; padding: 0.625rem var(--s4);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  border-bottom: 1px solid var(--border-lt); white-space: nowrap;
}
td {
  padding: 0.625rem var(--s4); border-bottom: 1px solid var(--border-lt);
  vertical-align: middle; color: var(--text-sec);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t); cursor: pointer; }
tbody tr:hover { background: var(--n50); }
tbody tr.row-danger { background: #fffbfb; }
tbody tr.row-danger:hover { background: var(--danger-bg); }

/* ════════════════════════════════════════════════════════════
   TABS
════════════════════════════════════════════════════════════ */
.tabs {
  display: flex; border-bottom: 1.5px solid var(--border);
  margin-bottom: var(--s6);
}
.tab-btn {
  padding: 0.625rem var(--s4); font-size: var(--sz-sm); font-weight: 500;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1.5px;
  transition: color var(--t), border-color var(--t);
  display: flex; align-items: center; gap: var(--s2); white-space: nowrap;
}
.tab-btn:hover { color: var(--text-sec); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--brand-green); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Pill tabs */
.tabs-pills { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s5); }
.tabs-pills .tab-btn {
  border: 1.5px solid var(--border); border-radius: var(--r-full);
  border-bottom: 1.5px solid var(--border); margin-bottom: 0;
  padding: 0.3125rem 0.875rem; background: var(--white);
}
.tabs-pills .tab-btn.active { background: var(--text); color: var(--white); border-color: var(--text); }

/* ════════════════════════════════════════════════════════════
   ALERTS / BANNERS
════════════════════════════════════════════════════════════ */
.alert {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4); border-radius: var(--r-lg);
  font-size: var(--sz-sm); border: 1px solid;
}
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #166534; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #92400e; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: #991b1b; }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: #1e40af; }

/* ════════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: var(--s6); right: var(--s6);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s2);
  pointer-events: none;
}
.toast {
  padding: 0.6875rem var(--s5); border-radius: var(--r-xl);
  font-size: var(--sz-sm); font-weight: 600; color: var(--white);
  box-shadow: var(--sh-lg); pointer-events: auto; max-width: 300px;
  animation: toastin 0.25s ease; display: flex; align-items: center; gap: var(--s3);
}
@keyframes toastin { from{transform:translateX(110%);opacity:0;} to{transform:none;opacity:1;} }
.toast-success { background: linear-gradient(135deg, #16a34a, #15803d); }
.toast-error   { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.toast-warning { background: linear-gradient(135deg, #d97706, #b45309); }
.toast-info    { background: linear-gradient(135deg, #2563eb, #1d4ed8); }

/* ════════════════════════════════════════════════════════════
   MISC COMPONENTS
════════════════════════════════════════════════════════════ */

/* Avatar */
.avatar {
  border-radius: 50%; background: var(--brand-green-bg); color: var(--brand-green);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--sz-sm); flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.av-sm  { width: 28px; height: 28px; font-size: var(--sz-xs); }
.av-md  { width: 36px; height: 36px; }
.av-lg  { width: 48px; height: 48px; font-size: var(--sz-lg); }
.av-xl  { width: 64px; height: 64px; font-size: var(--sz-xl); border-radius: var(--r-xl); }
.av-sq  { border-radius: var(--r-lg); }

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0.25rem 0.75rem; border-radius: var(--r-full);
  font-size: var(--sz-xs); font-weight: 500;
  background: var(--n100); color: var(--text-sec);
  border: 1px solid var(--n200); cursor: pointer; transition: all var(--t);
}
.chip:hover { background: var(--n200); }
.chip.active { background: var(--text); color: var(--white); border-color: var(--text); }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border-lt); margin: var(--s4) 0; }

/* Info row */
.info-row {
  display: flex; gap: var(--s4); padding: 0.5625rem 0;
  border-bottom: 1px solid var(--border-lt); font-size: var(--sz-sm);
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); min-width: 140px; flex-shrink: 0; }
.info-row-value { font-weight: 600; color: var(--text); }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s4);
}
.section-header h3, .section-header h4 { margin: 0; }

/* Progress bar */
.progress-bg { width: 100%; height: 5px; background: var(--n200); border-radius: var(--r-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--r-full); transition: width 0.6s ease; }
.progress-green  { background: #22c55e; }
.progress-amber  { background: #f59e0b; }
.progress-red    { background: #f43f5e; }
.progress-blue   { background: #3b82f6; }
.progress-violet { background: #8b5cf6; }

/* Empty state */
.empty-state { text-align: center; padding: var(--s12) var(--s4); color: var(--text-muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: var(--s4); opacity: 0.4; }

/* Search bar */
.search-wrap { position: relative; }
.search-wrap .search-ico {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
.search-wrap .form-input { padding-left: 2.25rem; }

/* Filters row */
.filters-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-bottom: var(--s4); }

/* AI banner */
.ai-banner {
  background: linear-gradient(135deg, var(--brand-green-bg) 0%, #e0f2fe 100%);
  border: 1px solid #bbf7d0; border-radius: var(--r-xl);
  padding: var(--s4); display: flex; align-items: flex-start; gap: var(--s3);
  cursor: pointer; transition: box-shadow var(--t);
}
.ai-banner:hover { box-shadow: var(--sh-md); }
.ai-banner-title { font-size: var(--sz-sm); font-weight: 600; color: var(--brand-green); margin-bottom: 2px; }
.ai-banner-desc  { font-size: var(--sz-xs); color: var(--text-sec); }

/* List item */
.list-item {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s4);
  border-bottom: 1px solid var(--border-lt); transition: background var(--t); cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--n50); }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: var(--sz-sm); font-weight: 500; color: var(--text); margin-bottom: 2px; }
.list-item-sub   { font-size: var(--sz-xs); color: var(--text-muted); }

/* Notification item */
.notif-item { display: flex; gap: var(--s3); padding: var(--s4); border-bottom: 1px solid var(--border-lt); cursor: pointer; transition: background var(--t); }
.notif-item:hover { background: var(--n50); }
.notif-item.unread { background: var(--brand-green-bg); }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-green); flex-shrink: 0; margin-top: 5px; }
.notif-body  { flex: 1; min-width: 0; }
.notif-title { font-size: var(--sz-sm); font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-desc  { font-size: var(--sz-xs); color: var(--text-muted); line-height: 1.4; }
.notif-time  { font-size: 11px; color: var(--text-faint); white-space: nowrap; margin-top: 2px; }

/* Chart placeholder */
.chart-area { display: flex; align-items: flex-end; gap: 4px; padding: var(--s3) 0 0; }
.chart-col  { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 160px; }
.chart-bar  { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; cursor: pointer; transition: opacity var(--t); }
.chart-bar:hover { opacity: 0.7; }

/* Slot (schedule) */
.slot { height: 38px; border-radius: var(--r); font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--t); }
.slot-open   { background: #dcfce7; color: #166534; }
.slot-open:hover { background: #bbf7d0; }
.slot-booked { background: #dbeafe; color: #1e40af; }
.slot-off    { background: var(--n100); color: var(--text-faint); cursor: default; }
.slot-sel    { background: var(--brand-green); color: white; }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: var(--s2); font-size: var(--sz-sm); color: var(--text-muted); margin-bottom: var(--s4); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-green); }
.breadcrumb-sep { color: var(--n300); }
.breadcrumb-cur { color: var(--text); font-weight: 500; }
