/* ==================================================
   BASE Y ESTILOS GENERALES
================================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-blend-mode: overlay;
    cursor: url('../assets/img/cursor_normal.png'), auto;
}

/* Modo claro (por defecto) */
@media (prefers-color-scheme: light) {
    body {
        background-image: url('../assets/img/bluebasegif.gif');
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    body {
        background-image: url('../assets/img/pinkbasegif.gif');
    }
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 14px;
}

/* ==================================================
   GRID LAYOUT
================================================== */
#layout-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    grid-template-rows: repeat(4, minmax(120px, auto));
    gap: 12px;
    width: 100%;
    max-width: 2000px;
    margin: 2rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
    grid-template-areas:
        "cycles   t1       t2       controls"
        "sudoku-board   display1 display2 player"
        "sudoku-board   bgspeed  . .";
    grid-auto-flow: dense;
}

.grid-cell {
    padding: 15px;
}

/* Asignación de áreas */
.area-cycles   { grid-area: cycles; }
.area-t1       { grid-area: t1; }
.area-t2       { grid-area: t2; }
.area-controls { grid-area: controls; }
.area-sudoku   { grid-area: sudoku; }
.area-player   { grid-area: player; }
.area-display1 { grid-area: display1; }
.area-display2 { grid-area: display2; }
.area-sudoku-board { grid-area: sudoku-board; }
.area-bgspeed { grid-area: bgspeed; }

/* Centrado de contenido en celdas clave */
.area-sudoku,
.area-player,
.area-controls,
.area-cycles,
.area-t1,
.area-t2,
.area-display1,
.area-display2,
.area-sudoku-board,
.area-bgspeed {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Centrar el contenido de ciclos, trabajo y descanso */
#ciclos,
#temporizadorEstudio,
#temporizadorDescanso {
    align-items: center;
}

/* Alineación específica para celdas de fila 1 */
.r1c1, .r1c2, .r1c3 {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* ==================================================
   TEMPORIZADORES
================================================== */
#temporizadores {
    display: flex;
    align-items: center;
}

.temporizador {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 140px;
    box-sizing: border-box;
    flex: 1 1 0;
    min-width: 120px;
}

.temporizador-label,
#ciclos-label,
.qt-display,
.text {
    font-family: monospace, sans-serif;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    cursor: url('../assets/img/cursor_normal.png'), auto;
}

.text {
    font-size: 16px;
    margin-bottom: 0;
}

#ciclos-label {
    margin-bottom: 10px;
}

.qt-row {
    display: flex;
    gap: 7px;
    align-items: center;
}

.qt-display {
    font-size: 64px;
}

/* Orden específico */
#ciclos              { order: 0; }
#temporizadorEstudio { order: 1; }
#temporizadorDescanso{ order: 2; }

/* ==================================================
   INPUTS CON ETIQUETA FLOTANTE (Uiverse - Maximinodotpy)
================================================== */

.inputGroup {
    font-family: 'Segoe UI', sans-serif;
    margin: 0.5em 0 0.5em 0;
    max-width: 190px;
    position: relative;
}

.inputGroup input {
    font-family: monospace, sans-serif;
    color: #752500;
    font-size: 100%;
    padding: 0.8em;
    outline: none;
    border: 2px solid rgb(200, 200, 200);
    background-color: transparent !important;
    border-radius: 20px;
    width: 100%;
    box-sizing: border-box;
    cursor: url('../assets/img/cursor_input.png'), auto;
    position: relative;
    text-align: center;
}

.inputGroup label {
    font-size: 100%;
    position: absolute;
    left: 0;
    padding: 0.8em;
    margin-left: 0.5em;
    pointer-events: none;
    transition: all 0.3s ease;
    color: rgb(100, 100, 100);
}

.inputGroup :is(input:focus, input:valid) ~ label {
    transform: translateY(-50%) scale(.9);
    margin: 0em;
    margin-left: 1.3em;
    padding: 0.4em;
    background-color: #e8e8e8;
}

