/* portfolio.css — Minha Carteira (Fase 1)
   Usa exclusivamente as CSS variables do tema (styles.css). */

.portfolio-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

/* ===== Cards de totais ===== */
.pf-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.pf-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
}

.pf-card-label {
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pf-card-value {
  font-size: 22px;
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pf-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.pf-card--pnl .pf-card-value.val-positive { color: var(--green-profit); }
.pf-card--pnl .pf-card-value.val-negative { color: var(--red-loss); }

/* ===== Dashboards (F2) ===== */
.pf-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.pf-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.pf-chart-card--wide { grid-column: 1 / -1; }

.pf-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pf-chart-header h3 {
  font-size: 15px;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}

.pf-chart-sub {
  font-size: 12px;
  font-weight: var(--fw-normal);
  color: var(--text-muted);
}

.pf-chart-body { position: relative; height: 260px; }
.pf-chart-card--wide .pf-chart-body { height: 300px; }

.pf-chart-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--yellow-accent);
}

.pf-period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
}

.pf-period-selector button {
  background: none;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: var(--fw-medium);
  font-family: var(--font-main);
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.pf-period-selector button:hover { color: var(--text-primary); }

.pf-period-selector button.active {
  background: var(--gradient-primary);
  color: #fff;
}

@media (max-width: 900px) {
  .pf-charts-grid { grid-template-columns: 1fr; }
}

/* ===== Controles ===== */
.pf-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pf-limit-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Tabela de posições ===== */
.pf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.pf-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.pf-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pf-table .text-right { text-align: right; }

.pf-row-position {
  cursor: pointer;
  transition: background 0.15s ease;
}
.pf-row-position:hover { background: var(--bg-card-hover); }

.pf-expand-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  color: var(--text-muted);
  font-size: 11px;
}
.pf-row-position.expanded .pf-expand-icon { transform: rotate(90deg); }

.pf-asset-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
}

.pf-asset-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-card);
  border: 1px solid var(--border);
  font-size: 15px;
  flex-shrink: 0;
}

.pf-pair-quote { color: var(--text-muted); font-weight: var(--fw-normal); }

.val-positive { color: var(--green-profit); }
.val-negative { color: var(--red-loss); }

/* Sub-linhas: transações da posição */
.pf-row-tx td {
  background: rgba(255, 255, 255, 0.015);
  font-size: 13px;
  padding: 9px 14px;
}

.pf-row-tx .pf-tx-date { color: var(--text-muted); }

.pf-tx-actions { display: flex; gap: 8px; justify-content: flex-end; }

.pf-btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 8px;
  font-size: 12px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.pf-btn-icon:hover { color: var(--text-primary); border-color: var(--border-hover); }
.pf-btn-icon.pf-btn-danger:hover { color: var(--red-loss); border-color: rgba(239, 68, 68, 0.4); }

/* Abas Em andamento × Finalizados */
.pf-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.pf-view-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 3px;
}

.pf-view-tabs button {
  background: none;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: var(--fw-medium);
  font-family: var(--font-main);
  padding: 7px 16px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.pf-view-tabs button:hover { color: var(--text-primary); }
.pf-view-tabs button.active {
  background: var(--gradient-primary);
  color: #fff;
}

.pf-realized-info {
  font-size: 13px;
  color: var(--text-secondary);
}
.pf-realized-info .val-positive { color: var(--green-profit); font-weight: var(--fw-semibold); }
.pf-realized-info .val-negative { color: var(--red-loss); font-weight: var(--fw-semibold); }

/* Badges de operação e tipo de ordem */
.pf-side-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  margin-right: 6px;
}
.pf-side-buy  { background: rgba(79, 185, 129, 0.12); color: var(--green-profit); border: 1px solid rgba(79, 185, 129, 0.3); }
.pf-side-sell { background: rgba(239, 68, 68, 0.1); color: var(--red-loss); border: 1px solid rgba(239, 68, 68, 0.3); }

.pf-order-type {
  color: var(--text-muted);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  margin-left: 6px;
  white-space: nowrap;
}

