/**
 * components.css
 * Reusable UI components: cards, tables, forms, buttons, badges, etc.
 * Depends on: variables.css, base.css
 */

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              opacity var(--transition);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn svg {
  width: 15px; height: 15px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

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

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

/* Accent (gold) */
.btn-accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-accent:hover { background: var(--color-accent-dark); border-color: var(--color-accent-dark); color: #fff; }

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border-mid);
}
.btn-outline:hover { background: var(--color-accent-soft); color: var(--color-text); border-color: var(--color-primary); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-accent-soft); color: var(--color-text); }

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover { opacity: 0.85; color: #fff; }

/* Sizes */
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 11px 28px; font-size: 0.95rem; }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  background: var(--color-panel);
}

/* Stat card */
.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card.stat-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

.stat-card-header { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-card-label  { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); }
.stat-primary .stat-card-label { color: rgba(255,255,255,0.75); }

.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-accent);
  flex-shrink: 0;
}
.stat-primary .stat-card-icon { background: rgba(255,255,255,0.2); color: #fff; }
.stat-card-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stat-card-value { font-size: 1.65rem; font-weight: 700; color: var(--color-text); line-height: 1; }
.stat-primary .stat-card-value { color: #fff; }

.stat-card-change {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.78rem; font-weight: 600;
}
.stat-card-change.up   { color: var(--color-success); }
.stat-card-change.down { color: var(--color-danger); }
.stat-primary .stat-card-change { color: rgba(255,255,255,0.85); }
.stat-card-change svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* ══════════════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  padding: 0 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-mid);
  white-space: nowrap;
}

.table th.right,
.table td.right { text-align: right; }

.table td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr {
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--color-accent-soft); }
html.dark .table tbody tr:hover { background: rgba(197,160,89,0.07); }

/* Ticker cell */
.ticker-cell { display: flex; align-items: center; gap: 10px; }
.ticker-initials {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
  font-weight: 700; font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
html.dark .ticker-initials { background: rgba(197,160,89,0.15); color: var(--color-accent); }
.ticker-name  { font-weight: 600; font-size: 0.88rem; }
.ticker-full  { font-size: 0.74rem; color: var(--color-text-muted); margin-top: 1px; }

/* ══════════════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.badge-default  { background: var(--color-accent-soft); color: var(--color-accent-dark); border-color: rgba(197,160,89,0.25); }
.badge-primary  { background: rgba(138,154,91,0.12);   color: var(--color-primary);  border-color: rgba(138,154,91,0.25); }
.badge-success  { background: var(--color-success-bg);  color: var(--color-success);  border-color: rgba(58,125,84,0.2); }
.badge-danger   { background: var(--color-danger-bg);   color: var(--color-danger);   border-color: rgba(155,67,42,0.2); }
.badge-warning  { background: var(--color-warning-bg);  color: var(--color-warning);  border-color: rgba(164,124,11,0.2); }
.badge-info     { background: var(--color-info-bg);     color: var(--color-info);     border-color: rgba(42,107,138,0.2); }

/* ══════════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--color-text); }
.form-hint  { font-size: 0.76rem; color: var(--color-text-muted); }
.form-error { font-size: 0.76rem; color: var(--color-danger); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--color-panel);
  border: 1px solid var(--color-border-mid);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--color-text-light); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(138,154,91,0.18);
}

.form-input.error { border-color: var(--color-danger); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(155,67,42,0.15); }

.form-textarea { resize: vertical; min-height: 100px; }

/* Input with leading icon */
.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-left: 38px; }
.input-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--color-text-muted); fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}

/* Input with trailing action */
.input-action {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); padding: 2px;
  transition: color var(--transition);
}
.input-action:hover { color: var(--color-text); }
.input-action svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Checkbox / Radio */
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════════════════════
   PROGRESS / ALLOCATION BAR
   ══════════════════════════════════════════════════════════════════════════ */
.progress {
  height: 6px;
  background: var(--color-border-mid);
  border-radius: 100px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 100px;
  transition: width 0.6s ease;
}
.progress-bar.accent { background: var(--color-accent); }

/* ══════════════════════════════════════════════════════════════════════════
   CHART PLACEHOLDER
   ══════════════════════════════════════════════════════════════════════════ */
.chart-placeholder {
  background: linear-gradient(135deg, var(--color-bg-soft) 0%, var(--color-panel) 100%);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  gap: 8px;
  border: 1px dashed var(--color-border-mid);
}
.chart-placeholder svg { width: 28px; height: 28px; stroke: var(--color-text-light); fill: none; stroke-width: 1.5; }

/* Mini bar chart (CSS-only, decorative) */
.mini-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 48px;
}
.mini-bar-chart .bar {
  flex: 1;
  background: linear-gradient(to top, rgba(138,154,91,0.4), rgba(138,154,91,0.8));
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}

/* ══════════════════════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 20px; }

.tab {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.tab:hover { color: var(--color-text); }
.tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════════════
   SEARCH / FILTER BAR
   ══════════════════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-input { max-width: 240px; }
.filter-bar .form-select { max-width: 160px; }

/* ══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-muted);
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--color-text-light); fill: none; stroke-width: 1.5; margin: 0 auto 12px; }
.empty-state p { font-size: 0.875rem; max-width: 320px; margin: 0 auto; }

/* ══════════════════════════════════════════════════════════════════════════
   ALERTS / NOTICES
   ══════════════════════════════════════════════════════════════════════════ */
.alert {
  display: flex; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid transparent;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; margin-top: 1px; }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info);    border-color: rgba(42,107,138,0.2); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(58,125,84,0.2); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(164,124,11,0.2); }
.alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger);  border-color: rgba(155,67,42,0.2); }

/* ══════════════════════════════════════════════════════════════════════════
   DIVIDER with label
   ══════════════════════════════════════════════════════════════════════════ */
.divider-label {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.75rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.07em;
  margin: 20px 0;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1; height: 1px; background: var(--color-border);
}

/* ══════════════════════════════════════════════════════════════════════════
   DROPDOWN MENU
   ══════════════════════════════════════════════════════════════════════════ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 6px;
  z-index: 200;
  display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
  border: none; background: none; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--color-accent-soft); }
.dropdown-item svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

/* Notification window (dropdown variant) */
.notification-menu {
  width: min(360px, 88vw);
  min-width: 320px;
  padding: 0;
  overflow: hidden;
}

.notification-head,
.notification-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--color-panel);
}

.notification-head {
  border-bottom: 1px solid var(--color-border);
}

.notification-foot {
  border-top: 1px solid var(--color-border);
}

.notification-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
}

.notification-link {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
}

.notification-link:hover {
  color: var(--color-primary-dark);
}

.notification-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}

.notification-item {
  display: block;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition);
}

.notification-item:hover {
  background: var(--color-accent-soft);
}

.notification-item.unread {
  border-left: 3px solid var(--color-accent);
  padding-left: 8px;
}

.notification-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notification-item-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}

.notification-item-time {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.notification-item-text {
  margin-top: 4px;
  font-size: 0.77rem;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* ══════════════════════════════════════════════════════════════════════════
   IMPORT METHOD CARD
   ══════════════════════════════════════════════════════════════════════════ */
.import-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.import-card:hover, .import-card.selected {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}
.import-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-accent);
}
.import-card-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.import-card-title { font-weight: 600; font-size: 0.95rem; }
.import-card-desc  { font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.5; }
