/* ============================================================
   MOOTIE – AI Moot Court Coach
   Restored cinematic dark-glass aesthetic with fixed layout
   ============================================================ */

/* ---------- Base Theme ---------- */
:root {
  --bg-0: #070a12;
  --bg-1: #0b0f1a;
  --bg-2: #111827;
  --panel: rgba(18,24,38,0.7);
  --panel-strong: rgba(22,28,45,0.9);
  --card: rgba(22,28,45,0.55);
  --stroke: rgba(255,255,255,0.06);
  --text-1: #e6ebff;
  --text-2: #b6c2e2;
  --muted: #8aa0c7;

  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --success: #34d399;
  --danger: #ef4444;

  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;

  --shadow-1: 0 10px 25px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-2: 0 18px 45px rgba(0,0,0,0.5);
}

html[data-theme="light"] {
  --bg-0: #f7fafc;
  --bg-1: #f9fbff;
  --bg-2: #ffffff;
  --panel: rgba(255,255,255,0.7);
  --panel-strong: rgba(255,255,255,0.9);
  --card: rgba(255,255,255,0.65);
  --text-1: #0b1020;
  --text-2: #304060;
  --muted: #57719c;
  --stroke: rgba(12,18,30,0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-1);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(39,120,255,0.08), transparent 50%),
    radial-gradient(1000px 500px at 100% 0%, rgba(167,139,250,0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}

/* ---------- Layout ---------- */
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px 28px;
  gap: 20px;
}

.navbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  color: var(--text-1);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease;
}
.logo i { color: var(--accent); }
.logo:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(125,211,252,.14); }

.brand-text { font-weight: 700; letter-spacing: .2px; }
.nav-tagline { color: var(--muted); margin-left: 8px; }

.nav-controls { display: flex; align-items: center; gap: 14px; }
.session-info { color: var(--text-2); display:flex; align-items:center; gap:8px; padding:8px 10px; }

.icon-btn {
  height: 38px; width: 38px; border-radius: 12px; border:1px solid var(--stroke);
  background: var(--card); color: var(--text-1);
  display:grid; place-items:center;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0,0,0,.3); }

.btn-debate {
  display:flex; align-items:center; gap:10px;
  padding:10px 14px;
  border-radius: 14px;
  cursor:pointer;
  background: linear-gradient(180deg, rgba(125,211,252,.18), rgba(125,211,252,.10));
  border:1px solid rgba(125,211,252,.35);
  color: var(--text-1);
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn-debate:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(125,211,252,.18); }

.main-content {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  min-height: 0;
}

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.sidebar-section {
  background: var(--panel-strong);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.section-title {
  font-size: 13px; text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

/* Mode selector */
.mode-selector { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.mode-btn {
  display:flex; align-items:center; justify-content:center; gap:8px;
  padding:10px;
  border-radius: 12px;
  border:1px solid var(--stroke);
  color: var(--text-2);
  background: var(--card);
  cursor:pointer;
  transition: all .15s ease;
}
.mode-btn.active {
  color: var(--text-1);
  border-color: rgba(125,211,252,.4);
  background: linear-gradient(180deg, rgba(125,211,252,.2), rgba(125,211,252,.08));
  box-shadow: 0 10px 22px rgba(125,211,252,.18);
}

/* Metrics */
.score-dashboard { display: grid; gap: 10px; }
.score-metric { background: var(--card); border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 12px; }
.metric-header { display:flex; align-items:center; justify-content:space-between; margin-bottom: 8px; }
.metric-label { color: var(--text-2); font-weight: 500; }
.metric-value, .value { font-weight: 700; color: var(--text-1); }
.metric-bar {
  height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; border: 1px solid var(--stroke);
}
.metric-fill, .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width .45s cubic-bezier(.2,.8,.2,1);
}

/* Debate Status */
#debateStatus .debate-info { display:grid; gap:8px; margin-bottom: 10px; }
.debate-row { display:flex; justify-content:space-between; color: var(--text-2); }
.debate-progress { height: 8px; background: rgba(255,255,255,.06); border:1px solid var(--stroke); border-radius:999px; overflow:hidden; }
.progress-fill { height:100%; width:0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s ease; }

/* Document Management */
.documents-panel {
  background: var(--panel-strong);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  padding: 12px;
  position: relative;
}
.documents-header {
  display:flex; align-items:center; justify-content:space-between; margin-bottom: 10px;
}
.btn-upload {
  height: 36px; width: 36px; border-radius: 12px; border: 1px solid var(--stroke);
  background: var(--card); color: var(--text-1); cursor:pointer;
  display:grid; place-items:center;
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn-upload:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0,0,0,.3); }

.documents-list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 8px;
  max-height: 280px; overflow: auto;
}
.documents-list .empty, .empty-state { color: var(--muted); padding: 10px; text-align: center; }

