/* Invoice Reader - Custom Styles */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: #1e293b;
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-height: 100vh;
  background: #1e293b;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  color: #f1f5f9;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  color: #94a3b8;
  font-size: 11px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-title {
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0 12px;
  margin: 16px 0 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover { background: #334155; color: #e2e8f0; }
.nav-item.active { background: #2563eb; color: #fff; }
.nav-item i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid #334155;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #334155;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { color: #f1f5f9; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #94a3b8; font-size: 11px; }

/* Main content */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  padding: 0;
}

.page-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title { font-size: 20px; font-weight: 700; color: #0f172a; }
.page-subtitle { font-size: 13px; color: #64748b; margin-top: 2px; }

.page-body { padding: 28px 32px; }

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 600; color: #0f172a; }
.card-body { padding: 20px; }

/* Stats cards */
.stat-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.yellow { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }

.stat-value { font-size: 26px; font-weight: 700; color: #0f172a; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-outline { background: transparent; border: 1px solid #e2e8f0; color: #475569; }
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  font-size: 13px;
  color: #374151;
  border-bottom: 1px solid #f1f5f9;
}

tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-draft { background: #f1f5f9; color: #475569; }
.badge-pending { background: #fffbeb; color: #92400e; }
.badge-approved { background: #f0fdf4; color: #166534; }
.badge-rejected { background: #fef2f2; color: #991b1b; }
.badge-exported { background: #eff6ff; color: #1e40af; }
.badge-blue { background: #eff6ff; color: #1e40af; }
.badge-green { background: #f0fdf4; color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .required { color: #dc2626; margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #1f2937;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea { resize: vertical; min-height: 100px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.upload-zone i { font-size: 48px; color: #93c5fd; margin-bottom: 16px; }
.upload-zone h3 { font-size: 16px; font-weight: 600; color: #374151; }
.upload-zone p { font-size: 13px; color: #9ca3af; margin-top: 4px; }

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

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.2s ease-out;
}

.modal-lg { max-width: 900px; }
.modal-sm { max-width: 400px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; color: #0f172a; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #9ca3af;
  transition: all 0.15s;
  background: none;
  border: none;
  font-size: 18px;
}
.modal-close:hover { background: #f1f5f9; color: #374151; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  justify-content: center;
}

.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #374151;
  transition: all 0.15s;
}

.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
}

.login-logo h1 { font-size: 24px; font-weight: 800; color: #0f172a; }
.login-logo p { font-size: 14px; color: #64748b; margin-top: 4px; }

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

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

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: toastIn 0.3s ease-out;
  cursor: pointer;
}

.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-warning { background: #92400e; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Loading */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}

/* Progress bar for OCR */
.ocr-progress {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.progress-bar-wrap {
  background: #e2e8f0;
  border-radius: 100px;
  height: 8px;
  margin: 16px 0;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  transition: width 0.3s ease;
}

/* Invoice items table */
.items-table input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.items-table input:focus {
  outline: none;
  border-color: #2563eb;
}

.items-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .page-header { padding: 14px 16px; }
  .login-card { padding: 28px 20px; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: #9ca3af;
}

.empty-state i { font-size: 56px; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: #374151; }
.empty-state p { font-size: 14px; margin-top: 4px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Search input */
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: 14px; }
.search-wrap input { padding-left: 36px; }

/* Tab nav */
.tab-nav {
  display: flex;
  gap: 2px;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active { background: #fff; color: #2563eb; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.tab-btn:hover:not(.active) { color: #374151; }

/* Status steps */
.status-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
}

.step {
  flex: 1;
  text-align: center;
  position: relative;
}

.step::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: #e2e8f0;
}

.step:last-child::after { display: none; }
.step.done::after { background: #16a34a; }

.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  position: relative;
  z-index: 1;
  background: #e2e8f0;
  color: #9ca3af;
}

.step.done .step-dot { background: #16a34a; color: #fff; }
.step.current .step-dot { background: #2563eb; color: #fff; }
.step-label { font-size: 11px; color: #9ca3af; font-weight: 500; }
.step.done .step-label, .step.current .step-label { color: #374151; }

/* Image preview */
.img-preview {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  object-fit: contain;
  background: #f8fafc;
}

/* Dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background 0.1s;
}

.dropdown-item:hover { background: #f8fafc; }
.dropdown-item.danger { color: #dc2626; }
.dropdown-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }

/* Mapped / unmapped indicator */
.mapped-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.mapped-dot.yes { background: #16a34a; }
.mapped-dot.no { background: #f59e0b; }