/* Seleção múltipla / exclusão em lote */
.pf-chk-cell { text-align: center; }
.pf-chk-cell input[type="checkbox"] {
  cursor: pointer;
  width: 15px;
  height: 15px;
  accent-color: var(--purple-vivid);
}

.pf-btn-delete-selected {
  color: var(--red-loss);
  border-color: rgba(239, 68, 68, 0.3);
}
.pf-btn-delete-selected:hover {
  border-color: rgba(239, 68, 68, 0.6);
}

/* FX indisponível */
.pf-fx-warn { color: var(--yellow-accent); cursor: help; }

/* ===== Empty state ===== */
.pf-empty {
  text-align: center;
  padding: 60px 20px;
}
.pf-empty-icon { font-size: 42px; margin-bottom: 12px; }
.pf-empty h3 { color: var(--text-primary); margin-bottom: 8px; }
.pf-empty p { color: var(--text-muted); margin-bottom: 20px; }

/* ===== Gate (não assinante) ===== */
.pf-gate {
  max-width: 560px;
  margin: 60px auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  box-shadow: var(--shadow-card);
}
.pf-gate .pf-gate-icon { font-size: 44px; margin-bottom: 14px; }
.pf-gate h3 { color: var(--text-primary); margin-bottom: 10px; }
.pf-gate p { color: var(--text-secondary); margin-bottom: 22px; }

/* ===== Modal ===== */
.pf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pf-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.pf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.pf-modal-header h3 { color: var(--text-primary); font-size: 18px; }

.pf-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.pf-modal-close:hover { color: var(--text-primary); }

.pf-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  padding: 20px 24px 0;
}

.pf-field { display: flex; flex-direction: column; gap: 5px; }
.pf-field-full { grid-column: 1 / -1; }

.pf-field label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
}

.pf-field input,
.pf-field select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.15s ease;
}
.pf-field input:focus,
.pf-field select:focus { border-color: var(--purple-vivid); }

.pf-field small { font-size: 11px; color: var(--text-muted); }

.pf-quote-hint { color: var(--btc-orange); font-weight: var(--fw-semibold); }

.pf-form-error {
  margin: 14px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red-loss);
  font-size: 13px;
}

.pf-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 22px 24px 24px;
}

/* ===== Banner de boas-vindas (F4) ===== */
.pf-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--gradient-card);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.pf-welcome-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.pf-welcome-text strong { color: var(--text-primary); font-size: 14px; }
.pf-welcome-text em { color: var(--btc-orange); font-style: normal; font-weight: var(--fw-semibold); }

.pf-welcome-dismiss { white-space: nowrap; flex-shrink: 0; }

@media (max-width: 700px) {
  .pf-welcome { flex-direction: column; align-items: flex-start; }
}

/* ===== Importação de CSV (F3) ===== */
.pfi-modal { max-width: 760px; }

.pfi-hint {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pfi-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 24px 0;
}

.pfi-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: var(--fw-medium);
}
.pfi-chip.pfi-st-new  { color: var(--green-profit); border-color: rgba(79, 185, 129, 0.4); }
.pfi-chip.pfi-st-dup  { color: var(--text-muted); }
.pfi-chip.pfi-st-sell { color: var(--yellow-accent); border-color: rgba(238, 183, 20, 0.35); }
.pfi-chip.pfi-st-err  { color: var(--red-loss); border-color: rgba(239, 68, 68, 0.4); }

.pfi-preview-wrap {
  margin: 14px 24px 0;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.pfi-preview-table { font-size: 13px; }
.pfi-preview-table th { position: sticky; top: 0; background: var(--bg-secondary); }
.pfi-preview-table td { padding: 8px 12px; }

.pfi-errors {
  margin: 14px 24px 0;
  font-size: 12px;
  color: var(--red-loss);
}
.pfi-errors ul { margin: 6px 0 0 18px; }

/* ===== Responsivo ===== */
@media (max-width: 900px) {
  .pf-form-grid { grid-template-columns: 1fr; }
  .table-card { overflow-x: auto; }
}
