/* ═══════════════════════════════════════════════════════════════════════
   PHASE 3 WIDGETS — phase3-widgets.css
   TASK_UI_02a: Macro Market Pulse & AI Portfolio Allocation
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Skeleton Loading ───────────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.skeleton {
  background: rgba(49, 53, 60, 0.7);
  border-radius: 6px;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}

.skeleton-text  { height: 0.875rem; width: 60%; margin-bottom: 0.5rem; }
.skeleton-value { height: 2rem;     width: 40%; }
.skeleton-bar   { height: 0.375rem; width: 100%; border-radius: 9999px; }
.skeleton-circle {
  border-radius: 50%;
  aspect-ratio: 1;
  width: 100%;
  max-width: 140px;
  margin: 0 auto;
}

/* ── Phase 3 Widget Container ───────────────────────────────────────── */
.p3-widget {
  background: rgba(28, 32, 38, 0.7);
  border: 1px solid rgba(69, 71, 75, 0.2);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.p3-widget:hover {
  border-color: rgba(0, 226, 147, 0.15);
}

/* Decorative glow accent */
.p3-widget::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(0, 226, 147, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.p3-widget-title {
  font-size: 0.625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #c6c6cb;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.p3-widget-title .p3-badge {
  font-size: 0.5rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 226, 147, 0.12);
  color: #00e293;
  border: 1px solid rgba(0, 226, 147, 0.25);
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* ── Macro Metric Cards ─────────────────────────────────────────────── */
.p3-macro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 640px) {
  .p3-macro-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .p3-macro-card--sentiment {
    grid-column: span 2;
  }
}

.p3-macro-card {
  background: rgba(38, 42, 49, 0.6);
  border: 1px solid rgba(69, 71, 75, 0.15);
  border-radius: 0.625rem;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  transition: background 0.2s ease;
}

.p3-macro-card:hover {
  background: rgba(49, 53, 60, 0.7);
}

.p3-macro-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #909095;
}

.p3-macro-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
  color: #dfe2eb;
  line-height: 1;
}

.p3-macro-value.positive { color: #00e293; }
.p3-macro-value.negative { color: #ffb4ab; }
.p3-macro-value.neutral  { color: #bfc7d8; }

.p3-macro-sub {
  font-size: 0.65rem;
  color: #909095;
}

/* Sentiment pill */
.p3-sentiment-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.p3-sentiment-pill.bullish {
  background: rgba(0, 226, 147, 0.1);
  color: #00e293;
  border: 1px solid rgba(0, 226, 147, 0.25);
}
.p3-sentiment-pill.bearish {
  background: rgba(255, 180, 171, 0.1);
  color: #ffb4ab;
  border: 1px solid rgba(255, 180, 171, 0.25);
}
.p3-sentiment-pill.neutral {
  background: rgba(191, 199, 216, 0.1);
  color: #bfc7d8;
  border: 1px solid rgba(191, 199, 216, 0.2);
}

.p3-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

/* ── Portfolio Donut Widget ─────────────────────────────────────────── */
.p3-donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.p3-donut-canvas-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.p3-donut-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.p3-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.p3-donut-center-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
  color: #dfe2eb;
  line-height: 1;
}

.p3-donut-center-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #909095;
  margin-top: 2px;
}

.p3-donut-legend {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 140px;
  overflow-y: auto;
}

.p3-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
}

.p3-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.p3-legend-ticker {
  font-weight: 700;
  font-family: 'Inter', monospace;
  color: #dfe2eb;
  min-width: 2.5rem;
}

.p3-legend-weight {
  font-family: 'Inter', monospace;
  color: #909095;
  margin-left: auto;
  font-size: 0.65rem;
}

/* ── Timestamp & Disclaimer ─────────────────────────────────────────── */
.p3-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(69, 71, 75, 0.15);
}

.p3-timestamp {
  font-size: 0.6rem;
  color: #909095;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.p3-disclaimer {
  font-size: 0.6rem;
  color: #909095;
  font-style: italic;
  text-align: right;
  max-width: 200px;
  line-height: 1.4;
}

