:root {
  --bg-dark: #090a0f;
  --bg-card: rgba(22, 28, 45, 0.45);
  --bg-card-hover: rgba(26, 34, 54, 0.6);
  --text-main: #f1f3f9;
  --text-muted: #8b9bb4;
  --primary: #4facfe;       /* Cool Cyan */
  --primary-glow: rgba(79, 172, 254, 0.35);
  --secondary: #00f2fe;     /* Neon Cyan */
  --accent: #7f00ff;        /* Violet */
  --accent-magenta: #ff007f;/* Magenta */
  --success: #00e676;
  --danger: #ff1744;
  --border-light: rgba(255, 255, 255, 0.07);
  --border-glow: rgba(79, 172, 254, 0.15);
  --font-title: 'Outfit', 'Sarabun', sans-serif;
  --font-body: 'Inter', 'Sarabun', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 3rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Glass ambient glow */
.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background: radial-gradient(circle at 10% 15%, rgba(127, 0, 255, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 90% 85%, rgba(0, 242, 254, 0.12) 0%, transparent 45%),
              radial-gradient(circle at 50% 50%, rgba(255, 0, 127, 0.04) 0%, transparent 50%);
  filter: blur(80px);
  pointer-events: none;
}

.container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
}

/* Header Section */
.app-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
}

.brand-icon {
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--secondary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(0, 242, 254, 0.45));
  animation: float 4s ease-in-out infinite alternate;
}

.logo h1 {
  font-family: var(--font-title);
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #d2d7f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 300;
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Layout Workspace */
.app-workspace {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  align-items: stretch;
}

/* Card glass styling */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 2.2rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(79, 172, 254, 0.18);
  box-shadow: 0 15px 45px rgba(0, 242, 254, 0.06);
}

h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
}

.section-icon {
  font-size: 1.15rem;
  color: var(--primary);
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.8rem;
  line-height: 1.4;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 500;
  color: #e2e8f0;
  display: flex;
  align-items: center;
}

.required-star {
  color: var(--danger);
  margin-left: 0.2rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1.1rem;
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.input-wrapper input,
.input-wrapper select {
  width: 100%;
  background: rgba(13, 17, 28, 0.6);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.85rem 1.1rem 0.85rem 2.8rem;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
}

.input-wrapper input[type="file"] {
  padding: 0.7rem 1.1rem 0.7rem 2.8rem;
  cursor: pointer;
}

.input-wrapper input[type="file"]::file-selector-button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  margin-right: 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.input-wrapper input[type="file"]::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--primary);
}

.input-wrapper input:focus,
.input-wrapper select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  background: rgba(13, 17, 28, 0.85);
}

.btn-toggle-input {
  position: absolute;
  right: 0.8rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  font-size: 0.95rem;
}

.btn-toggle-input:hover {
  color: #fff;
}

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Custom Select tweaks */
.input-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.input-wrapper::after {
  content: '\f0d7';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 1.2rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* Toggle Checkboxes options */
.options-group {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.8rem 0;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 1.1rem;
}

.toggle-control {
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  user-select: none;
  gap: 0.75rem;
}

.toggle-control input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.control-indicator {
  position: relative;
  height: 20px;
  width: 38px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

.toggle-control input:checked ~ .control-indicator {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.control-indicator::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.toggle-control input:checked ~ .control-indicator::after {
  transform: translateX(18px);
}

.control-label {
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 400;
}

/* Submit Action Button */
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #0d111c;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.05rem;
  border: none;
  border-radius: 14px;
  padding: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 242, 254, 0.45);
  color: #000;
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.25);
  cursor: not-allowed;
  box-shadow: none;
  border: 1px solid var(--border-light);
}

/* --- OUTPUT PANEL STYLES --- */

/* Empty / Placeholder State */
.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto 0;
  padding: 3rem 1rem;
  color: var(--text-muted);
  gap: 0.9rem;
}

.output-placeholder i {
  font-size: 4rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.output-placeholder p {
  font-size: 1.1rem;
  font-weight: 500;
  color: #e2e8f0;
}

.output-placeholder small {
  font-size: 0.8rem;
  max-width: 320px;
}

/* Progress Box */
.progress-box {
  background: rgba(79, 172, 254, 0.04);
  border: 1px solid rgba(79, 172, 254, 0.25);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

#progress-spinner i {
  color: var(--secondary);
  font-size: 1.1rem;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 10%;
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border-radius: 3px;
  box-shadow: 0 0 8px var(--primary-glow);
  animation: pulse-width 3s ease-in-out infinite alternate;
}

.progress-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Results Box & Tabs */
.results-box {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
}

.tabs-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 0.35rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.75rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: var(--bg-card-hover);
  color: var(--secondary);
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tabs-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 380px; /* Fixed height for scroll panels */
}

.tab-panel {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

.panel-header-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.content-scroll {
  flex-grow: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 1.2rem;
  overflow-y: auto;
}

.thai-font {
  font-family: 'Sarabun', var(--font-body);
  line-height: 1.7;
}

.rendered-text {
  font-size: 0.95rem;
  color: #e2e8f0;
  white-space: pre-wrap;
}

.rendered-markdown {
  font-size: 0.95rem;
  color: #cbd5e1;
}

.rendered-markdown h1,
.rendered-markdown h2,
.rendered-markdown h3 {
  font-family: var(--font-title);
  color: #fff;
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
}

.rendered-markdown h1:first-child,
.rendered-markdown h2:first-child,
.rendered-markdown h3:first-child {
  margin-top: 0;
}

.rendered-markdown ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.rendered-markdown li {
  margin-bottom: 0.5rem;
}

/* Saved Files Tab styles */
.saved-info-intro {
  font-size: 0.92rem;
  color: #e2e8f0;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.saved-paths {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.path-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem;
}

.path-label {
  font-size: 0.8rem;
  color: var(--secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.path-value {
  font-family: 'Consolas', monospace;
  font-size: 0.85rem;
  color: #cbd5e1;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Error Box styles */
.error-box {
  background: rgba(255, 23, 68, 0.04);
  border: 1px solid rgba(255, 23, 68, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: flex-start;
  margin: auto 0;
}

.error-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 700;
}

.error-message {
  font-size: 0.9rem;
  color: #fca5a5;
  line-height: 1.5;
}

/* Animations */
@keyframes float {
  0% {
    transform: translateY(0px);
  }
  100% {
    transform: translateY(-8px);
  }
}

@keyframes pulse-width {
  0% {
    width: 25%;
  }
  100% {
    width: 85%;
  }
}

/* Custom Scrollbars */
.content-scroll::-webkit-scrollbar {
  width: 6px;
}

.content-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
}

.content-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

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

.text-success {
  color: var(--success);
}

/* Responsive grid layout */
@media (max-width: 960px) {
  .app-workspace {
    grid-template-columns: 1fr;
  }
  body {
    padding: 1.5rem 1rem;
  }
}
