/* ============================================
   FundVault — Component Styles
   Cards, buttons, badges, tables, inputs, gauges
   ============================================ */

/* ── Cards ── */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-flat);
  padding: var(--sp-6);
  transition: box-shadow var(--transition-normal);
}

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

.card-flat {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  border: 1px solid var(--border-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.card-header h3,
.card-header h4 {
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
}

.card-header .view-all {
  font-size: var(--fs-13);
  color: var(--text-link);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  padding: var(--sp-3);
  margin: calc(-1 * var(--sp-3));
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.card-header .view-all:hover {
  background: var(--bg-selected-light);
}

.card-header .view-all::after {
  content: '→';
  display: inline-block;
  transition: transform var(--transition-fast);
}

.card-header .view-all:hover::after {
  transform: translateX(4px);
}

/* ── Stat Card ── */
.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-flat);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.stat-card:hover {
  box-shadow: var(--shadow-raised);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--fw-medium);
}

.stat-card .stat-value {
  font-size: var(--fs-24);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-change {
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Fund Card ── */
.fund-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-flat);
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 1px solid transparent;
}

.fund-card:hover {
  box-shadow: var(--shadow-raised);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.fund-card .fund-name {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--text-brand);
  margin-bottom: var(--sp-2);
  line-height: var(--lh-normal);
}

.fund-card .fund-amc {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
  margin-bottom: var(--sp-4);
}

.fund-card .fund-return {
  font-size: var(--fs-20);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.fund-card .fund-return-label {
  font-size: var(--fs-11);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-sm);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
  line-height: 1.4;
}

.btn-primary {
  background: var(--bg-dark);
  color: var(--text-white);
  border-color: var(--bg-dark);
}

.btn-primary:hover {
  background: var(--bg-dark-secondary);
}

.btn-primary:disabled {
  background: var(--border-light);
  color: var(--text-disabled);
  cursor: not-allowed;
  border-color: var(--border-light);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-brand);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-hover-light);
}

.btn-link {
  background: none;
  color: var(--text-link);
  padding: var(--sp-2) var(--sp-3);
}

.btn-link:hover {
  background: var(--bg-selected-light);
}

.btn-sm {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-12);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-6);
  font-size: var(--fs-16);
}

.btn-icon {
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-xs);
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-equity {
  background: var(--color-blue-light);
  color: var(--color-blue);
}

.badge-debt {
  background: #fef3e2;
  color: #b45309;
}

.badge-hybrid {
  background: var(--color-pro-light);
  color: var(--color-pro);
}

.badge-elss {
  background: var(--color-up-bg);
  color: #0f6b34;
}

.badge-index {
  background: var(--bg-dark-grey);
  color: var(--text-secondary);
}

.badge-liquid {
  background: #e0f7fa;
  color: #00838f;
}

.badge-positive {
  background: var(--color-up-light);
  color: var(--color-up);
}

.badge-negative {
  background: var(--color-down-light);
  color: var(--color-down);
}

/* ── Tags / Filter Pills ── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-default);
  background: var(--bg-white);
  color: var(--text-primary);
  user-select: none;
}

.tag:hover {
  background: var(--bg-hover-light);
}

.tag.active {
  background: var(--bg-dark);
  color: var(--text-white);
  border-color: var(--bg-dark);
}

/* ── Segmented Control (1Y / 3Y / 5Y toggles) ── */
.seg-control {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-white);
}

.seg-control button {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-right: 1px solid var(--border-default);
  white-space: nowrap;
}

.seg-control button:last-child {
  border-right: none;
}

.seg-control button:hover {
  background: var(--bg-hover-light);
}

.seg-control button.active {
  background: var(--bg-dark);
  color: var(--text-white);
}

/* ── Data Table ── */
/* Wide tables scroll horizontally inside their own card so the rightmost
   columns are never clipped by the page (which has overflow-x: clip). */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: var(--z-base);
}

.data-table th {
  background: var(--bg-light-grey);
  padding: var(--sp-4) var(--sp-5);
  text-align: left;
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.data-table th.sortable:hover {
  color: var(--text-brand);
}

.data-table th.sortable::after {
  content: '↕';
  margin-left: var(--sp-2);
  font-size: var(--fs-10);
  opacity: 0.4;
}

.data-table th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--text-link);
}

