/* =========================================================
   d24Chess Trainer - Fase 8 lectura ajustes finos
   DESKTOP
========================================================= */

*{
  box-sizing:border-box;
}

html,
body{
  width:100%;
  min-height:100dvh;
  margin:0;
  padding:0;
}

body{
  font-family:Arial, Helvetica, sans-serif;
  background:#d9d9d9;
  color:#222;
}

button,
input{
  font:inherit;
}

button{
  appearance:none;
}

.hidden{
  display:none !important;
}

/* Rotate warning */

.rotate-warning{
  display:none;
  position:fixed;
  inset:0;
  z-index:9999;
  background:#fff;
  align-items:flex-start;
  justify-content:center;
  padding-top:32px;
}

.rotate-warning-card{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-width:320px;
  padding:16px;
  text-align:center;
}

/* App */

.app{
  width:100%;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  background:#fff;
}

/* Header */

.app-header{
  width:100%;
  padding:10px 14px;
  background:#7699af;
  border-bottom: 1px solid #bdbdbd
}

.header-inner{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}

.header-info{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.app-header h1,
.project-title h1{
  font-family:'Dragon', system-ui, sans-serif !important;
  letter-spacing:1px;
  font-style:italic;
  font-size:30px;
  margin: 0px;
}

.project-title-d24{
  color:#000;
}

.title-chess{ 
  color:#fff;
  font-style: italic; 
}

.project-title-main{
  color:#7a4b24;
  margin-left:4px;
}

.mode-info{
  font-size:13px;
  font-weight: 700;
  color:#000;
}

.main-mode-buttons{
  display:flex;
  align-items:center;
  gap:8px;
}

.main-mode-btn{
  border:1px solid #bbb;
  border-radius:10px;
  background:#fff;
  padding:8px 14px;
  font-weight:800;
  cursor:pointer;
}

.main-mode-btn.active{
  border: 2px solid #222;
}

.mode-btn-icon{
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
  user-select: none;
}

/* Main panels */

.main-panels{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns:1fr 1fr;
  /*gap:12px;
  padding:12px;*/
}

/*
.left-panel{
  background:#fff3ad;
  min-height:0;
  border-radius:14px;
  padding:10px;
  overflow:hidden;
}*/

.left-panel{
  background:#fff;
  padding:10px;

  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:flex-start !important;
  overflow:visible !important;
}

.right-panel{
  background:#d3dfe6;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:0;
  padding:10px;
  overflow:hidden;
}

/* Left panel */

.board-block{
  width:min(100%, calc(100vh - 290px));
  max-width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  box-sizing:border-box;
}

.board-container,
.board-shell,
.turn-indicator-panel,
.message-panel,
.stockfish-analysis-panel,
.clock-panel,
.board-controls{
  width:100%;
}

.board-container{
  flex:1;
  min-height:260px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.board-shell{
  width:min(100%, calc(100vh - 290px));
  aspect-ratio:1 / 1;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#7a4b24;
  border: 10px solid color-mix(in srgb, #7699af 70%, black);
}

/* Board */

.board-with-coords{
  width:100%;
  height:100%;
  display:grid;
  grid-template-rows:22px 1fr 22px;
  grid-template-columns:1fr;
  background:#f4f4f4;
}

.board-middle-row{
  min-height:0;
  display:grid;
  grid-template-columns:22px 1fr 22px;
}

.board-coords{
  display:grid;
  grid-template-columns:repeat(8, 1fr);
  align-items:center;
  justify-items:center;
  font-size:12px;
  font-weight:800;
  color:#4b321d;
}

.board-side-coords{
  display:grid;
  grid-template-rows:repeat(8, 1fr);
  align-items:center;
  justify-items:center;
  font-size:12px;
  font-weight:800;
  color:#4b321d;
}

#boardTopCoords,
#boardRightCoords{
color: #f4f4f4;
}

.chess-board{
  width:100%;
  height:100%;
  display:grid;
  grid-template-columns:repeat(8, 1fr);
  grid-template-rows:repeat(8, 1fr);
  overflow:hidden;
  background-image:url("../img/boards/icy_sea.png");
  background-size:100% 100%;
  background-repeat:no-repeat;
  background-position:center;
}

.board-square{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  border:none;
  padding:0;
  margin:0;
  min-width:0;
  min-height:0;
  user-select:none;
  cursor:pointer;
}

.board-square{
  background:transparent;
}

.board-square.selected{
  outline:3px solid rgba(20, 20, 20, .55);
  outline-offset:-3px;
}


.board-square.last-move{
  box-shadow:none;
}

.board-square.last-move-from{
  background:rgba(255, 210, 70, .34);
}

.board-square.last-move-to{
  background:rgba(70, 150, 255, .30);
}

.board-piece{
  width:96%;
  height:96%;
  object-fit:contain;
  display:block;
  pointer-events:none;
  user-select:none;
}

.white-piece,
.black-piece{
  filter:drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

/*
.turn-indicator-panel{
  display:grid;
  grid-template-columns:36px 1fr 36px;
  gap:10px;
  align-items:center;
}
*/


.turn-indicator-panel{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  box-sizing:border-box;
  padding:8px 4px 4px;
}

.turn-side-indicator{
  width:25px;
  height:25px;
  margin: 10px 0px;
  border:1px solid #111;
  box-sizing:border-box;
  opacity:.35;
  transition:opacity .15s ease, transform .15s ease, box-shadow .15s ease;
}

.turn-white{
  background:#fff;
}

.turn-black{
  background:#000;
}

.turn-side-indicator.active-turn{
  opacity:1;
  transform:scale(1.15);
  box-shadow:0 0 0 2px rgba(11,132,255,.35);
}

.center-info-indicator,
.message-panel,
.stockfish-analysis-panel,
.clock-panel,
.board-controls{
  border-radius:10px;
  background:#fff;
  padding:8px;
}

.center-info-indicator{
  height: 34px;
  text-align:center;
  font-weight:800;
  background:#fff;
  color:#000;
}


.message-panel{
  min-height:36px;
  text-align:center;
  font-weight:700;
}

.stockfish-analysis-panel{
  display:flex;
  flex-direction:column;
  gap:5px;
  font-size:13px;
  margin-bottom: 10px;
}

.stockfish-line{
  display:grid;
  grid-template-columns:70px 1fr;
  gap:8px;
}

.stockfish-eval{
  font-weight:800;
}

.clock-panel{
  display:flex;
  justify-content:center;
  gap:12px;
}

.clock-box{
  min-width:110px;
  text-align:center;
  font-size:24px;
  font-weight:800;
}

.board-controls{
  display:flex;
  justify-content:center;
  gap:16px;
}

.board-control-btn,
.icon-action-btn,
.submenu-btn{
  display:flex;
  justify-content:center;
  align-items: center;
  border:1px solid #bbb;
  border-radius:9px;
  background:#d3dfe6;
  padding:7px 10px;
  font-weight:800;
  cursor:pointer;
}

.submenu-btn{
  background:#fff;
}





/* Right panel */

.right-submenu{
  display:grid;
  grid-template-columns:64px 1fr;
  gap:8px;
  align-items:center;
  border-radius: 12px 12px 0px 0px;
  border-bottom: 2px solid #7699ae;
  padding:0px 0px 8px;
}

.submenu-info{
  text-align:center;
  font-weight:900;
}

.submenu-actions{
  display:flex;
  gap:6px;
  align-items: center;
  width: 100%;
}

#analysisSubmenu{
  display: flex;
}

.submenu-btn{
  flex:1;
}

.submenu-btn.active{
  border: 2px solid #222;
}

.right-content-area{
  flex:1;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.content-panel{
  border-radius:12px;
  background:#7699ae;
  padding:10px;
}

.pgn-loader-panel{
  height: 100%;
  min-height:190px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.pgn-loader-top{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  box-sizing:border-box;
  padding:8px 4px 4px;
  gap:8px;
}

.pgn-search-input{
  width:100%;
  border:1px solid #bbb;
  border-radius:9px;
  padding:7px 10px;
}

.pgn-list-panel,
.manual-position-panel,
.moves-panel,
.editor-panel{
  border-radius:10px;
  padding:10px;
  background:#fafafa;
}

.pgn-list-panel{
  flex:1;
  min-height:310px;
  overflow:auto;
  overflow-x:auto;
  padding:0;
}

#info_BD-partida{
  padding: 6px 0px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: visible;
  gap: 6px;
}

#info_num-partida{
  display: flex;
  flex-direction:row;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
  gap:6px;
}

#info_num-partida button{
  height: 28px;
}

#info_num-partida img{
  height: 18px;
}

