:root {
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --primary: #0f766e;
    --primary-hover: #115e59;
    --secondary: #f59e0b;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
    --radius: 20px;
    --module-bg: #f8fafc;
    --message-bg: #f0fdf4;
    --message-text: #166534;
    --input-bg: #fafbfc;
    --submodule-bg: #f8fafc;
    --hover-bg: #eef2ff;
    --add-module-bg: #ffffff;
    --outline-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(145deg, #e0f2fe 0%, #f0fdf4 50%, #fef3c7 100%);
    transition: background 0.3s;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body::-webkit-scrollbar {
    display: none;
}

.container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 850px;
    padding: 2.5rem;
    transition: background 0.3s;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.container::-webkit-scrollbar {
    display: none;
}

.header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1.2rem;
    flex-wrap: wrap;
}

.header-icon {
    background: var(--primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.header-text {
    flex: 1;
}

.header-text h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
}

.header-text p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.5rem 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.theme-selector label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0;
}

.theme-selector select {
    padding: 0.3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
}

.section-title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.module-card {
    background: var(--module-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem 0.8rem;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
}

.module-card:hover {
    background: var(--hover-bg);
    border-color: #a5b4fc;
    transform: translateY(-2px);
}

.module-card.selected {
    background: var(--hover-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}

.module-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.module-label {
    font-weight: 600;
    color: var(--text);
}

.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.name-input {
    width: 100%;
    padding: 0.9rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 1.05rem;
    background: var(--input-bg);
    transition: 0.2s;
    color: var(--text);
}

.name-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-bg);
}

#moduloSubModule {
    margin-bottom: 1.5rem;
    transition: 0.3s;
}

.sub-module-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.sub-module-btn {
    background: var(--submodule-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 500;
    color: var(--text);
}

.sub-module-btn:hover {
    background: var(--hover-bg);
    border-color: #a5b4fc;
}

.sub-module-btn.selected {
    background: var(--hover-bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.add-module-btn {
    background: var(--add-module-bg);
    border: 2px dashed var(--border);
    color: var(--text-light);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 500;
}

.add-module-btn:hover {
    background: var(--hover-bg);
    border-color: #94a3b8;
}

.message-preview {
    background: var(--message-bg);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--message-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-preview span {
    flex: 1;
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    background: var(--input-bg);
    color: var(--text);
}

textarea:focus {
    border-color: var(--primary);
    background: var(--card-bg);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.voice-select {
    flex: 2;
    min-width: 200px;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: 14px;
    background: var(--input-bg);
    cursor: pointer;
    color: var(--text);
}

.speed-slider {
    flex: 1;
    min-width: 120px;
}

.speed-slider label {
    font-size: 0.85rem;
    color: var(--text-light);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.9rem 1.5rem;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    flex: 1;
    min-width: 120px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(15, 118, 110, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--outline-bg);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-outline:hover {
    background: var(--hover-bg);
}

.btn-display {
    background: #7c3aed;
    color: white;
}

.btn-display:hover {
    background: #6d28d9;
}

.btn-export {
    background: #059669;
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    min-width: auto;
    flex: 0;
}

.btn-export:hover {
    background: #047857;
}

.btn-export-day {
    background: #f59e0b;
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    min-width: auto;
    flex: 0;
}

.btn-export-day:hover {
    background: #d97706;
}

.sound-config {
    background: var(--module-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.sound-config label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.file-input {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.file-input input[type="file"] {
    flex: 1;
}

.status {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: 0.3s;
}

.status.active {
    opacity: 1;
}

.status.speaking {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.status.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.history-section {
    margin-top: 2rem;
    border-top: 2px solid var(--border);
    padding-top: 1.5rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-buttons {
    display: flex;
    gap: 0.5rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th {
    text-align: left;
    padding: 0.6rem;
    background: var(--module-bg);
    font-weight: 600;
    color: var(--text);
}

.history-table td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
}

.no-history {
    color: var(--text-light);
    font-style: italic;
    padding: 1rem 0;
}

.history-note {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ===== LOGIN ===== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, #e0f2fe 0%, #f0fdf4 50%, #fef3c7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.brand-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: floatIcon 2s infinite;
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--primary);
    margin: 0;
}

.brand-slogan {
    font-size: 0.95rem;
    color: var(--text-light);
    margin: 0.5rem 0 0;
}

.login-divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

.login-card h2 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.login-card p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.login-field {
    text-align: left;
    margin-bottom: 1rem;
}

.login-field label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text);
    font-weight: 600;
}

.login-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-bg);
}

.login-error {
    color: #dc2626;
    margin-top: 0.8rem;
    min-height: 1.2em;
}

/* ===== SPLASH SCREEN ===== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, #e0f2fe 0%, #f0fdf4 50%, #fef3c7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.splash-content {
    text-align: center;
}

.splash-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    animation: floatIcon 2s infinite;
}

.splash-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--primary);
    margin: 0;
}

.splash-slogan {
    font-size: 1.1rem;
    color: var(--text-light);
    margin: 0.5rem 0 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== MENSAJE DE BIENVENIDA ===== */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 14px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    animation: slideDown 0.6s ease-out;
}

.welcome-text {
    font-size: 1.2rem;
}

.welcome-name {
    font-weight: 800;
    font-size: 1.4rem;
    animation: pulseText 1.5s infinite;
}

@keyframes floatIcon {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseText {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem;
    }

    .modules {
        grid-template-columns: 1fr 1fr;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }
}