/* 
 * Palabras Cruzadas - Estilos CSS
 * Archivo: assets/css/styles.css
 */

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

:root {
    --primary-color: #6366f1;
    --secondary-color: #a78bfa;
    --accent-color: #fbbf24;
    --bg-dark: #1e1b4b;
    --bg-light: #f8fafc;
    --text-dark: #1e293b;
    --text-light: #e2e8f0;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-dark);
    height: 100vh;
    min-height: 500px;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@media (max-height: 500px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 500px;
    }
    .main-container {
        overflow-y: visible;
    }
}

@media (max-width: 250px) {
    body {
        overflow-x: auto;
        min-width: 250px;
    }
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    padding: clamp(0.75rem, 2vh, 1.5rem) 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.game-title {
    font-size: clamp(1.25rem, 4vh, 1.75rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.game-id {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1rem, 2.5vh, 1.25rem);
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
}

@media (max-width: 500px) {
    .game-id {
        position: static;
        transform: none;
        order: 2;
        margin: 0 0.5rem;
    }
    .header {
        flex-wrap: wrap;
        justify-content: center;
    }
    .game-title {
        order: 1;
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }
    .menu-btn {
        order: 3;
    }
}

.menu-btn {
    width: clamp(35px, 6vh, 40px);
    height: clamp(35px, 6vh, 40px);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease;
}

.menu-btn:hover {
    transform: scale(1.05);
}

.menu-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-dark);
    margin: 5px auto;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: clamp(0.75rem, 2vh, 1.5rem);
    gap: clamp(0.75rem, 2vh, 1.5rem);
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
}

.board-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: clamp(1rem, 3vh, 2rem);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(0.6rem, 2vh, 1rem);
    width: 100%;
    max-width: clamp(200px, 40vh, 300px);
    aspect-ratio: 1;
}

.letter-cell {
    background: var(--bg-light);
    border: 3px solid var(--primary-color);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.25rem, 4vh, 2rem);
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
}

.letter-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.letter-cell:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.letter-cell.dragging {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(0.95);
}

.letter-cell.center {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--bg-dark);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.info-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: clamp(1rem, 2.5vh, 1.5rem);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 2vh, 1.5rem);
    flex-shrink: 0;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.timer-container, .points-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.timer-icon, .points-icon {
    width: clamp(35px, 6vh, 40px);
    height: clamp(35px, 6vh, 40px);
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: clamp(1rem, 2.5vh, 1.2rem);
}

.points-icon {
    background: var(--accent-color);
}

.timer-text, .points-text {
    font-size: clamp(1.1rem, 2.5vh, 1.5rem);
    font-weight: 600;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-dark);
    font-size: clamp(0.9rem, 2vh, 1rem);
}

