:root {
  --bg-color: #0f172a;
  --text-color: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #6366f1;
  --accent-glow: #818cf8;
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --success: #10b981;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}

/* Dynamic Background Blobs */
.background-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(80px);
  opacity: 0.6;
  animation: drift 20s infinite alternate;
}

.blob-1 {
  top: -10%;
  left: -10%;
  width: 50vw;
  height: 50vw;
  background: #4f46e5;
}

.blob-2 {
  bottom: -10%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: #0ea5e9;
  animation-delay: -5s;
}

.blob-3 {
  top: 40%;
  left: 40%;
  width: 40vw;
  height: 40vw;
  background: #ec4899;
  animation-delay: -10s;
}

@keyframes drift {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(30px, 50px) scale(1.1);
  }
}

.app-container {
  width: 100%;
  max-width: 1400px;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 0.8s ease-out;
}

.logo {
  font-size: 2.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo i {
  color: var(--accent-color);
  -webkit-text-fill-color: initial;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 10px;
  font-size: 1rem;
}

/* Split Layout */
.split-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  align-items: start;
}

@media (max-width: 900px) {
  .split-view {
    grid-template-columns: 1fr;
  }
}

/* Glass Panels */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  margin-bottom: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.glass-panel:hover {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Upload Section */
.upload-area {
  border: 2px dashed var(--glass-border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--accent-color);
  background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
  font-size: 3rem;
  color: var(--accent-color);
  margin-bottom: 15px;
  display: block;
}

.file-types {
  display: block;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Preview Section */
.image-wrapper {
  position: relative;
  max-height: 400px;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
}

/* Preview Section Updates */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
}

.file-list-container {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  margin-bottom: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.2s;
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  width: 100%; /* Ensure it takes available space */
}

.file-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--glass-border);
}

.file-icon-placeholder {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 1.2rem;
  color: var(--accent-color);
  flex-shrink: 0;
}

.file-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* max-width removed to let flexbox handle it */
  font-size: 0.9rem;
}

.file-remove-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
}

.preview-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 15px;
}

.remove-btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
}
.remove-btn-text:hover {
  color: #ef4444;
}

/* Toggle Switch */
.toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #334155;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

#image-preview {
  max-width: 100%;
  max-height: 400px;
  display: inline-block;
  border-radius: 12px;
}

.pdf-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-color);
}

.pdf-preview i {
  font-size: 5rem;
  color: #ef4444; /* PDF color RED */
  margin-bottom: 20px;
}

.pdf-preview p {
  font-size: 1.1rem;
  color: var(--text-color);
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 16px;
  border-radius: 8px;
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-btn:hover {
  background: #ef4444;
}

.action-btn {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent-color), #4338ca);
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Result Section */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 15px;
}

.result-content {
  background: rgba(15, 23, 42, 0.6);
  padding: 20px;
  border-radius: 12px;
  min-height: 400px;
  max-height: 700px;
  overflow-y: auto;
  overflow-x: auto; /* Enable horizontal scrolling */
  font-family: "Inter", sans-serif;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: normal;
  flex-grow: 1;
  width: 600px; /* Force fixed width */
  max-width: 100%; /* Prevent exceeding parent width on small screens */
  margin: 0 auto; /* Center the content horizontally */
}

/* Markdown Styles */
.result-content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
}

.result-content th,
.result-content td {
  padding: 12px 15px;
  text-align: left;
  border: 1px solid var(--glass-border);
}

.result-content th {
  background-color: rgba(99, 102, 241, 0.2);
  color: #fff;
  font-weight: 600;
}

.result-content tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.result-content h1,
.result-content h2,
.result-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.result-content p {
  margin-bottom: 1rem;
}

.result-content ul,
.result-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

/* Result Blocks */
.file-result-block {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
}

.file-result-block h3 {
  margin-top: 0;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
  margin-bottom: 15px;
  font-size: 1.1rem;
  color: var(--accent-color);
}



/* Scrollbar styling for result content */
.result-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.result-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}
.result-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  margin-left: 10px;
  padding: 5px;
  border-radius: 5px;
  transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.1);
}

/* Loader */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Utilities */
.hidden {
  display: none !important;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