.source-row {
  display:flex; align-items:center; justify-content:space-between;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid var(--stroke);
  border-radius: 12px;
}
.source-row .name { color: var(--text-1); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.delete-btn {
  height: 28px; width: 28px;
  border-radius: 10px;
  border: 1px solid rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
  color: #ffb4b4;
  cursor:pointer;
  transition: transform .12s ease, background .2s ease;
}
.delete-btn:hover { transform: translateY(-1px); background: rgba(239,68,68,.14); }

.drop-hint { margin-top: 10px; color: var(--muted); font-size: 12.5px; display:flex; align-items:center; gap:8px; }
#dropZone.dragging { outline: 2px dashed rgba(125,211,252,.45); outline-offset: 6px; }

/* ---------- Chat Section ---------- */
.chat-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--panel-strong);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.messages-container {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.welcome-card {
  display:grid; place-items:center; text-align:center;
  padding: 26px;
  border: 1px dashed var(--stroke);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.02));
  color: var(--text-2);
}
.welcome-icon { font-size: 28px; color: var(--accent); margin-bottom: 8px; }
.welcome-tips { display:flex; gap: 16px; flex-wrap: wrap; justify-content:center; margin-top: 10px; }
.tip { display:flex; align-items:center; gap:8px; color: var(--muted); }

/* Chat messages */
.message {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: start;
}
.message .avatar {
  height: 42px; width: 42px;
  border-radius: 14px;
  display:grid; place-items:center;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--stroke);
  color: var(--accent);
}
.message.user .avatar { color: #60a5fa; }
.message .meta { grid-column: 2/3; font-size: 12px; color: var(--muted); margin-left: 2px; }
.message .text {
  grid-column: 2/3;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text-1);
  box-shadow: 0 8px 24px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.03);
}
.message.user .text { background: linear-gradient(180deg, rgba(96,165,250,.16), rgba(96,165,250,.08)); border-color: rgba(96,165,250,.28); }
.message.assistant .text { background: linear-gradient(180deg, rgba(125,211,252,.16), rgba(125,211,252,.08)); border-color: rgba(125,211,252,.28); }

/* Typing indicator */
.typing-indicator { display:flex; align-items:center; gap: 10px; padding: 0 18px 12px; color: var(--muted);}
.typing-indicator.hidden { display:none; }
.typing-dots { display:flex; gap:6px; }
.typing-dots .dot {
  width:7px; height:7px; border-radius:999px; background: var(--text-2); opacity:.6;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots .dot:nth-child(2){ animation-delay: .15s; }
.typing-dots .dot:nth-child(3){ animation-delay: .3s; }
@keyframes bounce { 0%,80%,100%{ transform: translateY(0); } 40%{ transform: translateY(-6px); } }

/* Input area */
.input-container {
  flex-shrink: 0;
  border-top: 1px solid var(--stroke);
  background: rgba(15,20,35,0.65);
  backdrop-filter: blur(10px);
  padding: 12px 16px;
}
.input-wrapper {
  display:flex; gap:10px; align-items: flex-end;
  background: var(--panel-strong);
  border:1px solid var(--stroke);
  border-radius: 16px;
  padding: 10px;
}
.btn-record, .btn-send {
  height: 40px; min-width: 40px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text-1);
  display:grid; place-items:center;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn-record:hover, .btn-send:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0,0,0,.3); }
.btn-record.recording { border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.12); color:#ffb4b4; }

.text-input {
  flex: 1 1 auto;
  min-height: 40px; max-height: 180px;
  background: transparent;
  color: var(--text-1);
  border: none; outline: none; resize: none;
  padding: 8px 2px;
  font-size: 15px; line-height: 1.4;
}
.input-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(3,8,20,.55); backdrop-filter: blur(4px); z-index: 50; }
.modal.hidden { display:none; }
.modal-content {
  width: min(680px, 92vw);
  background: var(--panel-strong);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.modal-header { display:flex; align-items:center; justify-content:space-between; padding: 12px 14px; border-bottom: 1px solid var(--stroke); }
.modal-body { padding: 14px; }
.modal-actions { display:flex; justify-content:flex-end; gap:10px; padding: 12px 14px; border-top:1px solid var(--stroke); }

.btn-primary {
  padding: 10px 16px; border-radius: 12px; cursor:pointer;
  border: 1px solid rgba(125,211,252,.35);
  background: linear-gradient(180deg, rgba(125,211,252,.22), rgba(125,211,252,.10));
  color: var(--text-1);
}

/* ---------- Scrollbar ---------- */
.messages-container::-webkit-scrollbar,
.documents-list::-webkit-scrollbar { width: 10px; }
.messages-container::-webkit-scrollbar-thumb,
.documents-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(125,211,252,.5), rgba(167,139,250,.5));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .main-content { grid-template-columns: 1fr; }
}
