/* ===========================
   ChatGPT-Style Modern UI
   =========================== */

:root {
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --primary-color: #10a37f;
  --secondary-color: #19c37d;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-dark: #202123;
  --text-primary: #353740;
  --text-secondary: #6e6e80;
  --border-color: #e5e5e5;
  --hover-bg: #f7f7f8;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", sans-serif;
  color: var(--text-primary);
  background: var(--bg-secondary);
  overflow: hidden;
}

/* ===========================
   Layout Structure
   =========================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-dark);
  color: white;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Keep toggle button visible when sidebar is collapsed */
.sidebar.collapsed .btn-toggle-sidebar {
  position: fixed;
  left: 24px;
  top: 12px;
  transform: translateX(calc(var(--sidebar-width)));
  z-index: 1001;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.sidebar.collapsed .btn-toggle-sidebar:hover {
  background: var(--primary-dark);
}

/* Adjust topbar when sidebar is collapsed to make room for button */
.sidebar.collapsed ~ .main-container .topbar {
  padding-left: 80px;
}

.main-container {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-container {
  margin-left: 0;
}

/* ===========================
   Sidebar
   =========================== */

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  gap: 8px;
}

.btn-new-chat {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-new-chat:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-toggle-sidebar {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-sidebar:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 8px;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.history-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 12px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.history-item.active {
  background: rgba(255, 255, 255, 0.15);
}

.history-item i {
  font-size: 12px;
  opacity: 0.7;
}

.history-item-content {
  flex: 1;
  overflow: hidden;
}

.history-item-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

.history-item-actions {
  opacity: 0;
  transition: opacity 0.2s;
}

.history-item:hover .history-item-actions {
  opacity: 1;
}

.btn-delete-history {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.btn-delete-history:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-settings {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-settings:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ===========================
   Top Bar
   =========================== */

.topbar {
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.btn-toggle-sidebar.mobile {
  display: none;
}

.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
}

/* ===========================
   Main Content
   =========================== */

.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* Welcome Screen */
.welcome-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.welcome-content {
  text-align: center;
  max-width: 600px;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 36px;
}

.welcome-content h2 {
  font-size: 28px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.welcome-content p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 32px;
}

.quick-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.quick-action-btn {
  padding: 16px 24px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  min-width: 160px;
}

.quick-action-btn:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.quick-action-btn i {
  font-size: 32px;
  color: var(--primary-color);
}

.quick-action-btn span {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Chat Container */
.chat-container {
  height: calc(100vh - var(--topbar-height) - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
}

.messages-area {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-x: hidden;
  width: 100%;
}

/* Message Styles */
.message {
  display: flex;
  gap: 16px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--primary-color);
  color: white;
}

.message.ai .message-avatar {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.message-content {
  flex: 1;
  padding-top: 6px;
  overflow-x: hidden;
  max-width: 100%;
}

.message-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.message-file-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.message-actions button {
  padding: 8px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.message-actions button:hover {
  background: var(--secondary-color);
  transform: translateY(-1px);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ===========================
   Input Area
   =========================== */

.input-area {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 20px 24px;
  transition: left 0.3s ease;
}

.sidebar.collapsed ~ .main-container .input-area {
  left: 0;
}

.input-container {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 12px;
  transition: all 0.2s;
}

.input-container:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.btn-attach {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-attach:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 8px;
  color: var(--text-primary);
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-secondary);
}

.btn-send {
  width: 36px;
  height: 36px;
  background: var(--primary-color);
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-send:hover {
  background: var(--secondary-color);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===========================
   Results Panel
   =========================== */

.results-panel {
  position: fixed;
  right: 0;
  top: var(--topbar-height);
  bottom: 0;
  width: 600px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 999;
}

.results-panel.show {
  transform: translateX(0);
}

.results-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.results-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-toolbar {
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-info {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-controls {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-sm:hover {
  background: var(--hover-bg);
  border-color: var(--text-secondary);
}

#resultTable {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

/* ===========================
   Tabulator Overrides
   =========================== */

.tabulator {
  border: none;
  font-size: 13px;
}

.tabulator .tabulator-header {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

.tabulator .tabulator-header .tabulator-col {
  background: transparent;
  border-right: 1px solid var(--border-color);
}

.tabulator-row {
  border-bottom: 1px solid var(--border-color);
}

.tabulator-row:hover {
  background: var(--hover-bg);
}

.tabulator .tabulator-cell {
  border-right: 1px solid var(--border-color);
}

/* ===========================
   Utilities
   =========================== */

.hidden {
  display: none !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-dark);
  color: white;
  padding: 16px 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: slideInUp 0.3s ease;
  z-index: 10000;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.success {
  background: var(--primary-color);
}

.toast.error {
  background: #ef4444;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-container {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 24px;
  padding: 40px 50px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-icon {
  text-align: center;
  margin-bottom: 30px;
}

.gemini-stars {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 80px;
}

.gemini-stars i {
  position: absolute;
  font-size: 24px;
  color: #60a5fa;
  animation: twinkle 2s ease-in-out infinite;
}

.gemini-stars .star-1 {
  top: 0;
  left: 0;
  animation-delay: 0s;
}

.gemini-stars .star-2 {
  top: 0;
  right: 0;
  animation-delay: 0.5s;
}

.gemini-stars .star-3 {
  bottom: 0;
  left: 0;
  animation-delay: 1s;
}

.gemini-stars .star-4 {
  bottom: 0;
  right: 0;
  animation-delay: 1.5s;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.8);
  }
}

.loading-content {
  text-align: center;
}

.loading-title {
  color: #f1f5f9;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pulse-icon {
  color: #60a5fa;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.loading-progress {
  margin-bottom: 30px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa, #93c5fd);
  background-size: 200% 100%;
  border-radius: 10px;
  animation: progress-animation 2s ease-in-out infinite;
  width: 100%;
}

@keyframes progress-animation {
  0% {
    background-position: 0% 0%;
  }
  50% {
    background-position: 100% 0%;
  }
  100% {
    background-position: 0% 0%;
  }
}

.loading-status {
  color: #cbd5e1;
  font-size: 14px;
  margin: 0;
}

.loading-steps {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  opacity: 0.5;
}

.step i {
  font-size: 24px;
  color: #64748b;
  transition: all 0.3s ease;
}

.step span {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
  transition: all 0.3s ease;
}

.step.active {
  opacity: 1;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  animation: stepGlow 2s ease-in-out infinite;
}

.step.active i {
  color: #60a5fa;
  animation: bounce 1s ease-in-out infinite;
}

.step.active span {
  color: #bfdbfe;
}

.step.completed {
  opacity: 1;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.step.completed i {
  color: #4ade80;
}

.step.completed span {
  color: #bbf7d0;
}

@keyframes stepGlow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.6);
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Responsive loading */
@media (max-width: 768px) {
  .loading-container {
    padding: 30px 25px;
  }

  .loading-title {
    font-size: 18px;
  }

  .loading-steps {
    flex-direction: column;
    gap: 10px;
  }

  .step {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 15px;
  }

  .step i {
    font-size: 20px;
  }
}

/* ===========================
   Message Inline Table Styles
   =========================== */

.message-table-container {
  margin: 15px 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow);
  width: 100%;
  display: flex;
  flex-direction: column;
}

.message-table-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.message-table-info,
.table-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.message-table-info i,
.table-info i {
  color: var(--primary-color);
}

.message-table-actions,
.table-actions {
  display: flex;
  gap: 10px;
}

.btn-table-action {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-export {
  background: var(--primary-color);
  color: white;
}

.btn-export:hover {
  background: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(16, 163, 127, 0.3);
}

.btn-save {
  background: #4285f4;
  color: white;
}

.btn-save:hover {
  background: #357ae8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.message-table-wrapper {
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  background: white;
}

.message-table-wrapper .tabulator {
  border: none;
  font-size: 13px;
  width: max-content !important;
  min-width: 100%;
  background: white;
}

.message-table-wrapper .tabulator-tableholder {
  overflow: visible !important;
  background: white;
}

.message-table-wrapper .tabulator-table {
  width: max-content !important;
  background: white;
}

.message-table-wrapper .tabulator-header {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

.message-table-wrapper .tabulator-col {
  background: transparent;
  border-right: 1px solid var(--border-color);
}

.message-table-wrapper .tabulator-col-title {
  font-weight: 600;
  color: var(--text-primary);
}

.message-table-wrapper .tabulator-row {
  border-bottom: 1px solid var(--border-color);
}

.message-table-wrapper .tabulator-row:hover {
  background: var(--hover-bg);
}

.message-table-wrapper .tabulator-cell {
  border-right: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.message-table-wrapper .tabulator-cell:hover {
  background-color: #f0f8ff !important;
}

.message-table-wrapper .tabulator-cell.tabulator-editing {
  background-color: #e3f2fd !important;
  border: 2px solid var(--primary-color) !important;
  padding: 0 !important;
}

.message-table-wrapper .tabulator-cell.tabulator-editing input {
  width: 100%;
  height: 100%;
  border: none;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}

.message-table-wrapper .tabulator-cell.tabulator-editing input:focus {
  outline: none;
}

.message-table-wrapper .tabulator-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 8px 10px;
}

/* ===========================
   Settings Modal
   =========================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-close-modal {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.btn-close-modal:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.help-link {
  font-size: 12px;
  color: var(--primary-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}

.help-link:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  padding-right: 48px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.form-input[type="password"] {
  font-family: "Courier New", monospace;
  letter-spacing: 2px;
}

.btn-toggle-password {
  position: absolute;
  right: 12px;
  top: 38px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-toggle-password:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.settings-info {
  background: #e3f2fd;
  border-left: 4px solid var(--primary-color);
  padding: 16px;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.settings-info i {
  color: var(--primary-color);
  font-size: 18px;
  flex-shrink: 0;
}

.settings-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: var(--bg-secondary);
}

.btn-primary,
.btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 163, 127, 0.3);
}

.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--hover-bg);
  border-color: var(--text-secondary);
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-container {
    margin-left: 0;
  }

  .btn-toggle-sidebar.mobile {
    display: block;
  }

  .input-area {
    left: 0;
  }

  .results-panel {
    width: 100%;
  }

  .quick-actions {
    flex-direction: column;
  }

  .quick-action-btn {
    width: 100%;
  }
}

/* ===========================
   Image Upload Modal Styles
   =========================== */

.modal-large {
  max-width: 900px;
}

.image-upload-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.dropzone:hover {
  border-color: var(--primary-color);
  background: rgba(16, 163, 127, 0.05);
}

.dropzone.drag-over {
  border-color: var(--primary-color);
  background: rgba(16, 163, 127, 0.1);
  transform: scale(1.02);
}

.dropzone i {
  font-size: 48px;
  color: var(--primary-color);
  margin-bottom: 16px;
  display: block;
}

.dropzone p {
  margin: 8px 0;
  color: var(--text-primary);
  font-size: 16px;
}

.dropzone-note {
  font-size: 13px !important;
  color: var(--text-secondary) !important;
}

.image-preview-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.image-preview-container:empty {
  display: none;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.image-preview-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
}

.image-preview-item:hover .image-preview-remove {
  opacity: 1;
}

.image-preview-remove:hover {
  background: rgba(220, 38, 38, 0.9);
  transform: scale(1.1);
}

.image-preview-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 11px;
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-upload-info {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: #e0f2fe;
  border-radius: 8px;
  border-left: 4px solid #0284c7;
}

.image-upload-info i {
  color: #0284c7;
  font-size: 20px;
  flex-shrink: 0;
}

.image-upload-info p {
  margin: 0;
  color: #0c4a6e;
  font-size: 14px;
  line-height: 1.5;
}

/* ===========================
   Paste Text Modal Styles
   =========================== */

.text-paste-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.paste-instructions {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: #fff3e0;
  border-radius: 8px;
  border-left: 4px solid #f57c00;
}

.paste-instructions i {
  color: #f57c00;
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.paste-instructions p {
  margin: 0;
  color: #e65100;
  font-size: 14px;
  line-height: 1.6;
}

.paste-textarea {
  width: 100%;
  min-height: 400px;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  transition: all 0.3s ease;
}

.paste-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.paste-textarea::placeholder {
  color: #999;
  line-height: 1.6;
}

.paste-stats {
  display: flex;
  gap: 20px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.paste-stats span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.paste-stats span::before {
  content: "•";
  color: var(--primary-color);
  font-size: 16px;
}

