/* CSS Variables for Theme Support */
:root {
  /* Light theme colors */
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --text-primary: #1d2023;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --border-color: #e9ecef;
  --border-hover: #adb5bd;
  --accent-color: #667eea;
  --accent-hover: #5a67d8;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3d3d3d;
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #a0a0a0;
  --border-color: #404040;
  --border-hover: #606060;
  --accent-color: #7c3aed;
  --accent-hover: #8b5cf6;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.4);
}

/* Reset & base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-brand h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.025em;
}

.version {
  background: var(--accent-color);
  color: white;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile hamburger menu */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  gap: 4px;
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background-color: var(--text-secondary);
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(3px, 3px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(3px, -3px);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  margin: 0;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  position: relative;
  box-sizing: border-box;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

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

.nav-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

.btn-text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* All navigation buttons use .nav-btn class */

/* Theme Toggle */
.theme-icon-wrapper {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.theme-icon {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 14px;
  line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.light-icon {
  opacity: 1;
  transform: rotate(0deg);
}

.dark-icon {
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .light-icon {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .dark-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.app-header {
  text-align: center;
  padding: 60px 20px 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.hero-content h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-content p {
  opacity: 0.9;
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.feature-badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge-feature {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.1);
}

.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 40px;
  padding: 30px 20px;
  transition: all 0.3s ease;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.footer-links a,
.footer-link-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0 12px;
}

.footer-links a:hover,
.footer-link-btn:hover {
  color: var(--accent-color);
}

.footer-links span {
  color: var(--text-muted);
  font-size: 0.875rem;
  opacity: 0.5;
}

.footer-credits {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.footer-credits a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
}

.footer-credits a:hover {
  text-decoration: underline;
}

/* Input section */
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 30px 0;
}

.input-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow-color);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.input-card h2 {
  font-size: 1.3rem;
  margin-bottom: 15px;
  color: var(--text-secondary);
  font-weight: 600;
}

.input-card input[type="file"] {
  margin-bottom: 10px;
  padding: 8px;
  width: 100%;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.input-card input[type="file"]:hover {
  border-color: var(--border-hover);
}

.input-card textarea {
  width: 100%;
  height: 200px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-card textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Actions */
.actions {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
  margin: 30px 0;
}

button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 120px;
}

.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.primary:disabled {
  background: #adb5bd;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.secondary:hover {
  background: var(--border-color);
  border-color: var(--border-hover);
}

.status {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
}

.status.success {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Summary & Results */
.summary {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 12px;
  margin: 20px 0;
  box-shadow: 0 2px 8px var(--shadow-color);
  border-left: 4px solid var(--accent-color);
  transition: all 0.3s ease;
}

.summary h3 {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.results {
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow-color);
  overflow: hidden;
  margin-top: 20px;
  transition: all 0.3s ease;
}

.legend {
  padding: 15px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: white;
}

.badge.changed {
  background: #fd7e14;
  color: white;
}

.badge.added {
  background: #28a745;
  color: white;
}

.badge.removed {
  background: #dc3545;
  color: white;
}

.badge.type {
  background: #6f42c1;
  color: white;
}

/* Diff display - Side by side view */
.diff-view {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 12px;
  transition: all 0.3s ease;
}

.diff-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.diff-column {
  padding: 8px 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-right: 1px solid var(--border-color);
}

.diff-column:last-child {
  border-right: none;
}

.left-column {
  background: var(--bg-tertiary);
}

.right-column {
  background: var(--bg-tertiary);
}

.diff-content {
  max-height: 600px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.diff-line {
  display: grid;
  grid-template-columns: 40px 1fr 40px 1fr;
  min-height: 20px;
  line-height: 20px;
  border-bottom: 1px solid var(--border-color);
}

.diff-line:hover {
  background: var(--bg-tertiary);
}

.line-number {
  padding: 0 8px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-color);
  text-align: right;
  font-size: 11px;
  user-select: none;
  min-width: 40px;
  box-sizing: border-box;
}

.line-content {
  padding: 0 8px;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  color: var(--text-primary);
}

.line-content:last-child {
  border-right: none;
}

/* Diff line types */
.diff-line.unchanged {
  background: var(--bg-secondary);
}

.diff-line.removed {
  background: #ffeef0;
}

[data-theme="dark"] .diff-line.removed {
  background: #4a1a1f;
}

.diff-line.removed .line-number {
  background: #ffdce0;
  color: #82071e;
}

[data-theme="dark"] .diff-line.removed .line-number {
  background: #3d1317;
  color: #ff6b7a;
}

.diff-line.removed .line-content {
  background: #ffeef0;
  color: #82071e;
}

[data-theme="dark"] .diff-line.removed .line-content {
  background: #4a1a1f;
  color: #ff6b7a;
}

.diff-line.added {
  background: #e6ffed;
}

[data-theme="dark"] .diff-line.added {
  background: #0d2818;
}

.diff-line.added .line-number {
  background: #cdffd8;
  color: #1a7f37;
}

[data-theme="dark"] .diff-line.added .line-number {
  background: #0a1f11;
  color: #7ee787;
}

.diff-line.added .line-content {
  background: #e6ffed;
  color: #1a7f37;
}

[data-theme="dark"] .diff-line.added .line-content {
  background: #0d2818;
  color: #7ee787;
}

.diff-line.changed {
  background: #fff8c5;
}

[data-theme="dark"] .diff-line.changed {
  background: #3d3a1a;
}

.diff-line.changed .line-number {
  background: #ffec9a;
  color: #7d4e00;
}

[data-theme="dark"] .diff-line.changed .line-number {
  background: #332e13;
  color: #f0c674;
}

.diff-line.changed .line-content {
  background: #fff8c5;
  color: #7d4e00;
}

[data-theme="dark"] .diff-line.changed .line-content {
  background: #3d3a1a;
  color: #f0c674;
}

.diff-line.type_change {
  background: #f0e5ff;
}

[data-theme="dark"] .diff-line.type_change {
  background: #2d1f3d;
}

.diff-line.type_change .line-number {
  background: #e1d4f7;
  color: #6f42c1;
}

[data-theme="dark"] .diff-line.type_change .line-number {
  background: #241731;
  color: #b19cd9;
}

.diff-line.type_change .line-content {
  background: #f0e5ff;
  color: #6f42c1;
}

[data-theme="dark"] .diff-line.type_change .line-content {
  background: #2d1f3d;
  color: #b19cd9;
}

/* Empty line placeholder */
.line-empty {
  background: #f6f8fa;
  color: transparent;
}

/* Diff section headers */
.diff-section {
  background: #f1f8ff;
  border-top: 1px solid #c0d3eb;
  border-bottom: 1px solid #c0d3eb;
  padding: 4px 8px;
  color: #0366d6;
  font-weight: 600;
  grid-column: 1 / -1;
  font-size: 11px;
}

/* Scrollbar styling */
.diff-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.diff-content::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.diff-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.diff-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease-out;
}

.modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 40px var(--shadow-hover);
  animation: slideUp 0.3s ease-out;
  border: 1px solid var(--border-color);
}

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

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
  position: relative;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  transition: all 0.2s;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.close-btn:hover {
  background: var(--border-color);
  color: var(--text-secondary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
  color: var(--text-primary);
}

.docs-section {
  margin-bottom: 30px;
}

.docs-section:last-child {
  margin-bottom: 0;
}

.docs-section h4 {
  color: var(--text-secondary);
  margin-bottom: 15px;
  font-size: 1.1rem;
  border-bottom: 2px solid var(--accent-color);
  padding-bottom: 5px;
}

.docs-section ol,
.docs-section ul {
  margin-left: 20px;
}

.docs-section li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.color-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.color-box.added {
  background: #e6ffed;
  border-color: #28a745;
}

.color-box.removed {
  background: #ffeef0;
  border-color: #dc3545;
}

.color-box.changed {
  background: #fff8c5;
  border-color: #fd7e14;
}

.color-box.unchanged {
  background: #fff;
  border-color: #6c757d;
}

.color-box.type {
  background: #f0e5ff;
  border-color: #6f42c1;
}

[data-theme="dark"] .color-box.added {
  background: #0d2818;
  border-color: #28a745;
}

[data-theme="dark"] .color-box.removed {
  background: #4a1a1f;
  border-color: #dc3545;
}

[data-theme="dark"] .color-box.changed {
  background: #3d3a1a;
  border-color: #fd7e14;
}

[data-theme="dark"] .color-box.unchanged {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}

[data-theme="dark"] .color-box.type {
  background: #2d1f3d;
  border-color: #6f42c1;
}

.docs-section pre {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  border: 1px solid var(--border-color);
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #24292e;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s;
}

[data-theme="dark"] .github-link {
  background: #f0f6fc;
  color: #24292f;
}

.github-link:hover {
  background: #1b1f23;
  color: white;
}

[data-theme="dark"] .github-link:hover {
  background: #e6edf3;
  color: #24292f;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    padding: 12px 16px;
    min-height: 56px;
    position: relative;
  }
  
  .nav-brand h1 {
    font-size: 1.125rem;
  }
  
  .nav-brand {
    gap: 8px;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    gap: 0;
    padding: 12px 16px;
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 1000;
  }
  
  .nav-links.active {
    display: flex;
  }
  
  .nav-btn {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    font-size: 0.9rem;
    gap: 8px;
    justify-content: flex-start;
    margin-bottom: 8px;
    border-radius: 8px;
  }
  
  .nav-btn:last-child {
    margin-bottom: 0;
  }
  
  .nav-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .btn-text {
    font-size: 0.9rem;
  }
  
  .theme-icon {
    font-size: 14px;
  }
  
  .hero-content h2 {
    font-size: 2rem;
  }
  
  .hero-content p {
    font-size: 1.1rem;
  }
  
  .feature-badges {
    gap: 8px;
  }
  
  .badge-feature {
    font-size: 0.8rem;
    padding: 4px 10px;
  }
  
  .inputs {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .container {
    padding: 15px;
  }
  
  .actions {
    flex-direction: column;
    gap: 10px;
  }
  
  button {
    width: 100%;
  }
  
  .legend {
    justify-content: center;
  }
  
  /* Stack diff columns vertically on mobile */
  .diff-header {
    grid-template-columns: 1fr;
  }
  
  .diff-line {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  
  .diff-line .line-number:nth-child(3),
  .diff-line .line-content:nth-child(4) {
    border-top: 1px solid #e1e4e8;
  }
  
  .diff-content {
    font-size: 11px;
  }
  
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 0 auto;
  }
  
  .modal-header {
    padding: 16px 20px;
    /* Inherit the flex layout from main styles */
  }
  
  .modal-header h3 {
    font-size: 1.25rem;
  }
  
  .modal-body {
    max-height: calc(90vh - 120px);
    padding: 16px 20px;
  }
  
  .color-legend {
    grid-template-columns: 1fr;
  }
  
  .close-btn {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .input-card textarea {
    height: 150px;
    font-size: 0.8rem;
  }
  
  .footer-links {
    flex-direction: column;
    gap: 8px;
  }
  
  .footer-links span {
    display: none;
  }
  
  .footer-links a,
  .footer-link-btn {
    padding: 4px 0;
  }
  
  .diff-content {
    font-size: 10px;
  }
  
  .line-content {
    padding: 0 4px;
  }
}
