/* ══════════════════════════════════════════════════════════════════════════════
   TWF PORTAL DESIGN SYSTEM v1.0
   Production-quality CSS covering all design critique items

   Brand Tokens:
   - Primary: Navy #0C1220 | Gold #C9A84C | Cream #FAF8F3
   - Fonts: Playfair Display (headings) | DM Sans (body)
   - Border Radius: 12px (cards) | 8px (buttons/inputs)
   - Shadow: 0 4px 24px rgba(12,18,32,0.06)
   ══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 1: CUSTOM PROPERTIES & ANIMATION TIMING
   DC-028: Animation/Transition System
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* Animation timing custom properties */
  --transition-fast: 150ms;
  --transition-normal: 250ms;
  --transition-slow: 400ms;

  /* Easing functions */
  --ease-standard: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Brand color tokens */
  --color-navy: #0C1220;
  --color-gold: #C9A84C;
  --color-cream: #FAF8F3;
  --color-white: #FFFFFF;
  --color-text-primary: #0C1220;
  --color-text-secondary: #4A4D55;
  --color-text-muted: #717378;
  --color-success: #2E7D32;
  --color-error: #E53935;
  --color-warning: #F59E0B;
  --color-info: #42A5F5;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing and sizing */
  --border-radius-lg: 12px;
  --border-radius-md: 8px;
  --border-radius-sm: 4px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(12, 18, 32, 0.04);
  --shadow-md: 0 4px 24px rgba(12, 18, 32, 0.06);
  --shadow-lg: 0 12px 40px rgba(12, 18, 32, 0.1);
  --shadow-gold: 0 4px 20px rgba(201, 168, 76, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 2: ANIMATION KEYFRAMES
   ═══════════════════════════════════════════════════════════════════════════════ */

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(400px) translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(400px) translateY(-8px) scale(0.95);
  }
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes animate-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes animate-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes animate-slide-down {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes animate-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 3: DC-013 - TOAST NOTIFICATION SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-container--mobile {
  bottom: 16px;
  right: 16px;
  left: 16px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-navy);
  color: var(--color-cream);
  padding: 16px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  min-width: 280px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  animation: toast-slide-in var(--transition-normal) var(--ease-out);
  pointer-events: auto;
  border-left: 4px solid transparent;
}

/* Toast variants */
.toast--success {
  border-left-color: var(--color-success);
}

.toast--error {
  border-left-color: var(--color-error);
}

.toast--warning {
  border-left-color: var(--color-warning);
}

.toast--info {
  border-left-color: var(--color-info);
}

/* Close button */
.toast__close {
  margin-left: auto;
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: opacity var(--transition-fast) ease;
  flex-shrink: 0;
}

.toast__close:hover {
  opacity: 0.7;
}

/* Exit animation */
.toast--exit {
  animation: toast-slide-out var(--transition-normal) var(--ease-out) forwards;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 4: DC-015 - SKELETON LOADING SCREENS
   ═══════════════════════════════════════════════════════════════════════════════ */

.skeleton {
  background: #e0e0e0;
  border-radius: var(--border-radius-md);
  animation: skeleton-pulse var(--transition-slow) ease-in-out infinite;
}

.skeleton--text {
  height: 14px;
  width: 100%;
  margin: 8px 0;
}

.skeleton--text-sm {
  height: 12px;
  width: 60%;
}

.skeleton--title {
  height: 24px;
  width: 60%;
  margin: 12px 0;
  border-radius: var(--border-radius-md);
}

.skeleton--avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton--card {
  height: 120px;
  border-radius: var(--border-radius-lg);
  margin: 16px 0;
}

.skeleton--table-row {
  display: flex;
  gap: 16px;
  padding: 12px;
  border-radius: var(--border-radius-md);
  margin-bottom: 8px;
}

.skeleton--table-row > * {
  flex: 1;
  height: 16px;
  border-radius: var(--border-radius-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 5: DC-009 - RESPONSIVE TABLES
   ═══════════════════════════════════════════════════════════════════════════════ */

.table-responsive {
  position: relative;
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
  background: var(--color-white);
  box-shadow: var(--shadow-md);
}

.table-responsive table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-responsive th {
  background: rgba(12, 18, 32, 0.02);
  padding: 12px 16px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 2px solid rgba(12, 18, 32, 0.06);
}

.table-responsive td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(12, 18, 32, 0.06);
}

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

.table-responsive tbody tr:hover {
  background: rgba(201, 168, 76, 0.03);
}

.table-responsive__scroll-hint {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.8));
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal) ease;
}

