/**
 * Admin Portfolio Page
 * Build: 20260201_ADMIN_REBUILD
 * Scoped under: .admin-page-portfolio
 * Style: Financial dashboard with allocations
 */

/* ==========================================
   SECTION 1: RESET & VARIABLES
   ========================================== */
.admin-page-portfolio *,
.admin-page-portfolio *::before,
.admin-page-portfolio *::after {
  background-image: none !important;
  box-shadow: none !important;
}

.admin-page-portfolio {
  --ap-blue: #2B8CFF;
  --ap-blue-soft: rgba(43, 140, 255, 0.14);
  --ap-blue-border: rgba(43, 140, 255, 0.15);
  --ap-dark: #0B1220;
  --ap-panel: #0F1A2E;
  --ap-surface: #162038;
  --ap-text: #EAF2FF;
  --ap-muted: rgba(234, 242, 255, 0.55);
  --ap-success: #10B981;
  --ap-warning: #F59E0B;
  --ap-danger: #EF4444;
  --ap-radius: 18px;
  --ap-radius-sm: 12px;
  --ap-transition: 160ms ease;
  --ap-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ==========================================
   SECTION 2: PAGE CONTAINER
   ========================================== */
.admin-page-portfolio {
  padding: 24px;
  min-height: 100%;
}

/* ==========================================
   SECTION 3: HEADER
   ========================================== */
.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.ap-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--ap-text);
}

.ap-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ap-btn {
  padding: 8px 16px;
  background: var(--ap-panel);
  border: 1px solid var(--ap-blue-border);
  border-radius: 999px;
  color: var(--ap-text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--ap-transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ap-btn:hover {
  background: var(--ap-blue-soft);
  border-color: var(--ap-blue);
}

.ap-btn.primary {
  background: var(--ap-blue);
  border-color: var(--ap-blue);
  color: white;
}

/* ==========================================
   SECTION 4: TOTAL VALUE BANNER
   ========================================== */
.ap-total-banner {
  background: var(--ap-panel);
  border: 1px solid var(--ap-blue-border);
  border-radius: var(--ap-radius);
  padding: 24px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
}

.ap-total-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ap-total-label {
  font-size: 11px;
  color: var(--ap-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ap-total-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--ap-text);
  font-family: var(--ap-mono);
}

.ap-total-change {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.ap-total-change.positive { color: var(--ap-success); }
.ap-total-change.negative { color: var(--ap-danger); }

.ap-total-stats {
  display: flex;
  gap: 32px;
}

.ap-total-stat {
  text-align: center;
  padding: 0 16px;
  border-left: 1px solid var(--ap-blue-border);
}

.ap-total-stat:first-child {
  border-left: none;
}

.ap-total-stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--ap-text);
  font-family: var(--ap-mono);
}

.ap-total-stat-label {
  font-size: 10px;
  color: var(--ap-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* ==========================================
   SECTION 5: ALLOCATION BREAKDOWN
   ========================================== */
.ap-allocation-panel {
  background: var(--ap-panel);
  border: 1px solid var(--ap-blue-border);
  border-radius: var(--ap-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.ap-allocation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ap-allocation-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ap-text);
}

.ap-allocation-visual {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}

.ap-allocation-segment {
  transition: width 0.3s ease;
}

.ap-allocation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.ap-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.ap-legend-label {
  font-size: 12px;
  color: var(--ap-text);
}

.ap-legend-value {
  font-size: 12px;
  color: var(--ap-muted);
  font-family: var(--ap-mono);
}

/* ==========================================
   SECTION 6: ASSETS TABLE
   ========================================== */
.ap-assets-panel {
  background: var(--ap-panel);
  border: 1px solid var(--ap-blue-border);
  border-radius: var(--ap-radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.ap-assets-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ap-blue-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ap-assets-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ap-text);
}

.ap-assets-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-blue-border);
  border-radius: 999px;
}

.ap-assets-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--ap-text);
  font-size: 12px;
  width: 120px;
}

.ap-assets-table {
  width: 100%;
}