.inputGroup :is(input:focus, input:valid) {
    border-color: rgb(150, 150, 200);
}

/* Contenedor para inputs de timer */
.qt-min,
.qt-sec,
#cycle-count {
    font-family: monospace, sans-serif;
    color: #752500;
    font-size: 100%;
    padding: 0.8em;
    outline: none;
    border: 2px solid rgb(200, 200, 200);
    background-color: transparent !important;
    border-radius: 20px;
    width: 100%;
    box-sizing: border-box;
    cursor: url('../assets/img/cursor_input.png'), auto;
    position: relative;
    text-align: right;
}

/* Input específico de cycles más estrecho */
#cycle-count {
    max-width: 100px;
}

/* Estilos para inputs deshabilitados */
.qt-min:disabled,
.qt-sec:disabled,
#cycle-count:disabled {
    background: #d7d7d7 !important;
    color: #5f5f5f !important;
    cursor: url('../assets/img/cursor_prohibido.png'), not-allowed !important;
    filter: grayscale(20%);
}

/* Inputs deshabilitados: mucho más grises y con cursor bloqueado */
#temporizadores input[type="number"]:disabled {
    background: #d7d7d7 !important;
    color: #5f5f5f !important;
    cursor: url('../assets/img/cursor_prohibido.png'), not-allowed !important;
    filter: grayscale(20%);
}

/* Cursor normal en las flechitas (spinner) de los inputs number */
.qt-min::-webkit-outer-spin-button,
.qt-min::-webkit-inner-spin-button,
.qt-sec::-webkit-outer-spin-button,
.qt-sec::-webkit-inner-spin-button,
#cycle-count::-webkit-outer-spin-button,
#cycle-count::-webkit-inner-spin-button {
    cursor: url('../assets/img/cursor_normal.png'), auto;
}

/* ==================================================
   CONTROLES Y BOTONES GENERALES
================================================== */
#temporizadorControles {
    order: 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.controles {
    font-family: monospace, sans-serif;
    font-size: 18px;
    font-weight: 500;
    background: #ffffff8a;
    color: #000;
    border: 0px;
    margin-left: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    box-sizing: border-box;
}

.controles:hover {
    background-color: #82b8ff71;
}

/* ==================================================
   BOTONES POMODORO (Empezar, Pausar, Resetear)
================================================== */
#qt1-start,
#qt1-pause,
#qt1-reset {
    --button_radius: 0.75em;
    --button_color: #ffcb8f;
    --button_outline_color: #752500;
    font-size: 17px;
    font-weight: bold;
    border: none;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    border-radius: var(--button_radius);
    background: var(--button_outline_color);
    margin-left: 6px;
    padding: 0;
}

#qt1-start .button_top,
#qt1-pause .button_top,
#qt1-reset .button_top {
    display: block;
    box-sizing: border-box;
    border: 2px solid var(--button_outline_color);
    border-radius: var(--button_radius);
    padding: 0.75em 1.5em;
    background: var(--button_color);
    color: var(--button_outline_color);
    transform: translateY(-0.2em);
    transition: transform 0.1s ease;
}

#qt1-start:hover .button_top,
#qt1-pause:hover .button_top,
#qt1-reset:hover .button_top {
    transform: translateY(-0.33em);
}

#qt1-start:active .button_top,
#qt1-pause:active .button_top,
#qt1-reset:active .button_top {
    transform: translateY(0);
}

/* ==================================================
   REPRODUCTOR
================================================== */
#player {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 0.75rem;
    box-sizing: border-box;
}

.player-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 420px;
}

.player-inner {
    flex: 1;
    padding: 0.75rem;
    border-radius: 12px;
    box-sizing: border-box;
}

.player-track {
    font-family: monospace, sans-serif;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    text-align: center;
    font-weight: 600;
    margin: 4px 0 8px;
    word-break: break-word;
}

