/* Cargar fuente OpenDyslexic desde carpeta local */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Italic.otf') format('opentype');
    font-weight: normal;
    font-style: italic;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-BoldItalic.otf') format('opentype');
    font-weight: bold;
    font-style: italic;
}

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

body {
    font-family: 'OpenDyslexic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    background: #ffffff;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    border: 2px solid #60a5fa;
}

.header {
    text-align: center;
    margin-bottom: 50px;
}

.header h1 {
    color: #0f172a;
    font-size: 2.5em;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header p {
    color: #64748b;
    font-size: 1.1em;
    font-weight: 400;
}

.upload-area {
    border: 2px dashed #0ea5e9;
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    margin-bottom: 40px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.upload-area:hover {
    border-color: #0284c7;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.15);
}

.upload-area.dragover {
    border-color: #0369a1;
    background: linear-gradient(135deg, #bae6fd 0%, #7dd3fc 100%);
    box-shadow: 0 15px 35px rgba(14, 165, 233, 0.25);
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.2em;
    color: #334155;
    margin-bottom: 15px;
    font-weight: 500;
}

.file-input {
    display: none;
}

.upload-btn {
    background: linear-gradient(135deg, #065fd4 0%, #0284c7 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: 12px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.upload-btn:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0369a1 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
}

.auto-detect-info {
    text-align: center;
    margin-bottom: 40px;
    padding: 24px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ecfeff 100%);
    border-radius: 16px;
    border: 1px solid #5eb9ea;
}

.auto-detect-info h3 {
    color: #0f4976;
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: 700;
}

.auto-detect-info p {
    color: #475569;
    font-size: 1em;
    line-height: 1.6;
}

.preview-section {
    display: none;
    margin-bottom: 40px;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    display: block;
}

.progress-section {
    display: none;
    margin-bottom: 40px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin: 25px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4 0%, #0284c7 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    font-size: 1.1em;
    color: #475569;
    margin-bottom: 10px;
    font-weight: 500;
}

.result-section {
    display: none;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.result-title {
    font-size: 1.8em;
    color: #0f172a;
    font-weight: 700;
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-copy {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-copy:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3);
}

.btn-download {
    background: linear-gradient(135deg, #06b6d4 0%, #0284c7 100%);
    color: white;
}

.btn-download:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0369a1 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
}

.btn-new {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: white;
}

.btn-new:hover {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 116, 139, 0.3);
}

.extracted-text {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 32px;
    min-height: 250px;
    font-family: 'OpenDyslexic', monospace;
    font-size: 1.2em;
    line-height: 2.2;
    color: #1e293b;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
}

.extracted-text:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #06b6d4 0%, #0284c7 100%);
    border-radius: 16px 16px 0 0;
}

.text-formatting-options {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.formatting-label {
    font-weight: 600;
    color: #0f172a;
    font-size: 1em;
}

.font-size-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.font-btn {
    background: linear-gradient(135deg, #06b6d4 0%, #0284c7 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

.font-btn:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0369a1 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.line-height-controls {
    display: none;
}

/* Nuevos estilos para personalización */
.customization-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 15px;
    width: 100%;
}

@media (min-width: 768px) {
    .customization-controls {
        grid-template-columns: repeat(2, 1fr);
    }
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item label {
    font-weight: 600;
    color: #0369a1;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-item label i {
    color: #0284c7;
}

.control-item select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #bae6fd;
    border-radius: 8px;
    background: white;
    font-size: 1em;
    font-family: 'OpenDyslexic', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-item select:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.control-item input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #bae6fd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.control-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0284c7;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.control-item input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0284c7;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.color-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-btn.selected {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.highlight-toggle {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.highlight-toggle:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.highlight-toggle.active {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.word-highlight {
    background: linear-gradient(120deg, #a7f3d0 0%, #fde68a 100%);
    padding: 2px 6px;
    border-radius: 6px;
    margin: 0 2px;
    transition: all 0.2s ease;
}

.word-highlight:hover {
    background: linear-gradient(120deg, #6ee7b7 0%, #fcd34d 100%);
    transform: scale(1.02);
}

.stats {
    margin-top: 30px;
    padding: 28px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 16px;
    font-size: 1em;
    color: #1e293b;
    border-left: 4px solid #0ea5e9;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.08);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.15);
}

.stat-value {
    font-size: 1.6em;
    font-weight: 700;
    color: #0284c7;
    display: block;
}

.stat-label {
    font-size: 0.9em;
    color: #64748b;
    margin-top: 6px;
    font-weight: 500;
}

.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    padding: 20px 24px;
    border-radius: 12px;
    margin: 20px 0;
    border-left: 4px solid #ef4444;
    font-size: 1em;
    line-height: 1.6;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.1);
}

.success-message {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    padding: 16px 24px;
    border-radius: 12px;
    margin: 15px 0;
    border-left: 4px solid #10b981;
    display: none;
    font-size: 1em;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.processing {
    animation: pulse 1.5s infinite;
}

/* Estilo base para el botón de volver */
.back-btn {
    position: absolute;
    top: 2rem;
    left: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

/* Hacer el botón fijo solo cuando no está en modo original */
body:not(.normal) .back-btn {
    position: fixed;
}

.back-btn:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-color: #94a3b8;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Controles de accesibilidad en la esquina derecha */
.accessibility-controls {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 1000;
}

/* Hacer los controles fijos solo cuando no está en modo original */
body:not(.normal) .accessibility-controls {
    position: fixed;
}

.control-btn {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;
    padding: 12px 20px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.3s ease !important;
    font-family: inherit !important;
    color: #1e293b !important;
    min-width: 140px !important;
    text-align: center !important;
}

.control-btn:hover {
    background: rgba(248, 250, 252, 1) !important;
    color: #1e293b !important;
    border-color: #94a3b8 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12) !important;
}

.control-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(203, 213, 225, 0.3) !important;
}

#darkModeToggle {
    min-width: 60px !important;
    padding: 12px 0 !important;
}

/* Modo oscuro */
body.dark-mode {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

body.dark-mode .container {
    background: #1e293b;
    color: #f1f5f9;
    border: 2px solid #60a5fa;
}

body.dark-mode .header h1,
body.dark-mode .header p,
body.dark-mode .result-title,
body.dark-mode .formatting-label {
    color: #f1f5f9;
}

body.dark-mode .auto-detect-info {
    background: #1e293b;
    border-color: #60a5fa;
}

body.dark-mode .auto-detect-info h3,
body.dark-mode .auto-detect-info p {
    color: #f1f5f9;
}

body.dark-mode .upload-area {
    background: #334155;
    border-color: #60a5fa;
    color: #f1f5f9;
}

body.dark-mode .upload-area .upload-text {
    color: #f1f5f9;
}

body.dark-mode .extracted-text,
body.dark-mode .text-formatting-options {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark-mode .stats {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-left-color: #60a5fa;
}

body.dark-mode .stat-item {
    background: rgba(51, 65, 85, 0.8);
}

body.dark-mode .stat-value {
    color: #60a5fa;
}

body.dark-mode .stat-label {
    color: #cbd5e1;
}

body.dark-mode .control-btn {
    background: rgba(30, 41, 59, 0.95) !important;
    color: #e2e8f0 !important;
    border-color: rgba(100, 116, 139, 0.4) !important;
}

body.dark-mode .control-btn:hover {
    background: rgba(20, 30, 40, 1) !important;
    color: #cbd5e1 !important;
    border-color: rgba(71, 85, 105, 0.5) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .back-btn {
    background: rgba(30, 41, 59, 0.95);
    color: #e2e8f0;
    border-color: rgba(100, 116, 139, 0.4);
}

body.dark-mode .back-btn:hover {
    background: rgba(20, 30, 40, 1);
    color: #cbd5e1;
    border-color: rgba(71, 85, 105, 0.5);
}

/* Filtros de daltonismo */
body.protanopia {
    filter: url('#protanopia');
}

body.tritanopia {
    filter: url('#tritanopia');
}

.svg-filters {
    position: absolute;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* Custom Select Styles */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
    user-select: none;
}

.custom-select {
    position: relative;
}

.custom-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    gap: 8px;
}

.custom-options {
    position: absolute;
    display: none;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    z-index: 2;
    margin-top: 4px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

body.dark-mode .custom-options {
    background: #334155;
    border-color: #475569;
}

.custom-select.open .custom-options {
    display: block;
}

.custom-option {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s ease;
    color: #1e293b;
}

body.dark-mode .custom-option {
    color: #e2e8f0;
}

.custom-option:hover {
    background-color: #f1f5f9;
}

body.dark-mode .custom-option:hover {
    background-color: #475569;
}

.arrow {
    position: relative;
    height: 10px;
    width: 10px;
    margin-left: 10px;
}

.arrow::before, .arrow::after {
    content: '';
    position: absolute;
    bottom: 0px;
    width: 0.15rem;
    height: 100%;
    background-color: #1e293b;
    transition: all 0.2s ease;
}

body.dark-mode .arrow::before,
body.dark-mode .arrow::after {
    background-color: #e2e8f0;
}

.arrow::before {
    left: -3px;
    transform: rotate(-45deg);
}

.arrow::after {
    left: 3px;
    transform: rotate(45deg);
}

.custom-select.open .arrow::before {
    transform: rotate(45deg);
}

.custom-select.open .arrow::after {
    transform: rotate(-45deg);
}

/* Tablets y dispositivos medianos */
@media (max-width: 1024px) {
    /* Estilos para el modo normal */
    body.normal .back-btn,
    body.protanopia .back-btn,
    body.tritanopia .back-btn {
        position: relative;
        top: auto;
        left: auto;
        padding: 10px 18px;
        font-size: 14px;
        margin-bottom: 12px;
        display: inline-flex;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    body.normal .accessibility-controls,
    body.protanopia .accessibility-controls,
    body.tritanopia .accessibility-controls {
        position: relative;
        top: auto;
        right: auto;
        display: inline-flex;
        gap: 8px;
        margin-bottom: 12px;
        float: right;
    }

    .container {
        clear: both;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* Contenedor para los botones superiores - aplica a todos los modos */
    body.normal .back-btn,
    body.protanopia .back-btn,
    body.tritanopia .back-btn {
        padding: 8px 14px;
        font-size: 13px;
        margin-bottom: 10px;
        position: relative;
        top: auto;
        left: auto;
        display: inline-flex;
    }

    body.normal .accessibility-controls,
    body.protanopia .accessibility-controls,
    body.tritanopia .accessibility-controls {
        gap: 6px;
        position: relative;
        top: auto;
        right: auto;
        display: inline-flex;
        float: right;
        margin-bottom: 10px;
    }

    .control-btn {
        min-width: auto !important;
        font-size: 12px !important;
        padding: 8px 10px !important;
    }

    #darkModeToggle {
        min-width: 40px !important;
        padding: 8px !important;
    }

    .container {
        padding: 20px 16px;
        margin: 0;
        border-radius: 16px;
    }
    
    .header h1 {
        font-size: 1.8em;
        margin-top: 0;
    }

    .header p {
        font-size: 1em;
    }
    
    .upload-area {
        padding: 30px 15px;
    }

    .upload-icon {
        font-size: 3em;
    }

    .upload-text {
        font-size: 1em;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 1em;
    }

    .result-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .result-title {
        font-size: 1.3em;
    }

    .text-formatting-options {
        padding: 20px 15px;
    }

    .formatting-label {
        font-size: 1em;
        margin-bottom: 10px;
        display: block;
        width: 100%;
    }

    .customization-controls {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .control-item {
        width: 100%;
    }

    .control-item label {
        font-size: 0.9em;
    }

    .control-item select {
        font-size: 0.95em;
        padding: 10px;
    }

    .color-options {
        gap: 8px;
        justify-content: flex-start;
    }

    .color-btn {
        width: 35px;
        height: 35px;
    }

    .extracted-text {
        padding: 20px 15px;
        font-size: 1em;
        line-height: 1.8;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-item {
        padding: 12px;
    }

    .stat-value {
        font-size: 1.3em;
    }

    .stat-label {
        font-size: 0.85em;
    }

    .preview-image {
        max-height: 250px;
    }

    .auto-detect-info {
        padding: 16px;
        margin-bottom: 20px;
    }

    .auto-detect-info h3 {
        font-size: 1.1em;
    }

    .auto-detect-info p {
        font-size: 0.95em;
    }
}