/* ========================================
   FINANCE SANITISATION TOOL - STYLES
   Light Mode Theme (matching Revenue/COS dashboards)
   ======================================== */

:root {
  /* Color Palette - Light Mode */
  --primary-50: #e3f2fd;
  --primary-100: #bbdefb;
  --primary-200: #90caf9;
  --primary-300: #64b5f6;
  --primary-400: #42a5f5;
  --primary-500: #2196f3;
  --primary-600: #1e88e5;
  --primary-700: #1976d2;
  --primary-800: #1565c0;
  --primary-900: #0d47a1;

  --success-50: #e8f5e9;
  --success-100: #c8e6c9;
  --success-500: #4caf50;
  --success-600: #43a047;
  --success-700: #388e3c;

  --warning-50: #fff3e0;
  --warning-500: #ff9800;
  --warning-600: #fb8c00;

  --error-50: #ffebee;
  --error-100: #ffcdd2;
  --error-500: #f44336;
  --error-600: #e53935;

  --grey-50: #fafafa;
  --grey-100: #f5f5f5;
  --grey-200: #eeeeee;
  --grey-300: #e0e0e0;
  --grey-400: #bdbdbd;
  --grey-500: #9e9e9e;
  --grey-600: #757575;
  --grey-700: #616161;
  --grey-800: #424242;
  --grey-900: #212121;

  /* Light Mode Colors */
  --background: #f8f9fa;
  --background-card: #ffffff;
  --background-card-hover: #f5f5f5;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a68;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;

  /* Brand Colors - Dynamic Brands */
  --brand-yellow: #f5a623;
  --brand-green: #27ae60;
  --brand-orange: #ff9800;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #1976d2 0%, #42a5f5 100%);
  --gradient-success: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  --gradient-header: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  --gradient-brand: linear-gradient(135deg, #f5a623 0%, #ff9800 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   HEADER
   ======================================== */
.header {
  background: var(--background-card);
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.logo-link {
  display: block;
  transition: transform var(--transition-fast);
}

.logo-link:hover {
  transform: scale(1.05);
}

.company-logo {
  height: 60px;
  width: auto;
}

.btn-text {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
}

.btn-text:hover {
  color: var(--primary-600);
  background: var(--primary-50);
}

.btn-text .material-icons {
  font-size: 1.25rem;
}

.title-section {
  display: flex;
  flex-direction: column;
}

.logo-icon {
  font-size: 2.5rem;
  color: var(--brand-yellow);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-lg);
  width: 100%;
}

/* ========================================
   SUMMARY SECTION (File Details & Net Income)
   ======================================== */
.summary-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.summary-card {
  background: var(--gradient-brand);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  color: white;
  animation: slideIn 0.5s ease-out;
}

.file-details-card {
  background: var(--gradient-primary);
}

.net-income-card {
  background: var(--gradient-brand);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.summary-icon {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.summary-icon .material-icons {
  font-size: 2rem;
  color: white;
}

.summary-content h2 {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.9;
  margin-bottom: var(--spacing-sm);
}

.summary-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing-xs);
}

.summary-subtitle {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* File Details Specific Styles */
.file-detail {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  line-height: 1.3;
}

.file-detail-sub {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: var(--spacing-xs);
}

.file-period {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-md);
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* Responsive for summary section */
@media (max-width: 900px) {
  .summary-section {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   UPLOAD SECTION
   ======================================== */
.upload-section {
  margin-bottom: var(--spacing-xl);
}

.upload-card {
  background: var(--background-card);
  border: 2px dashed var(--grey-400);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.upload-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.upload-card:hover {
  border-color: var(--primary-500);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.upload-card:hover::before {
  opacity: 0.03;
}

.upload-card.drag-over {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.upload-content {
  position: relative;
  z-index: 1;
}

.upload-icon {
  font-size: 4rem;
  color: var(--primary-500);
  margin-bottom: var(--spacing-md);
  display: block;
}

.upload-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
}

.upload-card p {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.file-types {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.file-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--background-card);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.file-info .material-icons {
  color: var(--primary-500);
}

/* ========================================
   MAPPING SECTION
   ======================================== */
.mapping-section {
  background: var(--background-card);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
}

.section-header .material-icons {
  color: var(--primary-500);
  font-size: 1.5rem;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  flex: 1;
  color: var(--text-primary);
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.mapping-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: var(--grey-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.mapping-item:hover {
  border-color: var(--primary-300);
  background: var(--background-card);
  box-shadow: var(--shadow-sm);
}

.mapping-from {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--error-100);
  color: var(--error-600);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.mapping-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

.mapping-to {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--success-100);
  color: var(--success-700);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.mapping-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.mapping-delete:hover {
  color: var(--error-500);
  background: var(--error-50);
}

.add-mapping-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  padding: var(--spacing-md);
  background: transparent;
  border: 2px dashed var(--grey-400);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.add-mapping-btn:hover {
  border-color: var(--primary-400);
  color: var(--primary-600);
  background: var(--primary-50);
}

/* ========================================
   PREVIEW SECTION
   ======================================== */
.preview-section {
  background: var(--background-card);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-left: auto;
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.toggle-label.active {
  color: var(--text-primary);
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--grey-400);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--primary-500);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(24px);
}

.table-container {
  overflow-x: auto;
  max-height: 500px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  background: var(--grey-100);
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--primary-500);
}

.data-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--grey-50);
}

.data-table .changed {
  background: var(--success-50);
}

.data-table .changed td {
  color: var(--success-700);
}

.no-data {
  text-align: center;
  padding: var(--spacing-2xl);
  color: var(--text-muted);
}

/* ========================================
   STATS SECTION
   ======================================== */
.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.stat-card {
  background: var(--background-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  transition: transform var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .material-icons {
  font-size: 2rem;
  color: var(--primary-500);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================================
   ACTION BUTTONS
   ======================================== */
.action-section {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-xl);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 200px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-success:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--grey-200);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--grey-300);
}

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--background-card);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  margin: var(--spacing-lg);
  box-shadow: var(--shadow-xl);
  animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--grey-200);
}

.modal-body {
  padding: var(--spacing-lg);
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.form-group input {
  width: 100%;
  padding: var(--spacing-md);
  background: var(--grey-50);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
  background: var(--background-card);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
  min-width: 100px;
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
  background: var(--background-card);
  padding: var(--spacing-lg);
  text-align: center;
  border-top: 1px solid var(--border-color);
}

.footer p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .header {
    padding: var(--spacing-md);
  }

  .logo-section {
    gap: var(--spacing-md);
  }

  .company-logo {
    height: 45px;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .main-content {
    padding: var(--spacing-lg) var(--spacing-md);
  }

  .summary-card {
    flex-direction: column;
    text-align: center;
  }

  .summary-value {
    font-size: 2rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .toggle-container {
    margin-left: 0;
  }

  .action-section {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--background-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  animation: toastSlide 0.3s ease-out;
  border-left: 4px solid var(--primary-500);
  color: var(--text-primary);
}

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

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

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}