.data-table th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--text-link);
}

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

.data-table td {
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-14);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-hover-light);
}

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

.data-table .fund-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.data-table .fund-name-cell .name {
  font-weight: var(--fw-medium);
  color: var(--text-brand);
  font-size: var(--fs-14);
}

.data-table .fund-name-cell .sub {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
}

/* ── Inputs ── */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  padding-left: 40px;
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--fs-14);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--text-brand);
  box-shadow: 0 0 0 3px rgba(21, 30, 40, 0.08);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-icon {
  position: absolute;
  left: var(--sp-4);
  color: var(--text-tertiary);
  pointer-events: none;
  font-size: var(--fs-16);
}

/* ── Range Slider ── */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--bg-dark);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--bg-white);
  box-shadow: var(--shadow-raised);
  transition: transform var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--bg-dark);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--bg-white);
  box-shadow: var(--shadow-raised);
}

/* ── Checkbox / Toggle ── */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--bg-dark);
  cursor: pointer;
}

/* ── Tooltip ── */
.tooltip-wrapper {
  position: relative;
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  color: var(--text-white);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-12);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--bg-dark);
}

.tooltip-wrapper:hover .tooltip {
  opacity: 1;
}

/* ── Stars ── */
.star {
  font-size: var(--fs-14);
  line-height: 1;
}

.star-filled {
  color: #f9b72f;
}

.star-half {
  color: #f9b72f;
  opacity: 0.6;
}

.star-empty {
  color: var(--border-default);
}

/* ── Progress Bar ── */
.progress-bar {
  height: 8px;
  background: var(--bg-dark-grey);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar .progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease-out;
  background: var(--color-up);
}

.progress-bar .progress-fill.warning {
  background: var(--color-warning);
}

.progress-bar .progress-fill.danger {
  background: var(--color-down);
}

/* ── Horizontal Bar (for holdings %) ── */
.h-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.h-bar .bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-dark-grey);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.h-bar .bar-fill {
  height: 100%;
  background: var(--chart-1);
  border-radius: var(--radius-full);
  transition: width 0.5s ease-out;
}

.h-bar .bar-value {
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-tertiary);
}

.empty-state .empty-icon {
  font-size: var(--fs-48);
  margin-bottom: var(--sp-5);
  opacity: 0.3;
}

.empty-state .empty-title {
  font-size: var(--fs-16);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}

.empty-state .empty-desc {
  font-size: var(--fs-14);
  max-width: 360px;
  margin: 0 auto;
  line-height: var(--lh-normal);
}

/* ── Chip (removable tag) ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-dark-grey);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  color: var(--text-primary);
}

.chip .chip-remove {
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: var(--fs-16);
  line-height: 1;
  transition: color var(--transition-fast);
}

.chip .chip-remove:hover {
  color: var(--color-down);
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--sp-6) 0;
}

/* ── Loading Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--bg-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Section Title ── */
.section-title {
  font-size: var(--fs-18);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
  margin-bottom: var(--sp-5);
}

.section-subtitle {
  font-size: var(--fs-13);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
  font-weight: var(--fw-regular);
}

/* ── Alert / Red Flag Card ── */
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--fs-13);
  line-height: var(--lh-normal);
}

.alert-card.alert-warning {
  background: #fffae6;
  border: 1px solid var(--color-warning);
  color: var(--color-warning-dark);
}

.alert-card.alert-danger {
  background: var(--color-down-bg);
  border: 1px solid #efa9b1;
  color: var(--color-down);
}

.alert-card.alert-info {
  background: var(--color-blue-light);
  border: 1px solid #a7c9de;
  color: #00477a;
}

.alert-card.alert-success {
  background: var(--color-up-bg);
  border: 1px solid #82edad;
  color: #0f6b34;
}

.alert-card .alert-icon {
  font-size: var(--fs-18);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Autocomplete Dropdown ── */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popup);
  z-index: var(--z-dropdown);
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

.autocomplete-dropdown.show {
  display: block;
  animation: fadeInDown 0.2s ease-out;
}

.autocomplete-item {
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-hover-light);
}

.autocomplete-item .item-name {
  font-weight: var(--fw-medium);
  color: var(--text-brand);
  font-size: var(--fs-14);
}

.autocomplete-item .item-sub {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
}
