/**
 * WooCommerce Amortization Schedules - Frontend Styles
 * Integrated from Phase B prototypes
 * Version: 27.1.0
 * 
 * CSS Isolation Strategy: All selectors use .lfamort-* prefix
 * Root container: .lfamort-schedule-container
 */

/* ============================================================================
   CSS RESET LAYER - Prevent theme CSS leakage
   ========================================================================= */

.lfamort-schedule-container,
.lfamort-schedule-container * {
  box-sizing: border-box !important;
}

.lfamort-schedule-container {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #0f172a;
  background: transparent;
}

.lfamort-schedule-container h1,
.lfamort-schedule-container h2,
.lfamort-schedule-container h3,
.lfamort-schedule-container p,
.lfamort-schedule-container ul,
.lfamort-schedule-container ol,
.lfamort-schedule-container li {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ============================================================================
   CSS CUSTOM PROPERTIES - Theming variables
   ========================================================================= */

:root {
  --lfamort-primary: #2563eb;
  --lfamort-primary-hover: #1d4ed8;
  --lfamort-secondary: #f59e42;
  --lfamort-success: #10b981;
  --lfamort-warning: #f59e0b;
  --lfamort-danger: #ef4444;
  --lfamort-bg: #ffffff;
  --lfamort-bg-secondary: #f8fafc;
  --lfamort-text: #0f172a;
  --lfamort-text-secondary: #64748b;
  --lfamort-border: #e2e8f0;
  --lfamort-border-light: #f1f5f9;
  --lfamort-radius: 8px;
  --lfamort-radius-sm: 4px;
  --lfamort-radius-lg: 12px;
  --lfamort-spacing: 16px;
  --lfamort-spacing-sm: 8px;
  --lfamort-spacing-lg: 24px;
  --lfamort-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --lfamort-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --lfamort-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   LAYOUT - Root container
   ========================================================================= */

.lfamort-schedule-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--lfamort-spacing);
}

/* ============================================================================
   HEADER - Page title and actions
   ========================================================================= */

.lfamort-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--lfamort-spacing-lg);
  padding-bottom: var(--lfamort-spacing);
  border-bottom: 2px solid var(--lfamort-border);
}

.lfamort-header__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--lfamort-text);
  margin: 0;
}

.lfamort-header__actions {
  display: flex;
  gap: var(--lfamort-spacing-sm);
  align-items: center;
}

/* ============================================================================
   BUTTONS
   ========================================================================= */

.lfamort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--lfamort-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  min-width: 44px;
}

.lfamort-btn:focus {
  outline: 2px solid var(--lfamort-primary);
  outline-offset: 2px;
}

.lfamort-btn--primary {
  background: var(--lfamort-primary);
  color: white;
  border-color: var(--lfamort-primary);
}

.lfamort-btn--primary:hover {
  background: var(--lfamort-primary-hover);
  border-color: var(--lfamort-primary-hover);
}

.lfamort-btn--secondary {
  background: white;
  color: var(--lfamort-text);
  border-color: var(--lfamort-border);
}

.lfamort-btn--secondary:hover {
  background: var(--lfamort-bg-secondary);
  border-color: var(--lfamort-text-secondary);
}

.lfamort-btn--small {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 36px;
  min-width: 36px;
}

/* ============================================================================
   SUMMARY CARDS - Existing styles enhanced
   ========================================================================= */

.lfamort-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--lfamort-spacing);
  margin-bottom: var(--lfamort-spacing-lg);
}

.lfamort-card {
  background: var(--lfamort-bg);
  border: 1px solid var(--lfamort-border);
  border-radius: var(--lfamort-radius);
  padding: var(--lfamort-spacing);
  box-shadow: var(--lfamort-shadow);
  transition: box-shadow 0.2s ease;
}

.lfamort-card:hover {
  box-shadow: var(--lfamort-shadow-md);
}

.lfamort-card__label,
.lfamort-card .metric__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--lfamort-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lfamort-card__value,
.lfamort-card .metric__value {
  font-size: 24px;
  font-weight: 700;
  color: var(--lfamort-text);
  margin-bottom: 4px;
}

.lfamort-card__help,
.lfamort-card .metric__meta {
  font-size: 12px;
  color: var(--lfamort-text-secondary);
  margin-top: 4px;
}

/* ============================================================================
   PROGRESS REGION
   ========================================================================= */

.lfamort-progress-region {
  background: var(--lfamort-bg-secondary);
  border: 1px solid var(--lfamort-border-light);
  border-radius: var(--lfamort-radius-lg);
  padding: var(--lfamort-spacing);
  margin-bottom: var(--lfamort-spacing-lg);
}

.lfamort-progress-inner {
  display: flex;
  gap: var(--lfamort-spacing);
  align-items: center;
  justify-content: space-between;
}

.lfamort-kpi {
  flex: 1 1 0;
  min-width: 0;
}

