:root {
  --bg-color: #05080f;
  --primary-blue: #8cb0ff;
  --light-blue: #a3c3ff;
  --card: rgba(10, 15, 26, 0.82);
  --border: rgba(140, 176, 255, 0.28);
  --text: #ffffff;
  --muted: #9ca3af;
  --accent: #8cb0ff;
  --shadow-color: rgba(77, 138, 255, 0.2);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Cairo", "Poppins", sans-serif;
  background-color: var(--bg-color);
  color: var(--text);
  min-height: 100vh;
}

/* ── Space Scene ─────────────────────────────────────────────────────────── */
.space-scene {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; overflow: hidden;
}

#twinkling-stars-container { width: 100%; height: 100%; position: absolute; }

.star {
  position: absolute; background-color: white; border-radius: 50%;
  animation-name: twinkle; animation-iteration-count: infinite;
}

@keyframes twinkle {
  0%   { opacity: 0; transform: scale(0.5); }
  50%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5); }
}

#rotatingGalaxy {
  position: fixed; top: 10px; right: 10px;
  width: 400px; height: auto; opacity: 0.3; z-index: 0;
}

#roamingRobot {
  position: fixed; width: 130px; height: auto;
  opacity: 0.75; z-index: 0;
  animation: roam-fullscreen 90s ease-in-out infinite;
}