.manual-position-panel{
  min-height:52px;
}

.pgn-load-control{
  position:relative;
  display:inline-flex;
}

.pgn-load-control .icon-action-btn{
  position:relative;
  z-index:1;
}


.pgn-database-select{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:0;
  cursor:pointer;
  z-index:2;
}

.pgn-status-line{
  border-radius:9px;
  background:#f4f4f4;
  padding:8px 10px;
  font-size:13px;
  font-weight:700;
}

.pgn-games-table{
  width:100%;
  min-width:680px;
  border-collapse:collapse;
  font-size:13px;
}

.pgn-games-table th,
.pgn-games-table td{
  border-bottom:1px solid #ddd;
  padding:7px 6px;
  text-align:left;
  vertical-align:top;
}

.pgn-games-table th{
  background:#d3dfe6;
  font-weight:900;
}

tr{cursor:pointer}
tbody tr:nth-child(even){background:#f6f6f6}
tbody tr:hover{background:#d8e9ff}
tbody tr.active{
  background:#0b84ff;
  color:white;
}

.pgn-game-row{
  cursor:pointer;
}

.pgn-game-row:hover{
  background:#f1f1f1;
}

.selected-game-row{
  background: #0b84ff !important;
  font-weight: 800;
  color: white;
}

.notation-panel{
  flex:1;
  min-height:240px;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.notation-top{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:center;
  padding-bottom: 6px;
  border-bottom: 1px solid #d3dfe6;
}

.notation-top-actions{
  display:flex;
  align-items:center;
  gap:6px;
}

.notation-game-counter{
  min-width:54px;
  text-align:center;
  font-weight:900;
  color:#000;
}

.notation-game-nav-btn{
  min-width:36px;
}

.game-title-info{
  font-weight:900;
  font-size: 20px;
}

.notation-metadata{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.event-meta-row{
  display:flex;
  justify-content:flex-start;
  align-items:center;
  font-size:14px;
  font-weight:700;
}

#eventFullInfo{
  display:inline-block;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.players-meta-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:8px;
  align-items:center;
}

.players-info{
  display:flex;
  flex-direction:column;
  gap:3px;
  font-weight:800;
}

.info-peones{
  display: flex;
  flex-direction:row;
  align-items:center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
}

.btn-icon-pawn{
  display: inline-block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: middle;
  flex: 0 0 auto;
}

#whitePlayerInfo{
  color: #fff;
}

.moves-panel{
  flex:1;
  min-height:140px;
  line-height:1.5;
}

.moves-list{
  width:100%;
  min-height:100%;
  white-space:normal;
  text-align: justify;
  line-height: 2.4;
}

.moves-list-active{
  display:block;
}

.moves-hidden{
    display:none !important;
}

body[data-main-mode="analysis"] .game-only,
body[data-main-mode="game"] .analysis-only{
  display:none !important;
}

.editor-panel{
  min-height:160px;
}


/* Lectura PGN - texto de anotación */

.notation-number{
  font-weight:900;
  margin-right:0px;
}

.notation-move{
  display:inline-block;
  border-radius:5px;
  cursor:pointer;
}

.move.notation-move.notation-black{
  margin-left: 2px;
  margin-right:10px;
}

.notation-move:hover{
  background:#ececec;
}

.notation-move.current{
  background:#536c7b;
  color:#fff;
}

.notation-comment{
  color:#555;
  font-style:italic;
  margin-right:6px;
}

.notation-variation{
  color:#777;
  margin-right:6px;
}

.notation-nag{
  color:#777;
  margin-right:6px;
}

.notation-result{
  font-weight:900;
}


/* =========================================================
   TABLET <= 900px
========================================================= */

@media(max-width:900px){

  .app-header{
    padding:8px 10px;
  }

  .header-inner{
    gap:10px;
  }

  .project-title{
    font-size:22px;
  }

  .main-panels{
    display:flex;
    flex-direction:column;
    gap:10px;
    padding:10px;
  }

  .left-panel,
  .right-panel{
    width:100%;
    overflow:visible;
  }

  .board-container{
    min-height:auto;
  }

  .board-shell{
    width:min(100%, calc(100dvh - 290px));
  }

  .right-panel{
    min-height:360px;
  }

}

/* =========================================================
   MOBILE <= 560px
========================================================= */

@media(max-width:560px){

  .header-inner{
    align-items:stretch;
  }

  .project-title{
  
    font-size:20px;
  }


  .main-mode-btn{
    flex:1;
    padding:7px 8px;
  }

  .main-panels{
    padding:8px 8px 0px;;
  }

  .left-panel{
    padding:0px;
  }

  
  .right-panel{
    padding:8px;
  }

  .board-shell{
    width:min(100%, calc(100dvh - 290px));
    border-width:4px;
  }

  .board-with-coords{
    grid-template-rows:18px 1fr 18px;
  }

  .board-middle-row{
    grid-template-columns:18px 1fr 18px;
  }

  .board-coords,
  .board-side-coords{
    font-size:10px;
  }

  .turn-indicator-panel{
    grid-template-columns:64px 1fr 64px;
    gap:5px;
  }

  .clock-box{
    min-width:88px;
    font-size:20px;
  }

  .board-controls{
    gap:5px;
  }

  .board-control-btn,
  .icon-action-btn,
  .submenu-btn{
    padding:6px 7px;
    font-size:12px;
  }

  .right-submenu{
    grid-template-columns:42px 1fr;
    gap:6px;
  }

  .submenu-actions{
    gap:4px;
  }

  .pgn-loader-top{
    grid-template-columns:1fr;
    gap:5px;
  }

  .event-meta-row{
    gap:8px;
    font-size:12px;
  }

}