.lfamort-kpi__label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.lfamort-kpi__value {
  font-size: 18px;
  font-weight: 700;
  color: var(--lfamort-text);
}

.lfamort-progress-bar {
  width: 100%;
  height: 10px;
  background: #eef2ff;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.lfamort-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--lfamort-primary) 0%, #3b82f6 100%);
  transition: width 280ms ease;
}

/* ============================================================================
   CHART REGION
   ========================================================================= */

.lfamort-chart-region {
  background: var(--lfamort-bg);
  border: 1px solid var(--lfamort-border);
  border-radius: var(--lfamort-radius);
  padding: var(--lfamort-spacing-lg);
  margin-bottom: var(--lfamort-spacing-lg);
  box-shadow: var(--lfamort-shadow);
}

#lfamort-chart {
  width: 100%;
  height: 300px;
  position: relative;
}

.lfamort-chart-placeholder {
  width: 100%;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lfamort-bg-secondary);
  border: 2px dashed var(--lfamort-border);
  border-radius: var(--lfamort-radius);
  color: var(--lfamort-text-secondary);
  font-size: 14px;
}

/* ============================================================================
   TOOLBAR
   ========================================================================= */

.lfamort-toolbar,
#lfamort-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--lfamort-spacing);
  margin-bottom: var(--lfamort-spacing);
  padding: var(--lfamort-spacing-sm);
  background: var(--lfamort-bg-secondary);
  border-radius: var(--lfamort-radius);
}

.lfamort-toolbar__left,
.lfamort-toolbar__right {
  display: flex;
  gap: var(--lfamort-spacing-sm);
  align-items: center;
}

.lfamort-toggle {
  display: inline-flex;
  background: white;
  border: 1px solid var(--lfamort-border);
  border-radius: var(--lfamort-radius);
  overflow: hidden;
}

.lfamort-toggle__option {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--lfamort-text);
  background: white;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.lfamort-toggle__option:not(:last-child) {
  border-right: 1px solid var(--lfamort-border);
}

.lfamort-toggle__option[aria-selected="true"] {
  background: var(--lfamort-primary);
  color: white;
}

.lfamort-toggle__option:hover:not([aria-selected="true"]) {
  background: var(--lfamort-bg-secondary);
}

.lfamort-toggle__option:focus {
  outline: 2px solid var(--lfamort-primary);
  outline-offset: -2px;
  z-index: 1;
}

/* ============================================================================
   TABLE
   ========================================================================= */

.lfamort-table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--lfamort-spacing-lg);
  border-radius: var(--lfamort-radius);
  box-shadow: var(--lfamort-shadow);
}

.lfamort-table,
#amortizationTable {
  width: 100%;
  border-collapse: collapse !important;
  background: var(--lfamort-bg);
  font-size: 14px;
}

.lfamort-table caption,
#amortizationTable caption {
  padding: var(--lfamort-spacing);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  color: var(--lfamort-text);
  background: var(--lfamort-bg-secondary);
  border-bottom: 2px solid var(--lfamort-border);
}

.lfamort-table thead,
#amortizationTable thead {
  background: var(--lfamort-bg-secondary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.lfamort-table th,
#amortizationTable th {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  color: var(--lfamort-text);
  border-bottom: 2px solid var(--lfamort-border);
  white-space: nowrap;
}

.lfamort-table th.dt-center,
#amortizationTable th.dt-center {
  text-align: center;
}

.lfamort-table th.dt-right,
#amortizationTable th.dt-right {
  text-align: right;
}

.lfamort-table tbody tr,
#amortizationTable tbody tr {
  border-bottom: 1px solid var(--lfamort-border-light);
  transition: background-color 0.15s ease;
}

.lfamort-table tbody tr:hover,
#amortizationTable tbody tr:hover {
  background: var(--lfamort-bg-secondary);
}

.lfamort-table td,
#amortizationTable td {
  padding: 12px 16px;
  color: var(--lfamort-text);
  vertical-align: middle;
}

.lfamort-table td.dt-center,
#amortizationTable td.dt-center {
  text-align: center;
}

.lfamort-table td.dt-right,
#amortizationTable td.dt-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   ROW DETAILS
   ========================================================================= */

.lfamort-row-toggle {
  background: none;
  border: none;
  color: var(--lfamort-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--lfamort-radius-sm);
  transition: all 0.2s ease;
  min-height: 36px;
  min-width: 36px;
}

.lfamort-row-toggle:hover {
  background: var(--lfamort-bg-secondary);
}

.lfamort-row-toggle:focus {
  outline: 2px solid var(--lfamort-primary);
  outline-offset: 2px;
}

.lfamort-row-details {
  padding: var(--lfamort-spacing);
  background: var(--lfamort-bg-secondary);
  border-top: 1px solid var(--lfamort-border);
  border-bottom: 1px solid var(--lfamort-border);
}