@keyframes roam-fullscreen {
  0%   { bottom: 5%;  left: 5%;  transform: rotate(-15deg); }
  25%  { bottom: 50%; left: 75%; transform: rotate(20deg);  }
  50%  { bottom: 60%; left: 10%; transform: rotate(-20deg); }
  75%  { bottom: 10%; left: 80%; transform: rotate(15deg);  }
  100% { bottom: 5%;  left: 5%;  transform: rotate(-15deg); }
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.leo-topbar {
  background: rgba(10,15,26,0.92);
  border-bottom: 1px solid rgba(140,176,255,0.25);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.leo-topbar-left  { display: flex; align-items: center; gap: 10px; }
.leo-topbar-left img { height: 32px; }
.leo-topbar-title { font-size: 1rem; color: var(--accent); font-weight: 600; }
.leo-topbar-right { display: flex; align-items: center; gap: 12px; }
.leo-status-dot   { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(140,176,255,0.8); }
.leo-user-label   { font-size: 0.85rem; text-align: right; }
.leo-user-label span { display: block; }
.leo-user-role    { color: #80e27e; font-size: 0.8rem; }

.leo-topbar-nav {
  display: flex; gap: 8px; align-items: center;
  padding-inline: 12px;
  border-inline: 1px solid rgba(140,176,255,0.15);
}
.leo-topbar-nav a {
  font-size: 0.8rem; color: #e5e7eb; text-decoration: none;
  padding: 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.04); transition: all 0.2s;
}
.leo-topbar-nav a:hover { background: rgba(140,176,255,0.18); color: #a3c3ff; }

.leo-btn-logout {
  background: rgba(239,68,68,0.18); color: #ef4444;
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 999px; padding: 6px 14px;
  font-size: 0.8rem; cursor: pointer; font-family: inherit;
}

/* ── Shell + Card ────────────────────────────────────────────────────────── */
.shell {
  position: relative; z-index: 1;
  max-width: 860px; margin: 30px auto; padding: 0 16px 60px;
}

.card {
  background: var(--card);
  border-radius: 18px; border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(0,0,0,0.55);
  padding: 28px 24px 32px;
  backdrop-filter: blur(12px);
}

.header { text-align: center; margin-bottom: 20px; }
.header h1 { color: var(--accent); font-size: 2rem; margin-bottom: 6px; text-shadow: 0 0 15px var(--shadow-color); }
.sub { color: #d1fae5; font-size: 0.9rem; }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.panel {
  border-radius: 16px;
  background: rgba(0,0,0,0.38);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 18px; margin-top: 14px;
}

/* ── Form Controls ───────────────────────────────────────────────────────── */
label {
  display: block; margin: 10px 0 6px;
  color: var(--light-blue); font-weight: 600; font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%; padding: 11px 14px;
  border-radius: 10px; border: 1px solid rgba(77,138,255,0.25);
  background: rgba(0,0,0,0.45); color: #ffffff;
  font-size: 0.95rem; font-family: inherit; outline: none;
  box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 12px rgba(77,138,255,0.5), 0 0 0 3px rgba(77,138,255,0.2);
}

input::placeholder, textarea::placeholder { color: rgba(225,225,225,0.35); }

select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238cb0ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: left 1rem center; background-size: 1em;
}
select option { background: #0c0f1a; }

textarea { min-height: 140px; resize: vertical; }

/* ── Grid ────────────────────────────────────────────────────────────────── */
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ── File Upload ─────────────────────────────────────────────────────────── */
.file-upload-area {
  border: 2px dashed rgba(140,176,255,0.35);
  border-radius: 10px; padding: 28px;
  text-align: center; transition: all 0.3s ease;
  background: rgba(0,0,0,0.2);
}
.file-upload-area.drag-over {
  border-color: var(--primary-blue);
  background: rgba(77,138,255,0.08);
}
.upload-icon { font-size: 36px; margin-bottom: 10px; transition: transform 0.3s; }
.file-upload-area.drag-over .upload-icon { transform: scale(1.3) translateY(-6px); }

.upload-button {
  background: none; border: 1px solid var(--primary-blue);
  color: var(--primary-blue); padding: 9px 22px;
  border-radius: 8px; cursor: pointer; transition: all 0.3s;
  font-family: inherit; font-size: 0.9rem;
}
.upload-button:hover { background: var(--primary-blue); color: #fff; transform: none; box-shadow: none; }

.upload-text { margin-top: 12px; color: var(--muted); font-size: 0.85rem; }

#fileList { margin-top: 12px; }
.file-item {
  background: rgba(0,0,0,0.25); padding: 9px 14px;
  border-radius: 7px; display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 7px;
  border: 1px solid rgba(140,176,255,0.2); font-size: 0.88rem;
}
.file-item button {
  background: none; border: none; color: #ff5c5c;
  cursor: pointer; font-size: 17px; padding: 0 4px;
  line-height: 1; transform: none; box-shadow: none;
}
.file-item button:hover { transform: none; box-shadow: none; color: #ff3030; }

/* ── Tasks Grid ──────────────────────────────────────────────────────────── */
.tasks-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-top: 8px;
}
.task-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.25); padding: 12px 14px;
  border-radius: 8px; border: 1px solid rgba(140,176,255,0.2);
  cursor: pointer; transition: border-color 0.2s;
}
.task-item:hover { border-color: var(--primary-blue); }
.task-item input[type="checkbox"] {
  width: 17px; height: 17px; flex-shrink: 0;
  accent-color: var(--primary-blue); cursor: pointer;
  padding: 0; border: none; background: none;
}
.task-item label { margin: 0; color: var(--text); font-weight: 400; cursor: pointer; font-size: 0.9rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: linear-gradient(135deg, #5a7ec9, #8cb0ff);
  color: #fff; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(140,176,255,0.4); }
button:active { transform: translateY(0); }

.btn-primary  { background: linear-gradient(135deg, #5a7ec9, #8cb0ff); }
.btn-secondary { background: rgba(15,23,42,0.9); border-color: rgba(148,163,184,0.5); }
.btn-secondary:hover { background: rgba(30,64,175,0.85); }

.btn-analyze {
  background: linear-gradient(135deg, var(--primary-blue) 0%, #6a5af9 100%);
  padding: 14px 40px; border-radius: 50px;
  font-size: 1rem; font-weight: 700;
  box-shadow: 0 4px 20px rgba(77,138,255,0.4);
  border: none;
}
.btn-analyze:hover { box-shadow: 0 8px 30px rgba(77,138,255,0.7); }
.btn-analyze:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.settings-btn { margin-top: 12px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 0.85rem; }

/* ── Status ──────────────────────────────────────────────────────────────── */
.status { color: #fde68a; margin: 14px 0 4px; font-size: 0.95rem; text-align: center; }

/* ── Loading spinner ─────────────────────────────────────────────────────── */
.loading {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  border-radius: 50%; border-top-color: #fff;
  animation: spin-loader 0.9s ease-in-out infinite;
  vertical-align: middle; margin-inline-end: 8px;
}
@keyframes spin-loader { to { transform: rotate(360deg); } }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-main-container { margin-top: 28px; }

.result-card {
  background: rgba(10,15,26,0.82);
  padding: 24px; border-radius: 16px;
  border: 1px solid rgba(140,176,255,0.25);
  margin-bottom: 22px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.result-card h3 {
  color: var(--primary-blue); font-size: 1.2rem;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(140,176,255,0.2);
}

.result-content {
  line-height: 1.85; white-space: pre-wrap;
  max-height: 340px; overflow-y: auto;
  padding-inline-end: 8px; font-size: 0.95rem;
}

/* Markdown in results */
.result-content h1, .result-content h2, .result-content h3 { color: var(--light-blue); margin: 12px 0 6px; }
.result-content a  { color: #93c5fd; }
.result-content code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 6px; }
.result-content pre { background: rgba(255,255,255,0.06); padding: 10px; border-radius: 10px; overflow: auto; }
.result-content ul, .result-content ol { padding-inline-start: 20px; margin: 8px 0; }
.result-content li { margin-bottom: 4px; }

.result-actions {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px;
}
.result-actions button {
  font-size: 0.82rem; padding: 7px 16px;
  border-radius: 8px; border: 1px solid rgba(140,176,255,0.25);
  background: rgba(0,0,0,0.25); color: var(--muted);
}
.result-actions button:hover {
  border-color: var(--light-blue); color: var(--light-blue);
  transform: none; box-shadow: none;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.leo-footer {
  position: relative; z-index: 1;
  text-align: center; padding: 24px;
  color: rgba(225,225,225,0.5); font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ── Novexa Topbar (novexa- prefix aliases) ──────────────────────────────── */
.novexa-topbar {
  background: rgba(10,15,26,0.92);
  border-bottom: 1px solid rgba(140,176,255,0.25);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.novexa-topbar-left  { display: flex; align-items: center; gap: 10px; }
.novexa-topbar-left img { height: 32px; width: auto; }
.novexa-topbar-title { font-size: 1rem; color: var(--accent); font-weight: 600; }
.novexa-topbar-right { display: flex; align-items: center; gap: 12px; }
.novexa-status-dot   { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(140,176,255,0.8); }
.novexa-user-label   { font-size: 0.85rem; text-align: right; }
.novexa-user-label span { display: block; }
.novexa-user-role    { color: #80e27e; font-size: 0.8rem; }

.novexa-topbar-nav {
  display: flex; gap: 8px; align-items: center;
  padding-inline: 12px;
  border-inline: 1px solid rgba(140,176,255,0.15);
}
.novexa-topbar-nav a {
  font-size: 0.8rem; color: #e5e7eb; text-decoration: none;
  padding: 4px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.04); transition: all 0.2s;
}
.novexa-topbar-nav a:hover { background: rgba(140,176,255,0.18); color: #a3c3ff; }

.novexa-btn-logout {
  background: rgba(239,68,68,0.18); color: #ef4444;
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 999px; padding: 6px 14px;
  font-size: 0.8rem; cursor: pointer; font-family: inherit;
}
.novexa-btn-logout:hover {
  background: rgba(239,68,68,0.32);
  transform: none; box-shadow: none;
}

/* Also fix #topbarLogo directly as safety net */
#topbarLogo { height: 32px !important; width: auto !important; }

@media (max-width: 768px) {
  .shell { padding: 0 12px 40px; }
  .header h1 { font-size: 1.6rem; }
  .grid-2-col { grid-template-columns: 1fr; }
  .btn-analyze { width: 100%; padding: 14px 20px; }
  #roamingRobot { width: 90px; animation-duration: 60s; }
  #rotatingGalaxy { width: 220px; top: -10px; right: -30px; }
  .leo-topbar-nav { display: none; }
  .novexa-topbar-nav { display: none; }
}

/* ── Remove galaxy/robot decorations (lawyer uses clean modern style) ─────── */
#rotatingGalaxy { display: none !important; }
#roamingRobot   { display: none !important; }

/* ── Clean dark background instead of space scene ────────────────────────── */
.space-scene {
  background: linear-gradient(135deg, #05080f 0%, #0a0f1e 50%, #060a14 100%);
}
#twinkling-stars-container { display: none !important; }

/* ── Footer centered (override any misplaced positioning) ────────────────── */
.leo-footer,
.novexa-footer {
  position: relative; z-index: 1;
  text-align: center !important;
  padding: 24px;
  color: rgba(225,225,225,0.5); font-size: 0.85rem;
  width: 100%;
  display: block;
}

/* ── novexa-footer explicit centering ───────────────────────────────────── */
footer.novexa-footer {
  position: relative; z-index: 1;
  text-align: center !important;
  padding: 24px 16px;
  color: rgba(225,225,225,0.5);
  font-size: 0.85rem;
  width: 100%;
  display: block;
  left: auto !important;
  right: auto !important;
}
