/* ==========================================================================
   ContaAzul Flow - Sistema de Conversão de Extratos Bancários para Conta Azul
   Design System & UI Components
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Color Palette - Dark Elegance with Conta Azul Blue & Emerald */
  --bg-app: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 35, 54, 0.85);
  --bg-input: rgba(13, 19, 32, 0.8);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #0070f3;
  --accent-gradient: linear-gradient(135deg, #0070f3 0%, #00c6ff 100%);
  --accent-hover: #0056b3;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.25);

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.25);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);

  --brand-contaazul: #0080ff;
  --brand-santander: #ec0000;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(0, 112, 243, 0.25);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: #f8fafc;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: #0070f3;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(0, 112, 243, 0.15);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 112, 243, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 28px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-badge {
  width: 46px;
  height: 46px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  box-shadow: var(--shadow-glow);
}

.brand-titles h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles .tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  border-radius: 20px;
}

.brand-titles p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 1px solid transparent;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 112, 243, 0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 112, 243, 0.5);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Dropdown Menu */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.dropdown-container.active .dropdown-menu {
  display: flex;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

/* Upload Dropzone Section */
.upload-hero {
  margin-bottom: 32px;
}

.dropzone-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 2px dashed rgba(0, 112, 243, 0.3);
  border-radius: var(--radius-xl);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dropzone-card:hover, .dropzone-card.drag-over {
  border-color: var(--brand-contaazul);
  background: rgba(0, 112, 243, 0.06);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}

.dropzone-icon-wrapper {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(0, 112, 243, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 32px;
  animation: pulseSlow 3s infinite ease-in-out;
}

.dropzone-text h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.dropzone-text p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.dropzone-badges {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge-feature {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-secondary);
}

/* File Queue / Tabs */
.files-queue-section {
  display: none;
  margin-bottom: 24px;
}

.files-queue-section.has-files {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.file-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-chip:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.file-chip.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary), var(--shadow-sm);
  background: rgba(0, 112, 243, 0.08);
}

.file-chip-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-chip-icon {
  font-size: 20px;
  color: var(--danger);
}

.file-chip-text {
  min-width: 0;
}

.file-chip-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-chip-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-chip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 16px;
  transition: color var(--transition-fast);
}

.btn-chip-remove:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Progress Overlay */
.progress-bar-container {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  width: 0%;
  transition: width 0.2s ease;
}

/* Stats / KPI Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
}

.stat-card.stat-credits::before { background: var(--success); }
.stat-card.stat-debits::before { background: var(--danger); }
.stat-card.stat-balance::before { background: var(--accent-primary); }
.stat-card.stat-count::before { background: var(--warning); }

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}

.stat-value.credits { color: var(--success); }
.stat-value.debits { color: var(--danger); }
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

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

/* Data Table Container */
.data-section {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Toolbar */
.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 240px;
}

.search-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 14px 8px 36px;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--border-focus);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.filter-pills {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.filter-pill {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Table Wrapper */
.table-responsive {
  max-height: 540px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}

.financial-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.financial-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #111726;
}

[data-theme="light"] .financial-table thead {
  background: #e2e8f0;
}

.financial-table th {
  padding: 12px 14px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.financial-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: background var(--transition-fast);
  vertical-align: middle;
}

.financial-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .financial-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

.financial-table tr.unselected td {
  opacity: 0.4;
  text-decoration: line-through;
}

/* Table Column Specifics */
.col-check { width: 36px; text-align: center; }
.col-date { width: 110px; font-family: var(--font-mono); font-size: 0.8rem; }
.col-val { width: 130px; font-family: var(--font-mono); font-weight: 600; text-align: right; }
.col-desc { min-width: 260px; font-weight: 500; }
.col-cat { min-width: 170px; }
.col-client { min-width: 160px; }
.col-cost { min-width: 130px; }
.col-action { width: 44px; text-align: center; }

/* Editable Cells */
.editable-cell {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border-color var(--transition-fast);
}

.editable-cell:hover {
  border-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
}

.editable-cell input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  color: var(--text-primary);
  font-family: inherit;
  font-size: inherit;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  outline: none;
}

.badge-date {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.val-credit { color: var(--success); }
.val-debit { color: var(--danger); }

/* Table Footer / Summary Bar */
.table-footer-bar {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 48px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  max-width: 420px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease-out;
}

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

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

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

.modal-window {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 640px;
  width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulseSlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Responsive */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    width: 100%;
  }
}
