﻿/* ============================================================
   GitImsi Dashboard — Client Portal Page Styles
   ============================================================ */

/* --- Login Gate --- */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.login-gate.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-gate-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.login-gate-bg .grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  padding: var(--space-3xl);
}

.login-card .card-content {
  position: relative;
  z-index: 2;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-2xl);
}

.login-logo .logo-icon {
  width: 48px;
  height: 48px;
}

.login-logo .logo-text {
  font-size: 1.8rem;
  font-weight: var(--font-weight-extrabold);
}

.login-title {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--space-2xl);
}

.login-form .form-group {
  margin-bottom: var(--space-lg);
}

.login-form .form-label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.login-form .form-label svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.login-form .form-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-primary);
}

.login-btn {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  margin-top: var(--space-sm);
}

.login-btn .btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.login-btn.loading .btn-spinner {
  display: inline-block;
}

.login-btn.loading .btn-text {
  display: none;
}

.demo-notice {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--accent-indigo-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.demo-notice strong {
  color: var(--accent-indigo-glow);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* --- Dashboard Layout --- */
.dashboard-wrapper {
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.dashboard-wrapper.visible {
  display: block;
  opacity: 1;
}

.dashboard-content {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
}

/* --- Dashboard Header --- */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2xl);
  flex-wrap: wrap;
  gap: var(--space-lg);
}

.dash-welcome h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-xs);
}

.dash-welcome .welcome-name {
  color: var(--accent-indigo-glow);
}

.dash-last-login {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.dash-last-login svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.dash-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.dash-actions .btn svg {
  width: 16px;
  height: 16px;
}

/* --- Metrics Row --- */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.metric-glass-card {
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.metric-glass-card:hover {
  transform: translateY(-4px);
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.metric-icon.indigo {
  background: var(--accent-indigo-muted);
  color: var(--accent-indigo-glow);
}

.metric-icon.emerald {
  background: var(--accent-emerald-muted);
  color: var(--accent-emerald-glow);
}

.metric-icon.amber {
  background: var(--accent-amber-muted);
  color: var(--accent-amber-glow);
}

.metric-icon.cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.metric-icon svg {
  width: 22px;
  height: 22px;
}

.metric-glass-card .metric-value {
  font-size: 2rem;
  font-weight: var(--font-weight-black);
  line-height: 1;
  margin-bottom: var(--space-xs);
  text-align: left;
}

.metric-glass-card .metric-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: left;
  margin-bottom: var(--space-sm);
}

.metric-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: var(--font-weight-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.metric-trend.up {
  color: var(--accent-emerald-glow);
  background: var(--accent-emerald-muted);
}

.metric-trend.down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.15);
}

.metric-trend.neutral {
  color: var(--text-tertiary);
  background: rgba(100, 116, 139, 0.15);
}

.metric-trend svg {
  width: 12px;
  height: 12px;
}

.metric-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--accent-emerald-glow);
}

.metric-status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: pulse-dot 2s ease-in-out infinite;
}

/* --- Dashboard Sections Grid --- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.dash-grid.full-width {
  grid-template-columns: 1fr;
}

.dash-section {
  padding: 0;
  overflow: visible;
}

.dash-section .card-content {
  position: relative;
  z-index: 2;
}

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.dash-section-title {
  font-size: 1.1rem;
  font-weight: var(--font-weight-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.dash-section-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-indigo-glow);
}

/* --- Campaign Tracker (Full Width Table) --- */
.campaign-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  gap: var(--space-md);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.search-box .form-input {
  padding-left: 38px;
  width: 100%;
  background: var(--bg-primary);
  font-size: 0.85rem;
}

.campaign-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

.campaign-table thead {
  background: var(--bg-tertiary);
}

.campaign-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

.campaign-table th:hover {
  color: var(--accent-indigo-glow);
}

.campaign-table th .sort-icon {
  display: inline-flex;
  margin-left: 4px;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.campaign-table th:hover .sort-icon,
.campaign-table th.sorted .sort-icon {
  opacity: 1;
}

.campaign-table th.sorted {
  color: var(--accent-indigo-glow);
}

.campaign-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(99, 102, 241, 0.07);
  white-space: nowrap;
}

.campaign-table tbody tr {
  transition: background var(--transition-fast);
}

.campaign-table tbody tr:hover {
  background: var(--accent-indigo-soft);
}

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

