/**
 * Privacy Portal Styles
 * Self-service data rights portal for GDPR/CCPA compliance
 *
 * Features:
 * - WCAG 2.2 AA compliant
 * - Dark theme matching SignSafe design
 * - Responsive layout
 * - Accessible components
 */

/* ===========================================
   CSS Variables
   =========================================== */
:root {
  --portal-bg: #0d1117;
  --portal-card: #161b22;
  --portal-card-hover: #1c2128;
  --portal-border: #30363d;
  --portal-text: #f0f6fc;
  --portal-text-secondary: #b1bac4; /* WCAG AA: 5.2:1 contrast on #0d1117 */
  --portal-text-muted: #8b949e; /* For decorative/non-essential text only */
  --portal-primary: #3b82f6;
  --portal-primary-hover: #2563eb;
  --portal-success: #22c55e;
  --portal-warning: #f59e0b;
  --portal-error: #ef4444;
  --portal-radius: 12px;
  --portal-radius-sm: 8px;
  --portal-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ===========================================
   Base Layout
   =========================================== */
.portal-page {
  min-height: 100vh;
  background: var(--portal-bg);
  color: var(--portal-text);
  padding-top: 80px; /* Space for fixed nav */
}

.portal-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.portal-header {
  text-align: center;
  margin-bottom: 3rem;
}

.portal-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--portal-text);
}

.portal-subtitle {
  font-size: 1rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

/* ===========================================
   Navigation Tabs
   =========================================== */
.portal-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--portal-border);
  padding-bottom: 0;
  overflow-x: auto;
}

.portal-tab {
  padding: 0.875rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--portal-text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-bottom: -1px;
}

.portal-tab:hover {
  color: var(--portal-text);
}

.portal-tab.active {
  color: var(--portal-primary);
  border-bottom-color: var(--portal-primary);
}

.portal-tab:focus-visible {
  outline: 2px solid var(--portal-primary);
  outline-offset: 2px;
}

/* ===========================================
   Tab Content
   =========================================== */
.portal-section {
  display: none;
}

.portal-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================================
   Cards
   =========================================== */
.portal-card {
  background: var(--portal-card);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.portal-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.portal-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: var(--portal-text);
}

.portal-card__description {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
  margin: 0 0 1rem;
  line-height: 1.6;
}

/* ===========================================
   Data Categories List
   =========================================== */
.data-category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.data-category {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--portal-border);
}

.data-category:last-child {
  border-bottom: none;
}

.data-category__icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 102, 255, 0.1);
  border-radius: var(--portal-radius-sm);
  flex-shrink: 0;
  font-size: 1.25rem;
}

.data-category__info {
  flex: 1;
}

.data-category__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0 0 0.25rem;
}

.data-category__desc {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

.data-category__count {
  font-size: 0.8125rem;
  color: var(--portal-primary);
  font-weight: 500;
}

/* ===========================================
   Buttons
   =========================================== */
.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--portal-radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.portal-btn:focus-visible {
  outline: 2px solid var(--portal-primary);
  outline-offset: 2px;
}

.portal-btn--primary {
  background: var(--portal-primary);
  color: white;
}

.portal-btn--primary:hover {
  background: var(--portal-primary-hover);
}

.portal-btn--secondary {
  background: transparent;
  color: var(--portal-text);
  border: 1px solid var(--portal-border);
}

.portal-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--portal-text-secondary);
}

.portal-btn--danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--portal-error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.portal-btn--danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.portal-btn--sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.portal-btn svg {
  width: 18px;
  height: 18px;
}

/* ===========================================
   Consent Toggles
   =========================================== */
.consent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--portal-border);
}

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

.consent-item__info {
  flex: 1;
}

.consent-item__name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--portal-text);
  margin: 0 0 0.25rem;
}

.consent-item__desc {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

.consent-item__status {
  font-size: 0.75rem;
  color: var(--portal-text-secondary);
  margin-top: 0.25rem;
}

/* Toggle switch - reusing consent-manager styles */
.portal-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.portal-toggle__input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.portal-toggle__slider {
  position: absolute;
  inset: 0;
  background: var(--portal-border);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.portal-toggle__slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.portal-toggle__input:checked + .portal-toggle__slider {
  background: var(--portal-success);
}

.portal-toggle__input:checked + .portal-toggle__slider::before {
  transform: translateX(22px);
}

.portal-toggle__input:focus-visible + .portal-toggle__slider {
  outline: 2px solid var(--portal-primary);
  outline-offset: 2px;
}

/* ===========================================
   Activity Log
   =========================================== */
.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--portal-border);
}

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

.activity-item__icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 102, 255, 0.1);
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-item__icon--success {
  background: rgba(34, 197, 94, 0.1);
  color: var(--portal-success);
}

.activity-item__icon--warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--portal-warning);
}

.activity-item__content {
  flex: 1;
}

.activity-item__action {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--portal-text);
  margin: 0 0 0.25rem;
}

.activity-item__details {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

.activity-item__time {
  font-size: 0.75rem;
  color: var(--portal-text-secondary);
  white-space: nowrap;
}

/* ===========================================
   Deletion Section
   =========================================== */
.deletion-warning {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--portal-radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.deletion-warning__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--portal-error);
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deletion-warning__text {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
  margin: 0;
  line-height: 1.6;
}

.deletion-countdown {
  background: var(--portal-card);
  border: 1px solid var(--portal-warning);
  border-radius: var(--portal-radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.deletion-countdown__title {
  font-size: 0.875rem;
  color: var(--portal-warning);
  margin: 0 0 0.5rem;
}

.deletion-countdown__time {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--portal-text);
  margin: 0;
}

/* ===========================================
   Form Elements
   =========================================== */
.portal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--portal-bg);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius-sm);
  color: var(--portal-text);
  font-size: 0.9375rem;
  transition: border-color 0.2s ease;
}