.lfamort-row-details[hidden] {
  display: none;
}

.lfamort-row-details__content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--lfamort-text-secondary);
}

/* ============================================================================
   BADGES
   ========================================================================= */

.lfamort-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.lfamort-badge--success {
  background: #d1fae5;
  color: #065f46;
}

.lfamort-badge--warning {
  background: #fef3c7;
  color: #92400e;
}

.lfamort-badge--danger {
  background: #fee2e2;
  color: #991b1b;
}

.lfamort-badge--neutral {
  background: #f1f5f9;
  color: #475569;
}

/* ============================================================================
   ACCESSIBILITY
   ========================================================================= */

.lfamort-sr-only,
.screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.lfamort-live {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ============================================================================
   READER VARIANT - data-variant="reader"
   ========================================================================= */

.lfamort-schedule-container[data-variant="reader"] {
  font-size: 17px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-card {
  padding: 20px;
  background: #f8fafc;
  border-color: #dbeafe;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-card__label,
.lfamort-schedule-container[data-variant="reader"] .lfamort-card .metric__label {
  font-size: 14px;
  margin-bottom: 8px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-card__value,
.lfamort-schedule-container[data-variant="reader"] .lfamort-card .metric__value {
  font-size: 28px;
  margin-bottom: 6px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-progress-region {
  background: #f8fafc;
  border-color: #dbeafe;
  padding: 20px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-kpi__value {
  font-size: 20px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-progress-bar {
  height: 12px;
}

.lfamort-schedule-container[data-variant="reader"] .lfamort-btn {
  padding: 12px 20px;
  font-size: 15px;
  min-height: 48px;
}

/* ============================================================================
   COMPACT VARIANT - data-variant="compact"
   ========================================================================= */

.lfamort-schedule-container[data-variant="compact"] {
  font-size: 14px;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-card {
  padding: 12px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-card:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: var(--lfamort-shadow);
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-card__label,
.lfamort-schedule-container[data-variant="compact"] .lfamort-card .metric__label {
  font-size: 11px;
  color: #475569;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-card__value,
.lfamort-schedule-container[data-variant="compact"] .lfamort-card .metric__value {
  font-size: 18px;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-progress-region {
  background: transparent;
  border-color: transparent;
  padding: 12px;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-kpi__value {
  font-size: 14px;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-progress-bar {
  height: 8px;
}

.lfamort-schedule-container[data-variant="compact"] .lfamort-btn {
  padding: 8px 14px;
  font-size: 13px;
  min-height: 38px;
}

/* ============================================================================
   RESPONSIVE - Tablet: 720-1023px
   ========================================================================= */

@media (max-width: 1023px) {
  .lfamort-cards {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .lfamort-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--lfamort-spacing-sm);
  }
  
  .lfamort-toolbar,
  #lfamort-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .lfamort-toolbar__left,
  .lfamort-toolbar__right {
    width: 100%;
    justify-content: space-between;
  }
}

/* ============================================================================
   RESPONSIVE - Mobile: <720px
   ========================================================================= */

@media (max-width: 719px) {
  .lfamort-schedule-container {
    padding: var(--lfamort-spacing-sm);
  }
  
  .lfamort-cards {
    grid-template-columns: 1fr;
  }
  
  .lfamort-progress-inner {
    flex-direction: column;
    align-items: stretch;
  }
  
  .lfamort-kpi {
    width: 100%;
  }
  
  .lfamort-header__actions {
    flex-wrap: wrap;
    width: 100%;
  }
  
  .lfamort-btn {
    flex: 1;
    min-width: 120px;
  }
  
  #lfamort-chart {
    height: 250px;
  }
}

/* ============================================================================
   PRINT STYLES
   ========================================================================= */

@media print {
  .lfamort-header__actions,
  .lfamort-toolbar,
  #lfamort-toolbar,
  .lfamort-row-toggle,
  .lfamort-btn {
    display: none !important;
  }
  
  .lfamort-row-details {
    display: block !important;
  }
  
  .lfamort-card,
  .lfamort-chart-region,
  .lfamort-table-wrapper {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  
  .lfamort-table,
  #amortizationTable {
    font-size: 10px;
  }
  
  .lfamort-table th,
  .lfamort-table td,
  #amortizationTable th,
  #amortizationTable td {
    padding: 6px 8px;
  }
}

/* ============================================================================
   HIGH CONTRAST MODE
   ========================================================================= */

@media (prefers-contrast: high) {
  .lfamort-schedule-container {
    border: 2px solid currentColor;
  }
  
  .lfamort-card,
  .lfamort-progress-region,
  .lfamort-chart-region,
  .lfamort-table-wrapper {
    border: 2px solid currentColor !important;
  }
  
  .lfamort-btn {
    border: 2px solid currentColor !important;
  }
}

/* ============================================================================
   REDUCED MOTION
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .lfamort-progress-fill {
    transition: none !important;
  }
}