.campaign-name {
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.campaign-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.campaign-platform .platform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.platform-dot.google { background: #4285f4; }
.platform-dot.meta { background: #1877f2; }
.platform-dot.linkedin { background: #0a66c2; }
.platform-dot.tiktok { background: #ff0050; }
.platform-dot.twitter { background: #1da1f2; }
.platform-dot.programmatic { background: #f59e0b; }

/* Status badges for campaigns */
.status-active {
  background: var(--accent-emerald-muted);
  color: var(--accent-emerald-glow);
}

.status-paused {
  background: var(--accent-amber-muted);
  color: var(--accent-amber-glow);
}

.status-optimizing {
  background: var(--accent-indigo-muted);
  color: var(--accent-indigo-glow);
}

.roas-value {
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
}

.roas-value.high { color: var(--accent-emerald-glow); }
.roas-value.medium { color: var(--accent-amber-glow); }
.roas-value.low { color: var(--text-secondary); }

.campaign-actions-cell {
  display: flex;
  gap: var(--space-xs);
}

.action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--accent-indigo-muted);
  color: var(--accent-indigo-glow);
}

.action-btn svg {
  width: 14px;
  height: 14px;
}

/* --- Proxy Allocation Panel --- */
.proxy-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.proxy-stat {
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.proxy-stat-value {
  font-size: 1.4rem;
  font-weight: var(--font-weight-bold);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}

.proxy-stat-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.proxy-usage-section {
  margin-bottom: var(--space-lg);
}

.proxy-usage-section h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  font-weight: var(--font-weight-medium);
}

.usage-bar {
  margin-bottom: var(--space-md);
}

.usage-bar-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
  font-size: 0.8rem;
}

.usage-bar-label {
  color: var(--text-secondary);
}

.usage-bar-value {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
}

.progress-bar.proxy {
  height: 8px;
  background: var(--bg-primary);
}

.progress-fill.indigo {
  background: linear-gradient(90deg, var(--accent-indigo), var(--accent-indigo-glow));
}

.progress-fill.emerald {
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-emerald-glow));
}

.progress-fill.amber {
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-amber-glow));
}

.region-distribution {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.region-item {
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.region-flag {
  font-size: 1.4rem;
  margin-bottom: var(--space-xs);
}

.region-name {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.region-pct {
  font-size: 1rem;
  font-weight: var(--font-weight-bold);
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* --- Data Delivery --- */
.delivery-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.delivery-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.delivery-item:hover {
  border-color: var(--glass-border);
  background: var(--accent-indigo-soft);
}

.delivery-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-indigo-muted);
  color: var(--accent-indigo-glow);
}

.delivery-icon svg {
  width: 18px;
  height: 18px;
}

.delivery-info {
  flex: 1;
  min-width: 0;
}

.delivery-name {
  font-size: 0.85rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delivery-meta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: flex;
  gap: var(--space-md);
}

.delivery-status {
  flex-shrink: 0;
}

.delivery-download {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--accent-emerald-glow);
  background: var(--accent-emerald-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  cursor: pointer;
}

.delivery-download:hover {
  background: var(--accent-emerald);
  color: white;
}

.delivery-download svg {
  width: 14px;
  height: 14px;
}

.delivery-download.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Task Queue --- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.task-item {
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

.task-type {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  font-weight: var(--font-weight-medium);
}

.task-type-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.task-type-icon.scrape { background: var(--accent-indigo-muted); color: var(--accent-indigo-glow); }
.task-type-icon.report { background: var(--accent-emerald-muted); color: var(--accent-emerald-glow); }
.task-type-icon.deploy { background: var(--accent-amber-muted); color: var(--accent-amber-glow); }
.task-type-icon.audit { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.task-eta {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.task-progress-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.task-progress-bar {
  flex: 1;
}

.task-progress-bar .progress-bar {
  height: 6px;
}

.task-pct {
  font-size: 0.78rem;
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-mono);
  color: var(--accent-indigo-glow);
  min-width: 36px;
  text-align: right;
}

/* --- Activity Feed --- */
.activity-feed {
  position: relative;
  padding-left: var(--space-xl);
}

.activity-feed::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent-indigo-muted), var(--border-subtle), transparent);
}

.activity-item {
  position: relative;
  padding-bottom: var(--space-lg);
}

.activity-item:last-child {
  padding-bottom: 0;
}

.activity-dot {
  position: absolute;
  left: calc(-1 * var(--space-xl) + 5px);
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.activity-dot.indigo { background: var(--accent-indigo); }
.activity-dot.emerald { background: var(--accent-emerald); }
.activity-dot.amber { background: var(--accent-amber); }
.activity-dot.neutral { background: var(--text-tertiary); }

.activity-time {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}

.activity-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .proxy-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-actions {
    width: 100%;
  }

  .dash-actions .btn {
    flex: 1;
  }

  .proxy-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .region-distribution {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .campaign-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: 100%;
  }

  .login-card {
    margin: var(--space-md);
    padding: var(--space-xl);
  }

  .dashboard-content {
    padding: var(--space-lg) var(--space-md);
  }
}

@media (max-width: 480px) {
  .proxy-stats {
    grid-template-columns: 1fr 1fr;
  }

  .region-distribution {
    grid-template-columns: 1fr;
  }
}

/* --- 480px Mobile --- */
@media (max-width: 480px) {
    .dash-stats-grid { grid-template-columns: 1fr !important; }
    .dash-charts-grid { grid-template-columns: 1fr !important; }
    .dash-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .dash-header { flex-direction: column; gap: var(--space-sm); }
}