.portal-input:focus {
  outline: none;
  border-color: var(--portal-primary);
}

.portal-input::placeholder {
  color: var(--portal-text-secondary);
}

.portal-form-group {
  margin-bottom: 1rem;
}

.portal-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--portal-text);
  margin-bottom: 0.5rem;
}

/* ===========================================
   Alerts
   =========================================== */
.portal-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--portal-radius-sm);
  margin-bottom: 1rem;
}

.portal-alert--success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: var(--portal-success);
}

.portal-alert--error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--portal-error);
}

.portal-alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.portal-alert__message {
  font-size: 0.875rem;
  margin: 0;
  line-height: 1.5;
}

/* ===========================================
   Loading State
   =========================================== */
.portal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.portal-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--portal-border);
  border-top-color: var(--portal-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ===========================================
   Empty State
   =========================================== */
.portal-empty {
  text-align: center;
  padding: 3rem 1rem;
}

.portal-empty__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.portal-empty__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0 0 0.5rem;
}

.portal-empty__text {
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

/* ===========================================
   Responsive Design
   =========================================== */
@media (max-width: 640px) {
  .portal-container {
    padding: 1.5rem 1rem 3rem;
  }

  .portal-title {
    font-size: 1.5rem;
  }

  .portal-tabs {
    gap: 0;
  }

  .portal-tab {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .portal-card {
    padding: 1rem;
  }

  .portal-btn {
    width: 100%;
  }

  .data-category {
    flex-direction: column;
    align-items: flex-start;
  }

  .consent-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .activity-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .activity-item__time {
    margin-top: 0.25rem;
  }
}

/* ===========================================
   Consent Badges & Groups (v2.0)
   =========================================== */
.consent-badge {
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.consent-badge--required {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.consent-badge--ccpa {
  background: #065f46;
  color: #d1fae5;
}

.consent-badge--cpra {
  background: #1e40af;
  color: #bfdbfe;
}

.consent-badge--ai {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
}

.consent-status-badge {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.consent-status-badge--active {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.consent-group {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--portal-border);
}

.consent-group:first-of-type {
  margin-top: 1rem;
  padding-top: 0;
  border-top: none;
}

.consent-group__title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--portal-text-secondary);
  margin: 0 0 0.5rem;
}

.consent-item--required {
  opacity: 0.8;
}

.consent-timeline {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--portal-border);
}

.portal-card__note {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--portal-radius-sm);
}

/* ===========================================
   CCPA Sale/Share Rights (v2.0)
   =========================================== */
.portal-card--warning {
  border-color: rgba(245, 158, 11, 0.3);
}

.ccpa-status-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: var(--portal-radius-sm);
  margin-bottom: 1rem;
}

.ccpa-status-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 197, 94, 0.2);
  border-radius: 50%;
  color: var(--portal-success);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ccpa-status-content {
  flex: 1;
}

.ccpa-status-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--portal-success);
  margin: 0 0 0.25rem;
}

.ccpa-status-desc {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

.gpc-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(59, 130, 246, 0.1);
  border-radius: var(--portal-radius-sm);
}

.gpc-status__icon {
  font-size: 1.25rem;
}

.gpc-status__text {
  font-size: 0.875rem;
  color: var(--portal-text);
}

.gpc-status--active {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.gpc-status--inactive {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ===========================================
   AI Transparency Section (v2.0)
   =========================================== */
.ai-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-feature {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--portal-border);
}

.ai-feature:last-child {
  border-bottom: none;
}

.ai-feature__icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(236, 72, 153, 0.1);
  border-radius: var(--portal-radius-sm);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ai-feature__content {
  flex: 1;
}

.ai-feature__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0 0 0.25rem;
}

.ai-feature__desc {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0 0 0.5rem;
}

.ai-feature__type {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f472b6;
  background: rgba(236, 72, 153, 0.15);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

.ai-data-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-data-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--portal-border);
}

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

.ai-data-item__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.ai-data-item__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--portal-text);
  margin: 0;
}

.ai-data-item__desc {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  margin: 0;
}

.ai-data-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

.ai-data-badge--inference {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.ai-data-badge--optional {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.ai-data-badge--never {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.ai-effects-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-effects-list li {
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--portal-text-secondary);
  border-bottom: 1px solid var(--portal-border);
}

.ai-effects-list li:last-child {
  border-bottom: none;
}

.ai-providers-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ai-provider {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--portal-radius-sm);
}

.ai-provider__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--portal-text);
}

.ai-provider__use {
  font-size: 0.8125rem;
  color: var(--portal-text-secondary);
  flex: 1;
}

.ai-provider__link {
  font-size: 0.8125rem;
  color: var(--portal-primary);
  text-decoration: none;
}

.ai-provider__link:hover {
  text-decoration: underline;
}

/* ===========================================
   Print Styles
   =========================================== */
@media print {
  .portal-tabs,
  .portal-btn,
  .portal-toggle {
    display: none;
  }

  .portal-section {
    display: block !important;
    break-inside: avoid;
  }

  .portal-card {
    border: 1px solid #ccc;
    background: white;
  }
}