.progress-bar {
    width: 100%;
    height: clamp(16px, 3vh, 20px);
    background: var(--bg-light);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.word-display {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: clamp(1rem, 2.5vh, 1.5rem);
    box-shadow: var(--shadow-lg);
    min-height: clamp(60px, 12vh, 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.25rem, 3.5vh, 2rem);
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: 0.15em;
    transition: all 0.3s ease;
    text-transform: uppercase;
    flex-shrink: 0;
}

.word-display.placeholder {
    font-size: clamp(0.9rem, 2.5vh, 1.2rem);
    color: #94a3b8;
    font-weight: 500;
    letter-spacing: normal;
    text-transform: none;
}

.word-display.forming {
    color: var(--primary-color);
}

.word-display.success {
    background: rgba(247, 247, 252, 1);
    color: #16a34a;
    animation: successPulse 0.6s ease;
}

.word-display.error {
    background: rgba(247, 247, 252, 1);
    color: #dc2626;
    animation: shake 0.5s ease;
}

.word-display.duplicate {
    background: rgba(247, 247, 252, 1);
    color: #f59e0b;
    animation: shake 0.5s ease;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.drag-line {
    position: fixed;
    pointer-events: none;
    z-index: 50;
}

.drag-line svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.drag-line path {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 6px rgba(99, 102, 241, 0.5));
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 1.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 200;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.menu-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

@media (max-width: 640px) {
    .game-title { font-size: 1.5rem; }
    .main-container { padding: 1rem; gap: 1rem; }
    .board-section { padding: 1.5rem; }
    .game-board { max-width: 250px; }
    .word-display { font-size: 1.2rem; padding: 1rem; }
    .timer-text, .points-text { font-size: 1.1rem; }
    .stats-row { flex-direction: column; gap: 0.75rem; }
    .timer-container, .points-container { width: 100%; justify-content: center; }
    .input-section { flex-direction: column; }
    .word-input, .submit-btn { width: 100%; }
}

@media (max-height: 700px) and (max-width: 640px) {
    .main-container { gap: 0.75rem; }
    .board-section { padding: 1rem; }
    .game-board { max-width: 200px; gap: 0.5rem; }
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 100%;
    animation: slideUp 0.4s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.modal-header h2 { margin: 0; font-size: 1.5rem; font-weight: 700; }

.modal-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: 10px;
}

.result-label { font-weight: 600; color: #64748b; }
.result-value { font-weight: 700; color: var(--text-dark); font-size: 1.1rem; }

.modal-footer {
    padding: 1.5rem;
    background: var(--bg-light);
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.share-btn, .new-game-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-btn {
    background: var(--accent-color);
    color: var(--text-dark);
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.4);
}

.new-game-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.new-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.share-icon { font-size: 1.2rem; }

.timer-text.warning {
    color: #ef4444;
    animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================
   MODALES FULLCOVER (Bienvenida y Pausa)
   ============================================ */

.modal-fullcover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.modal-large {
    max-width: 420px;
    max-height: 85vh;
}

/* Layout fijo: header y footer siempre visibles */
.modal-fixed-layout {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-fixed-layout .modal-header {
    flex-shrink: 0;
}

.modal-fixed-layout .modal-footer {
    flex-shrink: 0;
}

.modal-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: block;
}

.modal-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Instrucciones compactas */
.modal-body-scroll h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light);
    border-radius: 8px;
}

.instruction-item.compact {
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
}

.instruction-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.instruction-text {
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--text-dark);
}

.instruction-text strong {
    color: var(--primary-color);
}

/* Tabla de puntos compacta */
.points-table {
    margin-top: 1rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(167, 139, 250, 0.1));
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.points-table h4 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.points-table.compact {
    margin-top: 0.75rem;
    padding: 0.5rem;
}

.points-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.3rem;
    font-size: 0.8rem;
    text-align: center;
}

.points-grid span {
    padding: 0.3rem 0.2rem;
    background: white;
    border-radius: 4px;
    color: var(--text-dark);
    font-weight: 600;
}

/* Divisor entre stats e instrucciones */
.instructions-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
    margin: 1rem 0;
}

.instructions-title-small {
    text-align: center;
    color: var(--primary-color);
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

/* Botón Iniciar */
.btn-start {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

/* ============================================
   MODAL PAUSA
   ============================================ */

.modal-header-pause {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.pause-stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.pause-stat {
    background: var(--bg-light);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-align: center;
    min-width: 80px;
}

.pause-stat-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.15rem;
}

.pause-stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Botón Continuar */
.btn-continue {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-continue:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-continue:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

/* ============================================
   MODAL GAME OVER MEJORAS
   ============================================ */

.modal-note {
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    color: #64748b;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 0 0 20px 20px;
}

/* ============================================
   TABLERO DESHABILITADO
   ============================================ */

.game-board.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.game-board.disabled .letter-cell {
    cursor: not-allowed;
}

/* ============================================
   RESPONSIVE PARA MODALES
   ============================================ */

@media (max-width: 500px) {
    .modal-large {
        margin: 0.5rem;
        max-height: 92vh;
    }
    
    .modal-body-scroll {
        padding: 1rem;
    }
    
    .instruction-item {
        padding: 0.4rem 0.6rem;
        gap: 0.5rem;
    }
    
    .instruction-icon {
        font-size: 1rem;
        width: 24px;
    }
    
    .instruction-text {
        font-size: 0.85rem;
    }
    
    .points-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.25rem;
        font-size: 0.75rem;
    }
    
    .pause-stats {
        gap: 0.5rem;
    }
    
    .pause-stat {
        min-width: 70px;
        padding: 0.5rem 0.75rem;
    }
    
    .pause-stat-value {
        font-size: 1rem;
    }
    
    .btn-start, .btn-continue {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-height: 650px) {
    .modal-large {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-footer {
        padding: 1rem;
    }
    
    .instruction-item {
        margin-bottom: 0.4rem;
    }
    
    .points-table {
        margin-top: 0.75rem;
        padding: 0.5rem;
    }
}
