/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--gray-100);
  color: var(--text);
  text-decoration: none;
}

.btn:hover {
  background: var(--gray-200);
}

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  color: white;
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--debit);
  color: white;
}

.btn-danger:hover {
  color: white;
  background: #B91C1C;
}

.btn-success {
  background: var(--credit);
  color: white;
}

.btn-success:hover {
  color: white;
  background: #047857;
}

.btn-google {
  background: #4285f4;
  color: white;
}

.btn-google:hover {
  color: white;
  background: #3367d6;
}

.btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

.card-link {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}

.card-link:hover {
  text-decoration: underline;
}

/* Stat Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.stat-change {
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.positive { color: var(--success); }
.stat-change.neutral { color: var(--text-muted); }
.stat-change.negative { color: var(--error); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
}

td {
  font-size: 0.875rem;
  color: var(--text);
}

tr:hover {
  background: var(--gray-50);
}

.amount {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}

/* Forms */
.input, .textarea, .select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  transition: all 0.2s;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.input::placeholder, .textarea::placeholder {
  color: var(--text-light);
}

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

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: var(--gray-100);
  color: var(--text-muted);
}

.badge-success {
  background: var(--credit-bg);
  color: var(--credit);
}

.badge-error {
  background: var(--debit-bg);
  color: var(--debit);
}

.badge-warning {
  background: #FEF3C7;
  color: #D97706;
}

.badge-info {
  background: #DBEAFE;
  color: #2563EB;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* modal-close moved to single definition below */

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Credit Packages */
.credit-packages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.credit-package {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.credit-package:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.package-amount {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

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

/* Hide until loaded */
.stat-value, .summary-value {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.stat-value.loaded, .summary-value.loaded {
  opacity: 1;
}

/* Page content hide until data loaded */
.page-content {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.page-content.ready {
  opacity: 1;
}

/* Review Choice Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.review-choice-modal {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

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

/* modal-close - see unified definition */

.modal-body {
  padding: 1.5rem;
}

.job-info {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.info-row .value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

.info-row .value.score {
  color: var(--credit);
}

.info-row .value.score.low-score {
  color: var(--debit);
}

.issues-section {
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.issues-section h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #92400E;
}

.issues-list {
  margin: 0;
  padding-left: 1.5rem;
  color: #92400E;
  font-size: 0.875rem;
}

.issues-list li {
  margin-bottom: 0.5rem;
}

.issues-list li:last-child {
  margin-bottom: 0;
}

.decision-prompt {
  margin-bottom: 1rem;
}

.decision-prompt p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text);
  font-weight: 500;
}

.error-message {
  background: var(--debit-bg);
  color: var(--debit);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-top: 1rem;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.modal-footer .btn {
  flex: 1;
}

/* Modal transitions */
.modal-enter-active, .modal-leave-active {
  transition: opacity 0.3s;
}

.modal-enter-from, .modal-leave-to {
  opacity: 0;
}

.modal-enter-active .modal-content,
.modal-leave-active .modal-content {
  transition: transform 0.3s;
}

.modal-enter-from .modal-content,
.modal-leave-to .modal-content {
  transform: scale(0.9);
}

/* Toast animations */
@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

/* Additional badge styles for new statuses */
.badge-pending {
  background: #FEF3C7;
  color: #D97706;
}

.badge-processing {
  background: #DBEAFE;
  color: #2563EB;
}

.badge-done {
  background: var(--credit-bg);
  color: var(--credit);
}

.badge-ocr {
  background: #E0E7FF;
  color: #4F46E5;
}

.badge-text {
  background: #D1FAE5;
  color: #059669;
}

.badge-cancelled {
  background: var(--gray-200);
  color: var(--gray-600);
}

.badge-needs-review {
  background: #FED7AA;
  color: #C2410C;
}

.badge-pending-review {
  background: #BFDBFE;
  color: #1E40AF;
}

.badge-approved {
  background: #D1FAE5;
  color: #047857;
}

/* Confirm Sub-Modal */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.confirm-modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  animation: modalSlideIn 0.3s ease;
}

.confirm-icon {
  margin-bottom: 16px;
}

.confirm-modal h3 {
  font-size: 20px;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 12px;
}

.confirm-modal p {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 24px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.confirm-actions .btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.confirm-actions .btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.confirm-actions .btn-secondary:hover {
  background: #e2e8f0;
}

.confirm-actions .btn-danger {
  background: #EF4444;
  color: white;
  border: none;
}

.confirm-actions .btn-danger:hover {
  color: white;
  background: #DC2626;
}

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

/* Compact viewer table */
.viewer-compact table {
  font-size: 12px;
}
.viewer-compact th, 
.viewer-compact td {
  padding: 6px 10px;
}
.viewer-compact th {
  font-size: 11px;
}
.viewer-compact .action-buttons {
  padding: 8px 0;
  gap: 8px;
}
.viewer-compact .btn {
  padding: 6px 12px;
  font-size: 12px;
}

/* ===========================================
   GLOBAL ICON SIZING - PERMANENT FIX
   Problem: SVGs stretch/squash without explicit aspect-ratio
   Solution: Force square icons with bulletproof CSS
   =========================================== */

/* All button icons: 16px square, no exceptions */
button svg,
.btn svg,
.icon-btn svg,
a.btn svg {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    aspect-ratio: 1 / 1 !important;
    flex-shrink: 0 !important;
    display: block !important;
}

/* Large icons for empty states (48px) */
.preview-empty svg,
.empty-state svg {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    aspect-ratio: 1 / 1 !important;
}

/* Section icons (20px) per design guidelines */
.section-icon svg,
h2 svg,
h3 svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    aspect-ratio: 1 / 1 !important;
}

/* Page header icons (24px) per design guidelines */
.page-icon svg,
h1 svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    aspect-ratio: 1 / 1 !important;
}

/* Security Tab Severity Badges */
.status-badge-danger {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #dc2626 !important;
}

.status-badge-warning {
  background: rgba(245, 158, 11, 0.1) !important;
  color: #f59e0b !important;
}

.status-badge-info {
  background: rgba(251, 191, 36, 0.1) !important;
  color: #fbbf24 !important;
}

.status-badge-success {
  background: rgba(22, 163, 74, 0.1) !important;
  color: #16a34a !important;
}

/* Modal close button */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}


/* ============ Toast Notifications ============ */
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--gray-800);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--gray-200);
  font-size: 14px;
  min-width: 280px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-info {
  border-left: 4px solid var(--info);
}

.toast button {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
}

.toast button:hover {
  color: var(--gray-200);
}

/* Admin Panel Icons - consolidated from admin.css */
.nav-item svg {
    width: 20px !important;
    height: 20px !important;
}

.admin-badge svg {
    width: 14px !important;
    height: 14px !important;
}

.metric-icon svg {
    width: 20px !important;
    height: 20px !important;
}

.hamburger svg {
    width: 24px !important;
    height: 24px !important;
}

/* ============================================
   GRID UTILITIES - Standardized card layouts
   ============================================ */

/* Base grid for cards - automatically handles card margins */
.grid-cards {
  display: grid;
  gap: var(--space-sm);
}

.grid-cards > .card,
.grid-cards > [class*="card"] {
  margin-bottom: 0;
}

/* Column variants */
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* Responsive auto-fit grids */
.grid-auto-sm { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-auto-md { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* Responsive breakpoints */
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: 1fr; }
}

/* Spacing utilities */
.mb-0 { margin-bottom: 0 !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }

.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }
.gap-lg { gap: var(--space-lg) !important; }
