/* GLOBAL RESET & CORE THEME*/
:root {
  --bg-dark: #0d0d0d;
  --bg-panel: #161616;
  --bg-header: #1e1e1e;
  --accent-blue: #00a2ff;
  --accent-glow: rgba(0, 162, 255, 0.3);
  --text-main: #e0e0e0;
  --text-dim: #888;
  --border-color: #2a2a2a;
  --matrix-green: #00ff41;
  --error-red: #ff4444;
  --font-main: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "Fira Code", "Cascadia Code", "Consolas", monospace;
}

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

body,
html {
  min-height: 100vh;
  width: 100vw;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: hidden;
}

/*HOME PAGE */
.home-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at center, #1a1a1a 0%, #0d0d0d 100%);
}

.home-container {
  text-align: center;
  max-width: 1000px;
  width: 100%;
  padding: 20px;
}

.home-header {
  margin-bottom: 60px;
}
.home-header h1 {
  font-size: 3rem;
  margin-bottom: 10px;
}
.home-header p {
  color: var(--text-dim);
  font-size: 1.2rem;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

.portal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 50px 30px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.portal-card:hover {
  transform: translateY(-10px);
  border-color: var(--accent-blue);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.portal-card .icon {
  font-size: 3rem;
  margin-bottom: 20px;
}
.portal-card h2 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: var(--text-main);
}
.portal-card p {
  color: var(--text-dim);
  margin-bottom: 30px;
  line-height: 1.6;
}

.btn-link {
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* PROBLEM SELECTION PAGE*/
.selection-container {
  padding: 50px;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

.selection-header {
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.problem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  padding-bottom: 50px;
}

.problem-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 24px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.problem-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
}

.problem-card h3 {
  margin-bottom: 10px;
  color: var(--accent-blue);
}

/* Difficulty Tags*/
.difficulty-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 12px;
  background: #222;
}
.difficulty-tag.easy {
  color: #00ff88;
  border: 1px solid #00ff8833;
}
.difficulty-tag.medium {
  color: #ffaa00;
  border: 1px solid #ffaa0033;
}
.difficulty-tag.hard {
  color: #ff4444;
  border: 1px solid #ff444433;
}

/* Card Internals */
.problem-card .description {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 20px;
  height: 42px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.problem-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
}

.problem-card .case-count {
  color: var(--text-dim);
}
.problem-card .action-text {
  color: var(--accent-blue);
  font-weight: 600;
}

/* Loading Spinner & Error Box */
.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 100px;
  color: var(--text-dim);
}
.loader {
  border: 3px solid #333;
  border-top: 3px solid var(--accent-blue);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.error-box {
  grid-column: 1 / -1;
  background: #221111;
  border: 1px solid var(--error-red);
  padding: 30px;
  border-radius: 8px;
  text-align: center;
}

/* IDE LAYOUT */
.ide-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.left-panel {
  width: 350px;
  min-width: 250px;
  max-width: 600px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.resizer {
  width: 4px;
  cursor: col-resize;
  background: #222;
  transition: background 0.3s;
  z-index: 10;
}
.resizer:hover,
.resizer:active {
  background: var(--accent-blue);
}

.center-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  min-width: 400px;
}

.right-panel {
  width: 380px;
  min-width: 300px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

/* --- 5. UI COMPONENTS --- */
.header-bar {
  height: 55px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
}

.btn {
  padding: 8px 18px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-back {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-color);
}
.btn-back:hover {
  color: #fff;
  border-color: #666;
}

.btn-save {
  background: #333;
  color: #fff;
}
.btn-save:hover {
  background: #444;
}

.btn-run {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 0 10px var(--accent-glow);
}
.btn-run:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

select {
  background: #2a2a2a;
  color: white;
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 4px;
  outline: none;
}

/* TERMINAL & AGENT OUTPUT */
.terminal-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 8px 15px;
  background: #000;
  color: #555;
  border-bottom: 1px solid #222;
}

#agent-console {
  height: 50%;
  background: #000;
  color: var(--matrix-green);
  padding: 15px;
  font-family: var(--font-mono);
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  border-bottom: 1px solid var(--border-color);
}

#ai-hints {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-panel);
}

.hint-card {
  background: rgba(0, 162, 255, 0.05);
  border-left: 3px solid var(--accent-blue);
  padding: 15px;
  margin-top: 10px;
  border-radius: 4px;
}

/* TEACHER DASHBOARD */
.dashboard-container {
  padding: 40px;
  overflow-y: auto;
  min-height: 100vh;
}
.chart-wrapper {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 30px;
  border-radius: 12px;
  max-width: 900px;
  margin: 20px 0;
}

/* CODEMIRROR OVERRIDE */
.CodeMirror {
  height: calc(100vh - 55px) !important;
  font-family: var(--font-mono);
  font-size: 15px;
}
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* Responsive Grid */
@media (max-width: 768px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }
}

/* TOAST NOTIFICATIONS */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-box {
  min-width: 250px;
  background: #161b22;
  color: #e0e0e0;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid #30363d;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-family: var(--font-main);

  /* Entrance Animation */
  opacity: 0;
  transform: translateX(50px);
  animation: slideIn 0.3s ease-out forwards;
}

/* Status Colors */
.toast-box.success {
  border-left: 4px solid #00ff41;
}
.toast-box.error {
  border-left: 4px solid #ff4444;
}
.toast-box.info {
  border-left: 4px solid #00a2ff;
}

/* Exit Animation */
.toast-box.fade-out {
  animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* --- DIFF VIEWER STYLES --- */
.diff-add {
  color: #00ff41; /* Bright Green */
  background-color: rgba(0, 255, 65, 0.1);
  display: block;
  width: 100%;
}

.diff-remove {
  color: #ff4444; /* Bright Red */
  background-color: rgba(255, 68, 68, 0.1);
  display: block;
  width: 100%;
  text-decoration: line-through; /* Cross out removed lines */
}

.diff-header {
  color: #58a6ff; /* Blue for @@ ... @@ */
  font-weight: bold;
  display: block;
  opacity: 0.8;
  margin-top: 5px;
}

/* --- CUSTOM MODAL (CONFIRMATION BOX) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7); /* Dark semi-transparent background */
  z-index: 10000; /* Must be higher than everything else */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-box {
  background: #161b22; /* Matches bg-panel */
  border: 1px solid #30363d;
  padding: 25px;
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
  font-family: "Inter", sans-serif;
  transform: translateY(0);
  transition: transform 0.2s ease;
  text-align: center;
}

/* Subtle entrance animation */
.modal-overlay:not(.hidden) .modal-box {
  transform: translateY(-10px);
}

.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}