.progress {
    width: 100%;
    height: 8px;
    background: rgba(255, 190, 149, 0.574);
    border-radius: 6px;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    overflow: hidden;
    margin-bottom: 0.6rem;
    user-select: none;
    position: relative;
}

.progress:active {
    cursor: url('../assets/img/cursor_mano.png'), grabbing;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg,#fce7a4,#ff8282);
    border-radius: 6px 0 0 6px;
    pointer-events: none;
    transition: width 0.05s linear;
}

.player-controls {
    display: flex;
    gap: 7px;
    justify-content: center;
    align-items: center;
}

.player-controls button {
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    font-size: 1rem;
}

/* Botones con iconos */
.player-btn {
    width: 32px;
    height: 32px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 32px 32px;
    padding: 0;
}

.player-btn:hover {
    background-size: 34px 34px;
}

.player-btn-rew   { background-image: url('../assets/img/rewind_button.png'); }
.player-btn-play  { background-image: url('../assets/img/play_button.png'); }
.player-btn-pause { background-image: url('../assets/img/stop_button.png'); }
.player-btn-fwd   { background-image: url('../assets/img/skip_button.png'); }

/* Fila combinada opcional */
.player-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* ==================================================
   SUDOKU
================================================== */
#sudoku-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    --sudoku-cell: 30px;
    --sudoku-gap: 1px;
    --sudoku-border: 2px;
}

#sudoku-container h3 {
    font-family: monospace, sans-serif;
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    cursor: url('../assets/img/cursor_normal.png'), auto;
    text-align: center;
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, var(--sudoku-cell));
    grid-template-rows: repeat(9, var(--sudoku-cell));
    gap: var(--sudoku-gap);
    border: var(--sudoku-border) solid #85411d;
    width: calc(9 * var(--sudoku-cell) + 8 * var(--sudoku-gap) + 2 * var(--sudoku-border));
    margin: 0 auto;
}

/* Cursor personalizado para inputs del Sudoku */
#sudoku-board .sudoku-cell {
    cursor: url('../assets/img/cursor_input.png'), auto;
}

/* Sudoku: celdas deshabilitadas más evidentes */
#sudoku-board .sudoku-cell:disabled {
    background: #dcdcdc !important;
    color: #5e5e5e !important;
    cursor: url('../assets/img/cursor_prohibido.png'), not-allowed !important;
}

#sudoku-board .sudoku-cell::-webkit-outer-spin-button,
#sudoku-board .sudoku-cell::-webkit-inner-spin-button {
    cursor: url('../assets/img/cursor_normal.png'), auto;
}

.area-bgspeed {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0;
}

.sudoku-controls {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 8px;
    flex-wrap: nowrap;
    width: calc(9 * var(--sudoku-cell) + 8 * var(--sudoku-gap) + 2 * var(--sudoku-border));
    margin: 0 auto;
    overflow: visible;
}

.sudoku-controls button {
    font-family: monospace, sans-serif;
    font-size: 13px;
    font-weight: bold;
    background: #752500;
    color: #000;
    border: 0px;
    padding: 0;
    border-radius: 0.75em;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
    line-height: 1.15;
}

.sudoku-controls button .button_top {
    display: block;
    box-sizing: border-box;
    border: 2px solid #752500;
    border-radius: 0.75em;
    padding: 0.75em 1em;
    background: #ffcb8f;
    color: #752500;
    transform: translateY(-0.2em);
    transition: transform 0.1s ease;
    white-space: normal;
    overflow-wrap: anywhere;
}

.sudoku-controls button:hover .button_top {
    transform: translateY(-0.33em);
}

.sudoku-controls button:active .button_top {
    transform: translateY(0);
}

.sudoku-controls #check-sudoku {
    flex: 1.2 1 0;
}

.sudoku-controls #check-sudoku .button_top {
    padding: 0.75em 1.2em;
}

#sudoku-message {
    font-family: monospace, sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    text-align: center;
    min-height: 20px;
}

