/* =============================================================
   Chess Mnemonic Application & Epic Chess Stories Creator v3.3
   Unified CSS (Clean + Conflict-free)
   Author: Markellos Markides
   ============================================================= */

/* === Base Reset === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #111;
  color: #eee;
  font-family: Arial, sans-serif;
  line-height: 1.6;
  padding: 10px;
  padding-bottom: 100px;
}

/* === Header === */
header {
  background: #222;
  padding: 6px 8px;      /* ήταν 10px */
  margin-bottom: 5px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h1 {
  margin: 0;
  font-size: 1.3em;      /* ήταν 1.6em */
}

/* Πάνω σειρά: τίτλος + εικόνα */
.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Εικόνα στο header */
.header-img {
  width: 120px;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0,0,0,0.4);
}

/* Links */
header nav {
  margin-top: 6px;
}

.header-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-links a {
  display: inline-block;
  font-family: Georgia, serif;
  color: #fff;
  background: linear-gradient(180deg, #3a4f8a 0%, #1f2d60 100%);
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 1.05em;
  font-weight: 600;
  border: 1px solid #5b78ff;
  box-shadow: 0 0 6px rgba(100, 150, 255, 0.3);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.header-links a:hover {
  background: linear-gradient(180deg, #5b78ff 0%, #2f3f8a 100%);
  box-shadow: 0 0 10px rgba(120, 170, 255, 0.6);
  transform: translateY(-2px);
}

/* === Modal (General) === */
.modal {
  display: none;
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background: #1e1e1e;
  color: #f5f5f5;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px 30px;
  border-radius: 10px;
  width: 90%;
  max-width: 350px;
  height: auto;        /* modal παίρνει ακριβώς όσο ύψος χρειάζεται */
  max-height: 70vh;    /* μικρότερο limit */
  overflow-y: auto;    /* scroll μόνο αν ξεπεραστεί */
  border: 2px solid #3a3a3a;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.close {
  float: right;
  font-size: 24px;
  cursor: pointer;
  color: #aaa;
}

.close:hover {
  color: #fff;
}

/* === Layout === */
.layout-container {
  display: grid;
  grid-template-columns: 46% 17% 35%;
  gap: 10px;
  margin-bottom: 5px;
  position: sticky;
  top: 63px;
  background: #111;
  padding: 10px 0;
}

.left-panel,
.middle-panel,
.right-panel {
  background: #1a1a1a;
  padding: 10px;
  border: 1px solid #333;
  border-radius: 6px;
}

.left-panel textarea {
  width: 100%;
  height: 220px;
  background: #222;
  color: #eee;
  border: 1px solid #555;
  padding: 8px;
  resize: vertical;
  margin-bottom: 2px;
}

/* === Buttons & Inputs === */
button,
select {
  background: #333;
  color: #eee;
  border: 1px solid #555;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 4px;
  margin: 2px 0;
  transition: background 0.15s;
}

button:hover,
select:hover {
  background: #444;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}

th,
td {
  border: 1px solid #444;
  padding: 6px 10px;
  text-align: center;
}

th {
  background: #333;
  color: #fff;
  top: 0;
}

tr:nth-child(even) {
  background: #1a1a1a;
}

tr:nth-child(odd) {
  background: #111;
}

/* === Footer === */
footer {
  background: #222;
  padding: 7px;
  text-align: center;
  color: #b3b3b3;
  font-size: 0.7em;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}

/* =============================================================
   EPIC UI + PARCHMENT SECTION
   ============================================================= */
#epicSection,
.epic-modal-content {
  font-family: "Book Antiqua", Palatino, serif;
  color: #2b1b0e;
}

.parchment {
  background: linear-gradient(180deg, rgba(255,250,230,0.95), rgba(245,230,190,0.95));
  border: 1px solid rgba(140,110,60,0.28);
  box-shadow: 0 6px 20px rgba(30,20,10,0.25);
  padding: 18px;
  border-radius: 10px;
  line-height: 1.8;
  color: #2f2b1f;
  white-space: pre-wrap;
}

#epicTextView,
#epicText {
  font-family: "Book Antiqua", Palatino, serif;
  background: #f5f1e6;
  color: #2b1b0e;
  border-radius: 8px;
  border: 1px solid #d0c7b5;
  padding: 10px;
  line-height: 1.8;
}

/* === Epic Modal === */
.epic-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(3px);
}

.epic-modal-content {
  margin: 5% auto;
  padding: 20px;
  border: 1px solid #d0c7b5;
  border-radius: 10px;
  width: 70%;
  max-width: 800px;
  max-height: 80%;
  overflow-y: auto;
  background: #f5f1e6;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
  font-size: 10.5pt;
}

.epic-close {
  float: right;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  color: #7b6b55;
}

.epic-close:hover {
  color: #a03a2b;
}

/* === Buttons (Epic) === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(30,20,10,0.12);
  transition: transform .12s ease, box-shadow .12s ease;
}

.btn-primary {
  background: linear-gradient(180deg,#f4e0b8,#e8c77a);
  color:#2b1f08;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

/* === User Libraries === */
.ul-backdrop {
  position: fixed;
  top:0;
  left:0;
  width:100vw;
  height:100vh;
  background:rgba(0,0,0,0.55);
  display:flex;
  justify-content:center;
  align-items:center;
  padding-top:0;
  z-index:9999;
}

.ul-modal {
  background:#1a1a1a;
  width:90%;
  max-width:450px;
  height:auto;
  max-height:85vh;
  overflow-y:auto;
  border-radius:8px;
  display:flex;
  flex-direction:column;
  border:1px solid #555;
}

.ul-modal-header {
  padding:12px 16px;
  background:#222;
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:1px solid #444;
  font-weight:bold;
  color:#eee;
}

.ul-modal-body {
  flex:1;
  overflow-y:auto;
  padding:12px 16px;
  color:#ddd;
}

.ul-modal-footer {
  padding:12px 16px;
  background:#222;
  border-top:1px solid #444;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

/* Buttons inside User Libraries */
.ul-btn {
  cursor:pointer;
  background:#444;
  border:1px solid #666;
  padding:4px 8px;
  color:#eee;
  border-radius:4px;
}

.ul-btn:hover {
  background:#667;
}

/* === Instructions in modal === */
.instructions h4 {
  margin-top: 12px;
  font-size: 1.15em;
  color: #ffd27b;
}

.instructions h5 {
  margin-top: 10px;
  font-size: 1em;
  color: #ffefc2;
}

.instructions p,
.instructions li {
  margin-bottom: 6px;
  font-size: 0.9em;
}

.instructions ul,
.instructions ol {
  margin-left: 15px;
  margin-bottom: 10px;
}

/* === Responsive layout for main panels === */
@media (max-width:768px) {
  .layout-container {
    grid-template-columns:1fr;
    position:static;
  }
  .left-panel textarea {
    height:180px;
  }
  .epic-modal-content {
    width:90%;
  }
}

/* === Mobile header layout === */
@media (max-width: 600px) {

  header {
    padding: 8px;
  }

  .header-top-row {
    gap: 6px;
  }

  header h1 {
    font-size: 1em;
    line-height: 1.3;
    background: #333;
    padding: 6px 8px;
    border-radius: 6px;
  }

  .header-img {
    width: 70px;
  }

  .header-links {
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
  }

  #howToBtn {
    width: 100%;
    margin-top: 4px;
  }
}

/* Πιο χαμηλό header για tablet / laptop / desktop */
@media (min-width: 768px) {
  header {
    padding: 4px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  header nav {
    margin-top: 0;
  }

  .header-links {
    margin-top: 0;
  }

  header h1 {
    font-size: 1.05em;
  }

  .header-img {
    width: 60px;
  }

  .header-links a,
  #howToBtn {
    padding: 4px 8px;
    font-size: 0.9em;
  }
}

/* Table selection + Memory Palace Mode row */
.dropdown-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  font-size: 0.9em;
}

.dropdown-group h4 {
  margin: 0;
  display: inline;
  font-size: 1em;
}

.dropdown-group label {
  font-weight: bold;
}

.dropdown-group select {
  padding: 5px 10px;      /* ίδιο ύψος στα δύο dropdowns */
  border-radius: 4px;
}

/* Πιο μεγάλη εικόνα στο laptop / desktop */
@media (min-width: 1024px) {
  .header-img {
    width: 90px;   /* δοκίμασε 90 – αν τη θες μεγαλύτερη βάλε 100 ή 110 */
  }
}

/* Μικρότερη γραμματοσειρά στους τίτλους των στηλών και στο toolbar */
.table-wrapper table thead th {
  font-size: 0.8rem;   /* παίξε με 0.75–0.9 ανάλογα πώς το θες */
}

.table-toolbar {
  font-size: 14px;
}