.ap-assets-row {
  display: grid;
  grid-template-columns: 200px 1fr 120px 120px 100px;
  gap: 12px;
  padding: 14px 20px;
  align-items: center;
  border-bottom: 1px solid rgba(43, 140, 255, 0.08);
  transition: var(--ap-transition);
}

.ap-assets-row:hover {
  background: rgba(43, 140, 255, 0.03);
}

.ap-assets-row:last-child {
  border-bottom: none;
}

.ap-assets-row.header {
  background: var(--ap-surface);
  font-size: 10px;
  font-weight: 600;
  color: var(--ap-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 20px;
}

.ap-asset-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ap-asset-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ap-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--ap-blue);
}

.ap-asset-info {
  display: flex;
  flex-direction: column;
}

.ap-asset-symbol {
  font-size: 14px;
  font-weight: 600;
  color: var(--ap-text);
}

.ap-asset-fullname {
  font-size: 11px;
  color: var(--ap-muted);
}

.ap-asset-balance {
  font-size: 14px;
  font-weight: 500;
  color: var(--ap-text);
  font-family: var(--ap-mono);
}

.ap-asset-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--ap-text);
  font-family: var(--ap-mono);
}

.ap-asset-change {
  font-size: 13px;
  font-weight: 500;
  font-family: var(--ap-mono);
}

.ap-asset-change.positive { color: var(--ap-success); }
.ap-asset-change.negative { color: var(--ap-danger); }

.ap-asset-allocation {
  text-align: right;
}

.ap-asset-pct {
  font-size: 13px;
  font-weight: 500;
  color: var(--ap-text);
}

.ap-asset-bar {
  width: 60px;
  height: 4px;
  background: var(--ap-surface);
  border-radius: 2px;
  margin-top: 4px;
  margin-left: auto;
  overflow: hidden;
}

.ap-asset-bar-fill {
  height: 100%;
  background: var(--ap-blue);
  border-radius: 2px;
}

/* ==========================================
   SECTION 7: PERFORMANCE CARDS
   ========================================== */
.ap-performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.ap-performance-card {
  background: var(--ap-panel);
  border: 1px solid var(--ap-blue-border);
  border-radius: var(--ap-radius);
  padding: 20px;
}

.ap-perf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ap-perf-title {
  font-size: 12px;
  color: var(--ap-muted);
  text-transform: uppercase;
}

.ap-perf-badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

.ap-perf-badge.positive {
  background: rgba(16, 185, 129, 0.14);
  color: var(--ap-success);
}

.ap-perf-badge.negative {
  background: rgba(239, 68, 68, 0.14);
  color: var(--ap-danger);
}

.ap-perf-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ap-text);
  font-family: var(--ap-mono);
}

.ap-perf-sub {
  font-size: 12px;
  color: var(--ap-muted);
  margin-top: 4px;
}

/* ==========================================
   SECTION 8: EMPTY & LOADING
   ========================================== */
.ap-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ap-muted);
}

.ap-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.ap-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ap-surface);
  border-top-color: var(--ap-blue);
  border-radius: 50%;
  animation: ap-spin 0.8s linear infinite;
}

@keyframes ap-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   SECTION 9: RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
  .ap-total-banner {
    grid-template-columns: 1fr;
  }
  
  .ap-total-stats {
    padding-top: 16px;
    border-top: 1px solid var(--ap-blue-border);
  }
  
  .ap-total-stat:first-child {
    border-left: none;
    padding-left: 0;
  }
  
  .ap-assets-row {
    grid-template-columns: 1fr 100px 80px;
  }
  
  .ap-assets-row > :nth-child(2),
  .ap-assets-row > :nth-child(5) {
    display: none;
  }
}

@media (max-width: 768px) {
  .admin-page-portfolio {
    padding: 16px;
  }
  
  .ap-total-value {
    font-size: 28px;
  }
  
  .ap-total-stats {
    flex-wrap: wrap;
    gap: 16px;
  }
  
  .ap-total-stat {
    border-left: none;
    padding: 0;
  }
}
