/* Reset et base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #1e1e1e;
  color: #d4d4d4;
  height: 100vh;
  overflow: hidden;
}

/* Conteneur principal */
.ide-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Barre d'outils */
.toolbar {
  background-color: #2d2d30;
  border-bottom: 1px solid #3e3e42;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Boutons */
.btn {
  background-color: #0e639c;
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.2s;
}

.btn:hover:not(:disabled) {
  background-color: #1177bb;
}

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

.btn-primary {
  background-color: #16825d;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1e9e6f;
}

.btn-danger {
  background-color: #f14c4c;
}

.btn-danger:hover:not(:disabled) {
  background-color: #f36666;
}

.btn-secondary {
  background-color: #3c3c3c;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #4c4c4c;
}

.btn-icon {
  background: none;
  border: none;
  color: #cccccc;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Indicateur de statut */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #cccccc;
}

.status-indicator i {
  font-size: 10px;
}

.status-indicator.ready i {
  color: #16825d;
}

.status-indicator.running i {
  color: #007acc;
  animation: pulse 1.5s infinite;
}

.status-indicator.error i {
  color: #f14c4c;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Contenu principal */
.main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

/* Panneaux éditeur et terminal */
.editor-panel,
.terminal-panel {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}

/* Séparation entre éditeur et terminal */
.editor-panel {
  border-bottom: 1px solid #3e3e42;
}

/* En-tête des panneaux */
.panel-header {
  background-color: #252526;
  padding: 10px 16px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  flex: 0 0 auto;
}

.panel-header i {
  margin-right: 8px;
  color: #cccccc;
}

.shortcuts-hint {
  font-size: 12px;
  color: #8b8b8b;
  font-weight: normal;
}

/* Éditeur CodeMirror */
#editorContainer {
  flex: 1;
  overflow: hidden;
}

.CodeMirror {
  height: 100%;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
}

/* Terminal PyScript/XTerm.js */
/* 1) Container unique flex, sans scroll */
py-terminal#terminal {
  display: block;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  background-color: #1e1e1e;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
}

/* 2) Réactive les events souris sur les contenus (pour le hover/clic des erreurs) */
/* py-terminal#terminal .xterm-screen, */
/* py-terminal#terminal .xterm-rows, */
/* py-terminal#terminal .xterm-helpers { */
  /* pointer-events: auto !important; */
/* } */

/* 3) Seul le scroll-area reste non-interactif (pour ne pas “voler” la molette) */
/* py-terminal#terminal .xterm-scroll-area { */
  /* pointer-events: none !important; */
/* } */

/* 3) Seul le viewport gère le scroll interne */
/* py-terminal#terminal .xterm-viewport { */
  /* 1. Remplit tout l’espace disponible */
  /* flex: 1 1 auto; */
  /* min-height: 0; */
  /* height: 100% !important; */
  /* max-height: 100% !important; */

  /* 2. Active le scroll interne */
  /* overflow-y: auto !important; */
  /* autorise le comportement natif de la molette */
  /* overscroll-behavior: auto; */
/* } */

/* Mode plein écran */
.terminal-panel.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background-color: #1e1e1e;
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
  background: #464647;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5a5a5a;
}

/* Liens d'erreur cliquables */
.error-link {
  color: #3794ff;
  text-decoration: underline;
  cursor: pointer;
}

.error-link:hover {
  color: #5cadff;
}

/* Ligne d'erreur surlignée dans l'éditeur */
.CodeMirror .error-line-highlight {
  background-color: rgba(241, 76, 76, 0.2);
  border-left: 3px solid #f14c4c;
}

/* Mots sélectionnés surlignés (addon) */
.CodeMirror .CodeMirror-selection-highlight-scrollbar {
  background-color: rgba(255, 255, 0, 0.4);
}

.cm-matchhighlight {
  background-color: rgba(255, 150, 50, 0.3);
}

