/*
PDF Remediation Engine - Premium Dark Theme
*/

:root {
  --bg-base: #0f111a;
  --bg-surface: rgba(25, 28, 41, 0.7);
  --bg-surface-hover: rgba(35, 40, 58, 0.8);
  --bg-panel: rgba(20, 22, 33, 0.85);
  
  --text-primary: #f8f9fa;
  --text-secondary: #adb5bd;
  --text-muted: #6c757d;
  
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #06b6d4;
  
  --status-success: #10b981;
  --status-warning: #f59e0b;
  --status-error: #ef4444;
  --status-info: #3b82f6;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
  --glass-blur: blur(12px);
  --border-radius-lg: 16px;
  --border-radius-md: 8px;
  --border-radius-sm: 4px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Background Effects */
.ambient-bg {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.1), transparent 40%);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s infinite ease-in-out alternate;
}

.orb-1 { width: 400px; height: 400px; background: var(--accent-primary); top: -100px; right: -100px; animation-delay: 0s; }
.orb-2 { width: 300px; height: 300px; background: var(--accent-secondary); bottom: 20%; left: -50px; animation-delay: -5s; }
.orb-3 { width: 250px; height: 250px; background: var(--accent-tertiary); top: 40%; right: 20%; animation-delay: -10s; }

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 50px) scale(1.1); }
  100% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Layout */
header {
  height: 60px;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 1.1rem;
  background: linear-gradient(to right, var(--accent-primary), var(--accent-tertiary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.main-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Panels */
.panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}

.sidebar-left {
  width: 300px;
  min-width: 300px;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.sidebar-right {
  width: 350px;
  min-width: 350px;
  border-left: 1px solid var(--border-light);
  border-right: none;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-right.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
  transform: translateX(100%);
}

/* Common UI Elements */
.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-primary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-icon {
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
}
.btn-icon:hover {
  background: var(--bg-surface);
}

/* Upload View */
#upload-view {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-base);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.upload-box {
  width: 100%;
  max-width: 600px;
  height: 300px;
  border: 2px dashed var(--accent-primary);
  border-radius: var(--border-radius-lg);
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-glow);
}

.upload-box:hover, .upload-box.dragover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-tertiary);
  transform: scale(1.02);
}

.upload-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 40px;
  max-width: 1000px;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  padding: 16px;
  text-align: center;
}

.feature-card h3 { font-size: 1rem; margin-bottom: 8px; color: var(--accent-tertiary); }
.feature-card p { font-size: 0.8rem; color: var(--text-secondary); }

/* Analysis View */
#analysis-view {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-base);
  z-index: 90;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--bg-surface);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}

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

/* Workspace Preview Area */
.pdf-preview-container {
  flex: 1;
  background: #2a2a35;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  padding: 20px;
}

.pdf-page-wrapper {
  position: relative;
  background: white;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.pdf-page-img {
  display: block;
  max-width: none;
}

/* Overlays */
.pdf-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.overlay-box {
  position: absolute;
  border: 2px solid;
  background: rgba(0,0,0,0.1);
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.2s ease;
}

.overlay-box:hover {
  background: rgba(255,255,255,0.3);
}

.overlay-contrast { border-color: var(--status-error); background: rgba(239, 68, 68, 0.2); }
.overlay-table { border-color: var(--status-info); }
.overlay-form { border-color: var(--accent-secondary); }

/* Toolbars */
.toolbar {
  height: 50px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.module-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--accent-tertiary);
  border-bottom-color: var(--accent-tertiary);
}

/* Chat Panel */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-user {
  background: var(--accent-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-ai {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: white;
  padding: 10px;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  resize: none;
  height: 40px;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Issue Cards */
.issue-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.issue-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.issue-card.active {
  border-color: var(--accent-tertiary);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge-success { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-md);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

/* Interactive Table Grid */
.grid-editor-container {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #2a2a35;
  display: flex;
  justify-content: center;
}

.grid-table {
  border-collapse: collapse;
  background: white;
}

.grid-cell {
  border: 1px solid #ccc;
  padding: 8px;
  min-width: 80px;
  height: 40px;
  text-align: center;
  cursor: pointer;
  color: #333;
  user-select: none;
}

.grid-cell.th {
  background: #e0f2fe;
  font-weight: bold;
}
.grid-cell.selected {
  outline: 2px solid var(--accent-primary);
  background: #fffbeb;
}

/* Form Editor */
.form-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
}
.form-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  color: white;
  padding: 6px;
  border-radius: 4px;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface);
  border-left: 4px solid var(--accent-primary);
  padding: 12px 20px;
  border-radius: 4px;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease forwards;
  backdrop-filter: blur(10px);
}
.toast.error { border-color: var(--status-error); }
.toast.success { border-color: var(--status-success); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
