:root {
    --bg-color: #050505;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary-color: #3b82f6;
    --primary-color-hover: #2563eb;
    --accent-purple: #8b5cf6;
    --risk-high-bg: rgba(239, 68, 68, 0.25);
    --risk-high-text: #fca5a5;
    --risk-high-pip: #ef4444;
    --risk-med-bg: rgba(234, 179, 8, 0.25);
    --risk-med-text: #fde047;
    --risk-med-pip: #eab308;
    --risk-low-bg: rgba(255, 255, 255, 0);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Background Effects */
.bg-shape {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

.shadow-blue {
    top: -100px;
    left: -100px;
    background: var(--primary-color);
}

.shadow-purple {
    bottom: -100px;
    right: -100px;
    background: var(--accent-purple);
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(50px) scale(1.1);
    }
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(5, 5, 5, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
}

.logo-text {
    font-weight: 300;
    letter-spacing: -0.5px;
}

.logo-text strong {
    font-weight: 700;
    color: var(--primary-color);
}

.badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    letter-spacing: 1px;
}

/* Layout */
.container {
    max-width: 900px;
    margin: auto;
    width: 100%;
    padding: 3rem 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.mt-4 {
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

/* Typography */
.glow-text {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 1rem;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 3rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    backdrop-filter: blur(16px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* Editor */
.textarea-wrapper {
    position: relative;
    margin-bottom: 1.5rem;
}

.editor-div {
    width: 100%;
    min-height: 250px;
    max-height: 50vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.6;
    white-space: pre-wrap;
    text-align: left;
    word-break: break-word;
}

.editor-div div,
.editor-div p {
    margin: 0 0 1rem 0;
    /* Añadir margen inferior para separar párrafos */
    padding: 0;
}

.editor-div:empty:before {
    content: attr(aria-placeholder);
    color: var(--text-muted);
    font-style: italic;
    pointer-events: none;
    display: block;
}

.editor-div:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.character-count {
    position: absolute;
    bottom: 1rem;
    right: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Writing Level Slider */
.writing-level-container {
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.writing-level-container label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.slider-wrapper {
    position: relative;
    padding-bottom: 1.2rem;
}

#writingLevel {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    outline: none;
    margin-bottom: 0.8rem;
}

#writingLevel::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.2s;
}

#writingLevel::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    bottom: 0;
}

.slider-labels span {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    width: 16.66%;
    line-height: 1;
}

/* Buttons */
.actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.input-light {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.input-light:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

button {
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 1rem;
    border-radius: 12px;
    transition: all 0.2s;
    outline: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.25rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Loader Spinner */
.spinner {
    width: 60px;
    height: 60px;
    position: relative;
    margin: 40px auto;
}

.double-bounce1,
.double-bounce2 {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--primary-color);
    opacity: 0.6;
    position: absolute;
    top: 0;
    left: 0;
    animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
    animation-delay: -1.0s;
}

@keyframes sk-bounce {

    0%,
    100% {
        transform: scale(0.0);
    }

    50% {
        transform: scale(1.0);
    }
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 2rem;
    max-width: 250px;
    margin-inline: auto;
    text-align: left;
}

.step {
    font-size: 0.875rem;
    color: var(--text-muted);
    position: relative;
    padding-left: 1.5rem;
}

.step::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.4rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--glass-border);
}

.step.active {
    color: var(--primary-color);
    font-weight: 500;
}

.step.active::before {
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    line-height: 1;
    margin-top: 0.25rem;
}

.legend-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.pip-low {
    background: #cbd5e1;
}

.pip-med {
    background: var(--risk-med-pip);
}

.pip-high {
    background: var(--risk-high-pip);
}

.result-text-container {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    line-height: 1.6;
    font-size: 1.05rem;
    white-space: pre-wrap;
    /* Keeps newlines */
    overflow-wrap: break-word;
}

/* Modal UI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1rem;
    opacity: 1;
    transition: opacity 0.2s ease-out;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex !important;
    /* Keep flex, just invisible to allow transition */
}

/* Modifiers for smooth popup */
.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1) translateY(0);
}

.modal-content {
    background: var(--bg-color);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-body {
    padding: 1.5rem;
}

.modal-score-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.modal-score-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--glass-bg);
}

.analyzers-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.analyzer-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: relative;
    cursor: help;
    transition: all 0.2s;
}

.analyzer-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.analyzer-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.analyzer-score {
    font-size: 0.8rem;
    text-transform: uppercase;
}

.analyzer-reason-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10500;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    width: max-content;
    max-width: 350px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    animation: fadeInTooltip 0.2s ease forwards;
}

.analyzer-item:hover .analyzer-reason-tooltip {
    display: block;
}

@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translate(-50%, -5px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.modal-text-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-top: 0.5rem;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Utilities */
.w-100 {
    width: 100%;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* Highlight Spans */
.fragment-span {
    transition: all 0.2s;
    border-radius: 3px;
    padding: 0 2px;
    display: inline;
    /* Asegurar que se comporten como texto */
}

.fragment-span:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.risk-low {
    background: var(--risk-low-bg);
    color: var(--text-primary);
}

.risk-medium {
    background: var(--risk-med-bg);
    color: var(--risk-med-text);
}

.risk-high {
    background: var(--risk-high-bg);
    color: var(--risk-high-text);
    font-weight: 500;
}

/* Domain Badge */
.domain-badge {
    display: inline-block;
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}