:root {
  --bg-main: #0b0f19;
  --bg-panel: #151a2a;
  --bg-panel-hover: #1b2234;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --font-family: 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-family);
  background: var(--bg-main);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.05), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.05), transparent 25%);
  color: var(--text-main);
  font-size: 14px;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.text-white { color: #ffffff; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.font-medium { font-weight: 500; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Sidebar Branding */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.brand-icon {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: 12px;
  display: flex;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.brand p {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.btn-api-keys {
  background: #000;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.gemini-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gemini-settings label {
  font-size: 12px;
  color: var(--text-muted);
}

textarea, select, input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.2s;
}

textarea:focus, select:focus, input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

.hidden-input {
  display: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.panel-heading h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
}

.section-label {
  display: flex;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

.flex-between {
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.value-badge {
  text-transform: none;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.platform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.platform-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.platform-btn:hover {
  background: var(--bg-panel-hover);
}

.platform-btn input {
  accent-color: var(--primary);
}

.platform-btn span {
  font-size: 12px;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-stack span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.1);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(16px);
}

.slider.round {
  border-radius: 20px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Range Slider */
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* MAIN CONTENT */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Upload Dropzone */
.upload-panel {
  display: flex;
  flex-direction: column;
}

.upload-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.upload-header h2 {
  font-size: 16px;
  margin: 0;
}

.upload-drop {
  position: relative;
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 16px;
  text-align: center;
  padding: 40px 20px;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.1);
}

.upload-drop:hover, .upload-drop.dragover, .dropzone-container:hover, .dropzone-container.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
}

.upload-drop.dragover .upload-icon-large, .dropzone-container.dragover .dropzone-icon {
  transform: scale(1.1);
  color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.upload-icon-large {
  background: rgba(255,255,255,0.05);
  width: 48px; height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.upload-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.badge {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.upload-drop h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.upload-drop p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.upload-drop input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

/* Queue Toolbar */
.queue-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.queue-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.separator {
  color: var(--border-light);
}

.queue-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
  color: white;
}

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

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

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

.btn-secondary { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.05); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.15); }

.btn-tertiary { background: transparent; border: 1px solid var(--border-light); }
.btn-tertiary:hover:not(:disabled) { background: rgba(255,255,255,0.05); }


/* Cards List (Horizontal) */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.card-preview {
  width: 240px;
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border-color);
  position: relative;
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-icon {
  font-size: 40px;
}

.card-content {
  flex-grow: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.status-badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.status-pending { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.status-processing { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.status-done { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-failed { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.card-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-inputs textarea, .card-inputs input {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-light);
  font-size: 12px;
  padding: 10px 12px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
}

.btn-icon {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-main);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
}

.btn-icon.delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.card-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-top: 10px;
}

/* Responsiveness */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .queue-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .queue-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .card {
    flex-direction: column;
  }
  .card-preview {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
}
/* USER PROFILE & AUTH UI */
.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-left: auto;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: right;
}

.user-info span:first-child {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-main);
}

.badge-role {
  font-size: 8px;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.user-actions {
  display: flex;
  gap: 4px;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.15);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.key-selector {
  margin-bottom: 12px;
  background: rgba(0,0,0,0.3);
  padding: 10px;
  border-radius: 10px;
}

/* MODAL STYLES */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.key-list-container {
  margin: 20px 0;
  max-height: 280px;
  overflow-y: auto;
}

.key-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  transition: all 0.2s;
}

.key-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-light);
}

.key-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.key-item-label {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.key-item-stub {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.add-key-form label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.add-key-form input {
  margin-bottom: 12px;
  background: rgba(0,0,0,0.4);
}

/* NAVIGATION MENU */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border-color: rgba(59, 130, 246, 0.2);
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

/* UNIFIED DROPZONE */
.dropzone-container {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 40px 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.dropzone-container:hover, .dropzone-container.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--primary);
}

/* CARDS LISTING */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* INPUT OVERRIDES */
.styled-range {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  width: 100%;
}

.styled-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 4px solid var(--bg-panel);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* PROCESSING SPINNER */
.card-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
  color: #fff;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.processing-text {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}

.btn-success {
  background: #22c55e !important;
  border-color: #16a34a !important;
  color: white !important;
}

/* LOG CONSOLE */
.log-console {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-height: 400px;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s;
}

.log-console.minimized {
  transform: translateY(calc(100% - 48px));
}

.log-header {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.log-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.log-actions {
  display: flex;
  gap: 8px;
}

.log-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: all 0.2s;
}

.log-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.log-body {
  padding: 12px;
  overflow-y: auto;
  flex-grow: 1;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}

.log-entry.system { color: var(--primary); font-weight: 600; }
.log-entry.info { color: #fff; background: rgba(255, 255, 255, 0.03); }
.log-entry.warn { color: #facc15; background: rgba(250, 204, 21, 0.1); }
.log-entry.error { color: #f87171; background: rgba(239, 68, 68, 0.1); }
.log-entry.success { color: #4ade80; background: rgba(34, 197, 94, 0.1); }

@media (max-width: 640px) {
  .log-console {
    width: calc(100% - 48px);
    right: 24px;
    left: 24px;
  }
}