.table-responsive.is-scrollable .table-responsive__scroll-hint {
  opacity: 1;
}

/* Card-based table layout for mobile */
.table-card {
  display: block;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--color-white);
  border: 1px solid rgba(12, 18, 32, 0.1);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
}

.table-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.table-card-row:not(:last-child) {
  border-bottom: 1px solid rgba(12, 18, 32, 0.06);
}

.table-card-label {
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

@media (max-width: 768px) {
  .table-responsive {
    display: none;
  }

  .table-card {
    display: block;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 6: DC-035 - PRINT STYLESHEET
   ═══════════════════════════════════════════════════════════════════════════════ */

@media print {
  /* Hide interactive elements */
  .sidebar,
  nav,
  .toast-container,
  .modal-overlay,
  .tooltip,
  button:not(.print-visible),
  .btn-primary:not(.print-visible),
  .btn-secondary:not(.print-visible),
  [role="navigation"],
  .breadcrumbs {
    display: none !important;
  }

  /* Full width layout */
  body {
    width: 100%;
    margin: 0;
    padding: 0;
    background: white;
    color: black;
    font-size: 12px;
  }

  /* Card styling for print */
  .dash-card,
  .panel,
  .card {
    page-break-inside: avoid;
    background: white;
    border: 1px solid #ccc;
    box-shadow: none;
    margin-bottom: 12px;
  }

  /* Link URLs */
  a[href]::after {
    content: ' (' attr(href) ')';
    font-size: 10px;
    color: #666;
  }

  /* Page breaks */
  .section {
    page-break-inside: avoid;
  }

  /* Force monochrome */
  * {
    background: white !important;
    color: black !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 7: DC-028 - ANIMATION & TRANSITION SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */

.animate-fade-in {
  animation: animate-fade-in var(--transition-normal) var(--ease-out);
}

.animate-slide-up {
  animation: animate-slide-up var(--transition-normal) var(--ease-out);
}

.animate-slide-down {
  animation: animate-slide-down var(--transition-normal) var(--ease-out);
}

.animate-scale-in {
  animation: animate-scale-in var(--transition-normal) var(--ease-out);
}

.transition-all {
  transition: all var(--transition-normal) ease;
}

.transition-fast {
  transition: all var(--transition-fast) ease;
}

.transition-slow {
  transition: all var(--transition-slow) ease;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .animate-fade-in,
  .animate-slide-up,
  .animate-slide-down,
  .animate-scale-in,
  .toast,
  .skeleton {
    animation: none !important;
  }

  .transition-all,
  .transition-fast,
  .transition-slow {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 8: DC-030 - ICON SYSTEM
   ═══════════════════════════════════════════════════════════════════════════════ */

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
}

/* Size variants */
.icon--sm {
  width: 16px;
  height: 16px;
}

.icon--md {
  width: 20px;
  height: 20px;
}

.icon--lg {
  width: 24px;
  height: 24px;
}

.icon--xl {
  width: 32px;
  height: 32px;
}

/* Color variants */
.icon--gold svg {
  color: var(--color-gold);
}

.icon--navy svg {
  color: var(--color-navy);
}

.icon--success svg {
  color: var(--color-success);
}

.icon--error svg {
  color: var(--color-error);
}

.icon--muted svg {
  color: var(--color-text-muted);
}

/* Icon button */
.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-fast) ease;
  color: inherit;
}

.icon-btn:hover {
  background: rgba(12, 18, 32, 0.04);
  transform: scale(1.1);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.icon-btn:active {
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 9: DC-040 - BREADCRUMB NAVIGATION
   ═══════════════════════════════════════════════════════════════════════════════ */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  flex-wrap: wrap;
}

.breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.breadcrumbs__item a {
  color: var(--color-gold);
  text-decoration: none;
  transition: all var(--transition-fast) ease;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
}

.breadcrumbs__item a:hover {
  background: rgba(201, 168, 76, 0.1);
  text-decoration: underline;
}

.breadcrumbs__item a:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.breadcrumbs__item::after {
  content: '/';
  color: var(--color-text-muted);
  margin-left: 4px;
}

.breadcrumbs__item:last-child::after {
  content: '';
  margin-left: 0;
}

.breadcrumbs__current {
  font-weight: 600;
  color: var(--color-text-primary);
  padding: 4px 8px;
}

/* Accessibility: aria-current attribute support */
.breadcrumbs__item [aria-current="page"] {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 10: DC-042 - CONTEXTUAL HELP TOOLTIPS
   ═══════════════════════════════════════════════════════════════════════════════ */

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip__trigger {
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: var(--color-text-muted);
}

.tooltip__content {
  position: absolute;
  display: none;
  background: var(--color-navy);
  color: var(--color-cream);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-family: var(--font-body);
  line-height: 1.4;
  max-width: 250px;
  white-space: normal;
  word-wrap: break-word;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  animation: animate-fade-in var(--transition-fast) ease;
  pointer-events: none;
}

.tooltip__content::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: inherit;
}

/* Position variants */
.tooltip--top .tooltip__content {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}

.tooltip--top .tooltip__content::after {
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}

.tooltip--bottom .tooltip__content {
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}

.tooltip--bottom .tooltip__content::after {
  top: -3px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}

.tooltip--left .tooltip__content {
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.tooltip--left .tooltip__content::after {
  right: -3px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.tooltip--right .tooltip__content {
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.tooltip--right .tooltip__content::after {
  left: -3px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

/* Trigger on hover or focus */
.tooltip:hover .tooltip__content,
.tooltip__trigger:focus-visible ~ .tooltip__content {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 11: DC-005 - DASHBOARD CARD REDESIGN
   ═══════════════════════════════════════════════════════════════════════════════ */

.dash-card {
  background: var(--color-white);
  border: 1px solid rgba(12, 18, 32, 0.1);
  border-top: 3px solid var(--color-gold);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal) ease;
}

.dash-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.dash-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.dash-card__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
}

.dash-card__action {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast) ease;
}

.dash-card__action:hover {
  color: var(--color-gold);
  background: rgba(201, 168, 76, 0.1);
}

.dash-card__metric {
  display: block;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.2;
  margin: 16px 0;
}

.dash-card__metric-label {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.dash-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-weight: 600;
  margin: 8px 0;
}

.dash-card__trend--up {
  background: rgba(46, 125, 50, 0.1);
  color: var(--color-success);
}

.dash-card__trend--down {
  background: rgba(229, 57, 53, 0.1);
  color: var(--color-error);
}

.dash-card__footer {
  padding-top: 16px;
  border-top: 1px solid rgba(12, 18, 32, 0.06);
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 12: DC-010 - DATA VISUALIZATION SUPPORT
   ═══════════════════════════════════════════════════════════════════════════════ */

.chart-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  background: var(--color-white);
  padding: 16px;
}

.chart-canvas {
  width: 100%;
  height: 100%;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
}

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

.chart-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: rgba(12, 18, 32, 0.02);
  border-radius: var(--border-radius-lg);
  border: 2px dashed rgba(12, 18, 32, 0.1);
  color: var(--color-text-muted);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SECTION 13: RESPONSIVE DESIGN UTILITIES
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .toast-container {
    bottom: 24px;
    right: 24px;
  }

  .dash-card {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: 100%;
    min-width: auto;
  }

  .chart-container {
    aspect-ratio: auto;
    height: 280px;
  }

  .breadcrumbs {
    font-size: 12px;
  }

  .tooltip__content {
    max-width: 200px;
    font-size: 11px;
  }
}