/* ── Empty / Error State ────────────────────────────────────────────── */
.p3-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  border: 1px dashed rgba(69, 71, 75, 0.4);
  border-radius: 0.625rem;
  color: #909095;
  font-size: 0.75rem;
  text-align: center;
}

.p3-empty-state .material-symbols-outlined {
  font-size: 1.5rem;
  opacity: 0.4;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .p3-widget { padding: 1rem; }
  .p3-macro-value { font-size: 1.1rem; }
  .p3-donut-canvas-wrap { width: 110px; height: 110px; }
  .p3-donut-center-value { font-size: 1.1rem; }
  .p3-disclaimer { max-width: 140px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   PHASE 3 — Stock Table Enhancements (TASK_UI_03a)
   3 cột mới: AI Recommendation Badge, Margin of Safety, RSI Gauge
   ═══════════════════════════════════════════════════════════════════════ */

/* ── AI Recommendation Badge ────────────────────────────────────────── */
.p3-rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.p3-rec-badge.buy {
  background: rgba(0, 226, 147, 0.12);
  color: #00e293;
  border-color: rgba(0, 226, 147, 0.3);
}
.p3-rec-badge.buy::before { content: '▲'; font-size: 0.5rem; }

.p3-rec-badge.hold {
  background: rgba(191, 199, 216, 0.1);
  color: #bfc7d8;
  border-color: rgba(191, 199, 216, 0.2);
}
.p3-rec-badge.hold::before { content: '◆'; font-size: 0.45rem; }

.p3-rec-badge.sell {
  background: rgba(255, 180, 171, 0.1);
  color: #ffb4ab;
  border-color: rgba(255, 180, 171, 0.3);
}
.p3-rec-badge.sell::before { content: '▼'; font-size: 0.5rem; }

.p3-rec-badge.watch {
  background: rgba(255, 196, 0, 0.08);
  color: #ffc400;
  border-color: rgba(255, 196, 0, 0.2);
}
.p3-rec-badge.watch::before { content: '●'; font-size: 0.45rem; }

.p3-rec-badge.na {
  background: rgba(69, 71, 75, 0.3);
  color: #909095;
  border-color: rgba(69, 71, 75, 0.3);
}

/* ── Margin of Safety (MoS) ─────────────────────────────────────────── */
.p3-mos {
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'Inter', monospace;
}
.p3-mos.positive { color: #00e293; }
.p3-mos.neutral  { color: #bfc7d8; }
.p3-mos.negative { color: #ffb4ab; }
.p3-mos.na       { color: #909095; font-weight: 400; }

/* ── RSI Gauge ──────────────────────────────────────────────────────── */
.p3-rsi-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 56px;
}

.p3-rsi-label {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'Inter', monospace;
}
.p3-rsi-label.overbought { color: #ffb4ab; }
.p3-rsi-label.neutral    { color: #bfc7d8; }
.p3-rsi-label.oversold   { color: #00e293; }
.p3-rsi-label.na         { color: #909095; }

.p3-rsi-bar-track {
  height: 3px;
  background: rgba(69, 71, 75, 0.5);
  border-radius: 9999px;
  overflow: hidden;
  width: 100%;
}

.p3-rsi-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}
.p3-rsi-bar-fill.overbought { background: #ffb4ab; }
.p3-rsi-bar-fill.neutral    { background: #bfc7d8; }
.p3-rsi-bar-fill.oversold   { background: #00e293; }

/* ── Mobile Stock Card View ─────────────────────────────────────────── */
.p3-stock-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.p3-stock-card:active {
  background: rgba(49, 53, 60, 0.5);
}

.p3-card-row1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.p3-card-ticker {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
  color: #dfe2eb;
  line-height: 1;
}

.p3-card-sector-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
}

.p3-card-composite {
  text-align: right;
}

.p3-card-composite-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Manrope', sans-serif;
  color: #00e293;
  line-height: 1;
}

.p3-card-composite-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #909095;
}

.p3-card-row2 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.p3-card-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.p3-card-stat-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #909095;
  font-weight: 700;
}

.p3-card-stat-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: #dfe2eb;
}

.p3-card-row3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.p3-card-badge-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.p3-card-arrow {
  color: #909095;
  font-size: 1rem;
}
