/* =========================
   RESET & BASE
   ========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: linear-gradient(180deg, #0b1020, #0e1a33);
  color: #e5e7eb;
}

/* =========================
   NAVBAR
   ========================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(11,16,32,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
  font-weight: 900;
  font-size: 16px;
  text-decoration: none;
  color: #fff;
}

.navbar ul {
  list-style: none;
  display: flex;
  gap: 18px;
  align-items: center;
}

.navbar a {
  text-decoration: none;
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}

.navbar a:hover {
  color: #fff;
}

/* Login button */
.nav-auth-btn {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  cursor: pointer;
}

.nav-auth-btn:hover {
  background: rgba(255,255,255,0.12);
}

/* =========================
   LAYOUT
   ========================= */
.main-container {
  max-width: 980px;
  margin: 70px auto 0;
  padding: 0 22px 40px;
}

.page-title {
  font-size: 36px;
  font-weight: 900;
  margin-bottom: 8px;
}

.page-subtitle {
  color: rgba(255,255,255,0.75);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* =========================
   UPLOAD BOX
   ========================= */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.chat-box input[type="text"],
.chat-box select,
.chat-box textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15,23,42,0.7);
  color: #fff;
  outline: none;
}

.chat-box textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.45;
}

#symbolInput {
  flex: 1;
  min-width: 220px;
}

#intervalSelect {
  flex: 0 0 160px;
  min-width: 160px;
}

.field-label {
  font-size: 12px;
  opacity: 0.9;
  font-weight: 700;
  margin-top: 4px;
}

.helper {
  font-size: 12px;
  opacity: 0.75;
}

.upload-hint {
  font-size: 12px;
  opacity: 0.85;
  margin-top: -4px;
}

.file-input {
  padding: 10px 0;
  color: rgba(255,255,255,0.85);
}

/* ✅ NEW: checkbox row used by index.html */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #6366f1;
  cursor: pointer;
}

.check-row span {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1.35;
}

/* Analyze button + spinner */
.analyze-btn {
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  font-weight: 900;
  font-size: 14px;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: fit-content;
}

.analyze-btn:hover {
  filter: brightness(1.05);
}

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

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.9);
  animation: spin 0.8s linear infinite;
}

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

/* =========================
   PREVIEW
   ========================= */
.preview-wrap {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.preview-thumb {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: zoom-in;
}

.preview-title {
  font-size: 13px;
  font-weight: 800;
}

.preview-sub {
  font-size: 12px;
  opacity: 0.75;
}

/* =========================
   STATUS
   ========================= */
.upload-info {
  margin-top: 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.upload-info .muted {
  margin-left: 8px;
  opacity: 0.75;
}

.status-warning {
  margin-top: 8px;
  font-size: 12px;
  color: #fbbf24;
  min-height: 16px;
}

/* =========================
   OUTPUT
   ========================= */
.output {
  margin-top: 22px;
}

.output-title {
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 8px;
}

.output-box {
  padding: 16px;
  border-radius: 16px;
  background: rgba(15,23,42,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  min-height: 140px;
  line-height: 1.55;
}

/* Markdown rendering inside output */
.output-box h1 {
  font-size: 18px;
  margin: 14px 0 8px;
  font-weight: 900;
}
.output-box h2 {
  font-size: 15px;
  margin: 14px 0 8px;
  font-weight: 900;
}
.output-box h3 {
  font-size: 14px;
  margin: 12px 0 6px;
  font-weight: 800;
}
.output-box p {
  margin: 8px 0;
  color: rgba(255,255,255,0.92);
}
.output-box ul {
  margin: 8px 0 12px 18px;
}
.output-box li {
  margin: 6px 0;
}
.output-box code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}

/* Tables */
.output-box table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.output-box th, .output-box td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
.output-box th {
  background: rgba(255,255,255,0.06);
  font-weight: 900;
}
.output-box tr:last-child td {
  border-bottom: none;
}

/* =========================
   FOOTER
   ========================= */
.footer {
  margin-top: 120px;
  padding: 28px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

.footer a {
  color: #c7d2fe;
  text-decoration: none;
  font-weight: 600;
}

.footer a:hover,
.footer a:focus {
  color: #e0e7ff;
  text-decoration: underline;
}

.footer .link-strong {
  margin: 0 4px;
}

/* =========================
   MODAL (CRITICAL)
   ========================= */

/* Blur background when modal open */
body.modal-open .navbar,
body.modal-open .main-container,
body.modal-open .footer {
  filter: blur(10px);
}

/* Overlay hidden by default */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  z-index: 5000;
  padding: 18px;
}

/* Only visible when JS adds .open */
.modal-overlay.open {
  display: flex;
}

/* Modal card */
.modal {
  width: min(560px, 100%);
  padding: 18px;
  border-radius: 18px;
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  position: relative;
}

.modal-title {
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 8px;
}

.modal-text {
  font-size: 14px;
  line-height: 1.6;
  opacity: 0.9;
}

/* X button */
.modal-x {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.modal-x:hover {
  background: rgba(255,255,255,0.14);
}

.modal-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.modal-primary {
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 900;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border: none;
}

.modal-secondary {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.modal-secondary:hover {
  background: rgba(255,255,255,0.14);
}

.modal-preview {
  margin-top: 12px;
}

.modal-preview-img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.25);
}

/* ✅ Small responsiveness polish */
@media (max-width: 520px) {
  .navbar { padding: 12px 16px; }
  .page-title { font-size: 30px; }
  #intervalSelect { flex: 1; min-width: 140px; }
  .analyze-btn { width: 100%; }
}