/* Styles pour le gestionnaire de fichiers */
.ide-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.file-panel {
  width: 250px;
  background-color: #252526;
  border-right: 1px solid #3e3e42;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.file-panel-header {
  background-color: #2d2d30;
  padding: 10px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative; /* Ajouter cette ligne */
}

.file-panel-header h3 {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.file-item {
  padding: 5px 10px;
  margin: 2px 0;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: background-color 0.2s;
}

.file-item:hover {
  background-color: #2a2d2e;
}

.file-item i {
  font-size: 12px;
  color: #cccccc;
}

.file-item .remove-btn {
  margin-left: auto;
  color: #8b8b8b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.2s;
}

.file-item .remove-btn:hover {
  color: #f14c4c;
  background-color: rgba(241, 76, 76, 0.2);
}

.file-drop-zone {
  border: 2px dashed #3e3e42;
  border-radius: 4px;
  padding: 20px;
  text-align: center;
  margin: 10px;
  background-color: #1e1e1e;
  transition: all 0.3s;
}

.file-drop-zone.drag-over {
  border-color: #007acc;
  background-color: rgba(0, 122, 204, 0.1);
}

.file-drop-zone p {
  margin: 0;
  font-size: 13px;
  color: #8b8b8b;
}

.file-drop-zone i {
  font-size: 24px;
  color: #8b8b8b;
  margin-bottom: 8px;
}

.file-input {
  display: none;
}

.ide-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-item {
  position: relative;
}

.file-item.open::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #007acc;
}

/* Preview des fichiers binaires */
.editor-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#editorContainer {
  height: 100%;
}

.file-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: #1e1e1e;
  color: #d4d4d4;
  overflow: auto;
}

.file-preview img {
  max-width: 90%;
  max-height: 70%;
  object-fit: contain;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.file-preview-info {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: #8b8b8b;
}

.file-preview-info strong {
  color: #cccccc;
  display: block;
  margin-bottom: 5px;
}

.binary-file-info {
  background-color: #252526;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  padding: 30px;
  text-align: center;
}

.binary-file-info i {
  font-size: 48px;
  color: #8b8b8b;
  margin-bottom: 20px;
}

.back-link{
  font-weight:600;
  border-bottom:1px solid #444;
  margin:4px 0 6px;
  cursor:pointer;
}

.download-btn {
  color: #8b8b8b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.2s;
}

.download-btn:hover {
  color: #4CAF50;
  background-color: rgba(76, 175, 80, 0.2);
}

/* Indicateur de sauvegarde */
.save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #f39c12;
  margin-right: 16px;
}

.save-indicator i {
  font-size: 8px;
}

/* Bouton de déconnexion */
.logout-btn {
  color: #8b8b8b;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 4px;
  transition: all 0.2s;
  font-size: 14px;
}

.logout-btn:hover {
  color: #cccccc;
  background-color: rgba(255,255,255,0.1);
}

/* Séparateurs dans la toolbar */
.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Onglets de sortie */
.output-tabs {
  margin-left: 20px;
  display: flex;
  gap: 4px;
}

.output-tab {
  background: none;
  border: none;
  color: #8b8b8b;
  padding: 4px 12px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  font-size: 13px;
  transition: all 0.2s;
}

.output-tab:hover {
  background-color: rgba(255,255,255,0.05);
}

.output-tab.active {
  background-color: #1e1e1e;
  color: #d4d4d4;
}

/* Panneaux de sortie */
.output-panels {
  flex: 1;
  position: relative;
  min-height: 0;
}

.output-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

.output-panel.active {
  display: flex;
  flex-direction: column;
}

#graphicsPanel {
  background-color: white;
  overflow: auto;
  padding: 10px;
}

#skulptCanvas {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#skulptCanvas canvas {
  border: 1px solid #ddd;
}

/* Console panel pour scroll */
#consolePanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

py-terminal#terminal span,
py-terminal#terminal pre {
  display: block;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Correction du curseur PyScript */
