* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --primary-gradient: linear-gradient(145deg, #4a90d9, #357abd);
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-light: white;
    --text-dim: rgba(255, 255, 255, 0.7);
    --shadow: 0 20px 60px rgba(0,0,0,0.5);
    --shadow-btn: 0 4px 15px rgba(74, 144, 217, 0.3);
    --error: #ff6b6b;
    --success: #51cf66;
}

html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

.viewer-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.header {
    color: var(--text-light);
    text-align: center;
    margin-bottom: 15px;
    padding: 0 10px;
    flex-shrink: 0;
}

.header h1 {
    font-size: clamp(16px, 5vw, 20px);
    font-weight: 600;
    margin-bottom: 3px;
}

.header p {
    font-size: clamp(11px, 3vw, 12px);
    opacity: 0.7;
}

/* ✅ ELIMINAR transform del libro - causa conflictos con page-flip */
#book {
    box-shadow: var(--shadow);
    border-radius: 5px;
    max-width: 100%;
    max-height: 100%;
    position: relative;
}

.page {
    background-color: white;
    overflow: hidden;
}

.page-content {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#loading {
    color: var(--text-light);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-direction: column;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-bg);
    border-top-color: var(--text-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error { color: var(--error) !important; }
.success { color: var(--success) !important; }

.controls-footer {
    flex-shrink: 0;
    width: 100%;
    margin-top: 10px;
}

.controls {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    border: 1px solid var(--glass-border);
}

.btn {
    background: var(--primary-gradient);
    color: var(--text-light);
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-btn);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 217, 0.5);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.5;
}

.btn-icon {
    padding: 12px 15px;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    justify-content: center;
}

.page-indicator {
    color: var(--text-light);
    font-size: 16px;
    font-weight: 500;
    padding: 10px 20px;
    background: var(--glass-bg);
    border-radius: 25px;
    min-width: 120px;
    text-align: center;
    cursor: pointer;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-light);
    font-size: 14px;
}

.zoom-slider {
    width: 100px;
    height: 5px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Móvil */
.mobile-controls {
    display: none;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.mobile-page-indicator {
    background: var(--primary-gradient);
    color: var(--text-light);
    padding: 15px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
}

.mobile-page-indicator .page-number {
    font-size: clamp(20px, 6vw, 24px);
    font-weight: bold;
    display: block;
}

.mobile-page-indicator .page-total {
    font-size: clamp(12px, 3vw, 14px);
    opacity: 0.9;
}

/* ✅ Zoom control para móvil */
.mobile-zoom-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-light);
    padding: 10px;
    background: var(--glass-bg);
    border-radius: 10px;
    margin-bottom: 15px;
}

.mobile-zoom-control .zoom-slider {
    width: 150px;
}

.nav-buttons-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.nav-btn {
    background: var(--primary-gradient);
    color: var(--text-light);
    border: none;
    padding: 15px 5px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    min-height: 65px;
}

.nav-btn:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #357abd, #4a90d9);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.nav-btn .icon {
    font-size: clamp(18px, 5vw, 20px);
}

.nav-btn .label {
    font-size: clamp(8px, 2.5vw, 9px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}

.action-btn:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.98);
}

.swipe-hint {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    font-size: 11px;
    margin-top: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

.modal-content {
    background: #1a1a2e;
    border-radius: 20px;
    padding: 25px;
    width: 100%;
    max-width: 350px;
    border: 1px solid var(--glass-border);
}

.modal-title {
    color: var(--text-light);
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}

.modal-input {
    width: 100%;
    padding: 15px;
    font-size: 24px;
    text-align: center;
    border: 2px solid var(--glass-border);
    border-radius: 10px;
    background: var(--glass-bg);
    color: var(--text-light);
    margin-bottom: 20px;
    outline: none;
}

.modal-input:focus {
    border-color: var(--primary);
}

.modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.modal-btn {
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.modal-btn.cancel {
    background: var(--glass-bg);
    color: var(--text-light);
}

.modal-btn.confirm {
    background: var(--primary);
    color: var(--text-light);
}

@media (min-width: 769px) {
    .mobile-controls { display: none !important; }
}

@media (max-width: 768px) {
    .controls { display: none !important; }
    .mobile-controls { display: block !important; }
}

@media (max-width: 480px) {
    .nav-buttons-grid { gap: 6px; }
    .nav-btn { padding: 12px 3px; }
}