.icon-button#btn-sudoku {
    width: 274px;
    height: 87px;
    border: none;
    border-radius: 20px;
    background: url('../assets/img/sudoku.png') no-repeat center / 100%;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    box-shadow: 0 4px 14px rgba(0,0,0,0);
}

.icon-button#btn-sudoku:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.3);
    background-size: 279px 91px;
}

/* Estado bloqueado del Sudoku */
#sudoku-container.locked {
    opacity: 0.5;
}

#sudoku-container.locked .sudoku-controls button {
    pointer-events: none;
    filter: grayscale(60%);
}

/* ==================================================
   CONTROL DE VELOCIDAD DEL GIF
================================================== */
.speed-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 250px;
}

.speed-label {
    font-family: monospace, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    text-align: center;
}

#gif-speed {
    width: 100%;
    height: 6px;
    background: rgba(255, 190, 149, 0.574);
    border-radius: 6px;
    outline: none;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    -webkit-appearance: none;
}

#gif-speed::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(90deg, #fce7a4, #ff8282);
    border-radius: 50%;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    border: 2px solid #752500;
}

#gif-speed::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(90deg, #fce7a4, #ff8282);
    border-radius: 50%;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    border: 2px solid #752500;
}

#speed-value {
    font-family: monospace, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
}

/* ==================================================
   CONTROL DE VOLUMEN
================================================== */
.volume-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 250px;
    padding: 0.75rem;
    min-height: 11px;
    justify-content: space-around;
}

.volume-label {
    font-family: monospace, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
    text-align: center;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    background: rgba(255, 190, 149, 0.574);
    border-radius: 6px;
    outline: none;
    cursor: url('../assets/img/cursor_mano.png'), auto;
    transform: rotate(-90deg);
    transform-origin: center;
    padding: 0;
    margin: 40px 0;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    width: 24px !important;
    height: 24px !important;
    background: linear-gradient(90deg, #fce7a4, #ff8282) !important;
    border-radius: 50% !important;
    cursor: url('../assets/img/cursor_mano.png'), auto !important;
    border: 2px solid #752500 !important;
}

#volume-slider::-moz-range-thumb {
    width: 24px !important;
    height: 24px !important;
    background: linear-gradient(90deg, #fce7a4, #ff8282) !important;
    border-radius: 50% !important;
    cursor: url('../assets/img/cursor_mano.png'), auto !important;
    border: 2px solid #752500 !important;
}

#volume-value {
    font-family: monospace, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #85411d;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.815);
}

/* Botón de mute */
.volume-btn {
    width: 32px;
    height: 32px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 32px 32px;
    border: none;
    padding: 0;
    border-radius: 6px;
    cursor: url('../assets/img/cursor_mano.png'), auto;
}

.volume-btn:hover {
    background-size: 34px 34px;
}

.volume-btn-on {
    background-image: url('../assets/img/volume_on.png');
}

.volume-btn-off {
    background-image: url('../assets/img/volume_off.png');
}

/* ==================================================
   MEDIA QUERIES
================================================== */

/* Tablet (<=1150px) */
@media (max-width: 1150px) {
    #layout-grid {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
        grid-template-areas:
            "cycles   t1       t2"
            "controls display1   display2"
            "player sudoku-board bgspeed";
    }
}

/* Móvil (<=870px) */
@media (max-width: 870px) {
    #layout-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "cycles"
            "t1"
            "display1"
            "t2"
            "display2"
            "controls"
            "player"
            "bgspeed"
            "sudoku-board";
    }
    .grid-cell { min-height: 120px; }
    .player-inner { max-width: 100%; }
    .sudoku-controls { font-size: 80%; }
}

/* Opcional: en pantallas muy pequeñas permite wrap */
@media (max-width: 420px) {
    .sudoku-controls {
        flex-wrap: nowrap;
        overflow-x: visible;
        font-size: 10px;
    }
}
