/**
 * PDFEditor.pk Design System
 * Core CSS variables and base styles
 */

/* Upload Zone Component — shared across PHP, Node.js, Python stacks */
@import url('upload-zone.css');

:root {
  /* ========================================
     Brand Colors
     ======================================== */
  --brand-primary: #2563EB;
  --brand-primary-hover: #1D4ED8;
  --brand-primary-light: #DBEAFE;
  --brand-secondary: #7C3AED;
  --brand-secondary-hover: #6D28D9;
  --brand-accent: #F59E0B;
  --brand-accent-hover: #D97706;

  /* Status Colors */
  --color-success: #10B981;
  --color-success-light: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-info: #3B82F6;
  --color-info-light: #DBEAFE;

  /* ========================================
     Light Mode Colors
     ======================================== */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --bg-tertiary: #F3F4F6;
  --bg-hover: #F3F4F6;
  --bg-active: #E5E7EB;

  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-tertiary: #6B7280;
  --text-disabled: #9CA3AF;
  --text-inverse: #FFFFFF;

  --border-primary: #E5E7EB;
  --border-secondary: #D1D5DB;
  --border-focus: #2563EB;

  /* ========================================
     Dark Mode Colors
     ======================================== */
  --dark-bg: #0f172a;
  --dark-surface: #1e293b;
  --dark-surface-hover: #334155;
  --dark-border: #334155;

  --dark-text-primary: #f1f5f9;
  --dark-text-secondary: #94a3b8;
  --dark-text-tertiary: #64748b;

  /* ========================================
     Gradients
     ======================================== */
  --gradient-primary: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  --gradient-accent: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);
  --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 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-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  /* ========================================
     Typography
     ======================================== */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Fira Code', 'SF Mono', Monaco, 'Inconsolata', 'Roboto Mono', monospace;

  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */
  --text-5xl: 3rem;       /* 48px */

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* ========================================
     Spacing
     ======================================== */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

  /* ========================================
     Border Radius
     ======================================== */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */
  --radius-full: 9999px;

  /* ========================================
     Transitions
     ======================================== */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow: 300ms ease;

  /* ========================================
     Z-Index Scale
     ======================================== */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
}

/* ========================================
   Dark Mode
   ======================================== */
.dark,
[data-theme="dark"] {
  --bg-primary: var(--dark-bg);
  --bg-secondary: var(--dark-surface);
  --bg-tertiary: var(--dark-surface-hover);
  --bg-hover: var(--dark-surface-hover);

  --text-primary: var(--dark-text-primary);
  --text-secondary: var(--dark-text-secondary);
  --text-tertiary: var(--dark-text-tertiary);

  --border-primary: var(--dark-border);
  --border-secondary: var(--dark-border);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* ========================================
   Base Styles
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ========================================
   Utility Classes
   ======================================== */

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--brand-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

/* Background Colors */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-brand { background-color: var(--brand-primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-active);
}

.btn-outline {
  background: transparent;
  color: var(--brand-primary);
  border: 1px solid var(--brand-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

/* Cards */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-secondary);
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .container { padding: 0 var(--space-6); }
}

@media (min-width: 1024px) {
  .container { padding: 0 var(--space-8); }
}

/* Grid */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 768px) {
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lg\:grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* Spacing */
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* Text */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Visibility */
.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* RTL Support (for future Urdu translation) */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
[dir="rtl"] .navbar-brand { margin-left: auto; margin-right: 0; }
[dir="rtl"] .trust-badge { margin-right: auto; margin-left: 1rem; }
[dir="rtl"] .footer-links { text-align: right; }

[dir="rtl"] .text-left {
  text-align: right;
}

[dir="rtl"] .text-right {
  text-align: left;
}

/* Print */
@media print {
  .no-print { display: none !important; }
}

/* ========================================
   Accessibility
   ======================================== */

/* Skip Navigation */
.skip-nav {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand-primary);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  transition: top 0.2s;
  text-decoration: none;
  font-weight: 500;
}
.skip-nav:focus {
  top: 0;
}

/* Focus Indicators (WCAG 2.1 AA) */
*:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Reduced Motion (WCAG 2.1 AA) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Touch Targets (WCAG 2.5.5) */
@media (pointer: coarse) {
  button, a, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ========================================
   Trust & Credibility
   ======================================== */

/* Trust Badge in Header */
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
  margin-left: 0.75rem;
  opacity: 0.85;
}
.trust-badge i {
  color: var(--color-success);
  font-size: 0.85rem;
}

/* Trust Indicators near Upload Zones */
.trust-indicators {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.trust-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

/* Status Page Styles */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
}
.status-dot.operational {
  background-color: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}
.status-dot.degraded {
  background-color: var(--color-warning);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}
.status-dot.down {
  background-color: var(--color-error);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

@media (max-width: 768px) {
  .trust-badge {
    display: none;
  }
}

/* ========================================
   Shared Components
   ======================================== */

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border-secondary);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-secondary);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  color: var(--brand-primary);
  margin-bottom: var(--space-4);
}

.upload-zone .upload-text {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.upload-zone .upload-hint {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* File Card */
.file-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.file-card .file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border-radius: var(--radius-md);
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.file-card .file-info {
  flex: 1;
  min-width: 0;
}

.file-card .file-name {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card .file-size {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.file-card .file-remove {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.file-card .file-remove:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Processing Spinner */
.processing-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-8);
}

.processing-spinner .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-primary);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: ds-spin 0.8s linear infinite;
}

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

.processing-spinner .spinner-text {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-secondary);
}

.processing-spinner .progress-bar {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.processing-spinner .progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* Download Section */
.download-section {
  text-align: center;
  padding: var(--space-8);
}

.download-section .success-icon {
  font-size: 3rem;
  color: var(--color-success);
  margin-bottom: var(--space-4);
}

.download-section .success-text {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.download-section .success-detail {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-6);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-8);
  background: var(--color-success);
  color: var(--text-inverse);
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-download:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Error Card */
.error-card {
  max-width: 500px;
  margin: 2rem auto;
  padding: 2rem;
  background: white;
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--color-error, #ef4444);
  box-shadow: var(--shadow-md);
  text-align: center;
}
.error-card .error-icon { font-size: 3rem; color: var(--color-error, #ef4444); margin-bottom: 1rem; }
.error-card .error-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
.error-card .error-message { color: var(--text-tertiary); margin-bottom: 1rem; }
.error-card .error-suggestions { text-align: left; margin-top: 1rem; }
.error-card .error-suggestions li { margin-bottom: 0.5rem; }
.error-card .btn-retry { margin-top: 1rem; }

/* Dark mode adjustments for shared components */
.dark .upload-zone,
[data-theme="dark"] .upload-zone {
  background: var(--dark-surface);
  border-color: var(--dark-border);
}

.dark .upload-zone:hover,
[data-theme="dark"] .upload-zone:hover,
.dark .upload-zone.drag-over,
[data-theme="dark"] .upload-zone.drag-over {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.1);
}

.dark .file-card,
[data-theme="dark"] .file-card {
  background: var(--dark-surface);
  border-color: var(--dark-border);
}

.dark .file-card .file-icon,
[data-theme="dark"] .file-card .file-icon {
  background: rgba(37, 99, 235, 0.15);
}