py-terminal#terminal .xterm-cursor,
py-terminal#terminal .xterm-cursor-outline {
  width: auto !important;
  min-width: 0.6em !important;
  max-width: 1ch !important;
}

/* Alternative si ça ne fonctionne pas */
py-terminal .xterm-screen .xterm-cursor-layer .xterm-cursor {
  width: 1ch !important;
}

.loading-message {
  text-align: center;
  padding: 20px;
  color: #8b8b8b;
  font-size: 14px;
}

.loading-message i {
  margin-right: 8px;
}

.dropdown-toggle {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: #2d2d30;
  border: 1px solid #3e3e42;
  border-radius: 4px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: #d4d4d4;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: #094771;
}

.dropdown-item i {
  margin-right: 8px;
  width: 16px;
  text-align: center;
}

.rename-btn {
  color: #8b8b8b;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.2s;
  margin-left: auto;
  margin-right: 4px;
}

.rename-btn:hover {
  color: #3794ff;
  background-color: rgba(55, 148, 255, 0.2);
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#currentProjectName {
  font-weight: 600;
  color: #007acc;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: text;
}

#currentProjectName:hover {
  background-color: rgba(0, 122, 204, 0.1);
}

#currentProjectName:focus {
  outline: 1px solid #007acc;
  background-color: rgba(0, 122, 204, 0.1);
}

.save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  margin-right: 16px;
  cursor: help;
  transition: all 0.3s;
}

.save-indicator:hover {
  transform: scale(1.1);
}

@keyframes pulseSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.save-indicator.pulse-success {
  animation: pulseSuccess 0.5s ease-in-out;
}

.students-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.student-card .student-name {
  display: flex;
  align-items: center;
}

.student-card .student-name span {
  /* Laisse le nom prendre la place nécessaire */
  flex-shrink: 0;
}

.student-card .student-name .btn-view-as {
  /* Pousse le lien tout à droite */
  margin-left: auto;
  text-decoration: none;        /* selon vos goûts */
  padding: 4px 8px;             /* selon vos goûts */
  border-radius: 4px;           /* selon vos goûts */
  background-color: #0e639c;    /* selon votre charte */
  color: white;                 /* selon votre charte */
}

.student-card .student-name .btn-view-as:hover {
  background-color: #1177bb;    /* selon votre charte */
}

/* 1) Wrapper flex autour du titre + bouton */
.submission-info .submission-title-wrapper {
  display: flex;
  align-items: center;
}

/* 2) Un petit écart entre le nom et le bouton */
.submission-title {
  margin-right: 0.5em;
  font-weight: 600;
}

/* 3) Style du bouton (vous l’avez déjà pour .btn-view-as, mais on peut décliner) */
.btn-view-project {
  /* reprend vos règles .btn-primary ou .btn-view-as */
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #1e1e1e;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #3e3e42;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  color: #8b8b8b;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-info {
  background: #2a2d2e;
  padding: 12px;
  border-radius: 4px;
  color: #8b8b8b;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.version-item {
  background: #2a2d2e;
  padding: 12px 16px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.version-item:hover {
  background: #3e3e42;
}

.version-info {
  flex: 1;
}

.version-filename {
  color: #fff;
  font-weight: 500;
  margin-bottom: 4px;
}

.version-date {
  color: #8b8b8b;
  font-size: 12px;
}

.version-size {
  color: #8b8b8b;
  font-size: 12px;
}

.version-load-btn {
  background: #007acc;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.version-load-btn:hover {
  background: #005a9e;
}

.no-versions {
  text-align: center;
  color: #8b8b8b;
  padding: 40px;
}

.package-checkbox input:disabled + label {
  cursor: not-allowed;
}

.package-checkbox.incompatible {
  position: relative;
}

.package-checkbox.incompatible::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  pointer-events: none;
}

.storage-indicator {
  color: #8b8b8b;
  font-size: 12px;
  margin-left: 12px;
}
