/* ==========================================================================
   ELOCUENCIA AI - ESTILOS PRINCIPALES (DISEÑO SAAS MÓVIL Y DESKTOP PWA)
   ========================================================================== */

:root {
    --bg-main: #0b0f19;
    --bg-card: #131a2b;
    --border-color: #222f4d;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --neon-green: #10b981;
    --neon-blue: #3b82f6;
    --neon-purple: #8b5cf6;
    --neon-red: #f43f5e;
    --neon-yellow: #f59e0b;
    
    --font-family: 'Space Grotesk', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Reset y Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px;
    display: flex;
    justify-content: center;
}

/* Soporte para Notch de iOS y modo Standalone de PWA */
@media (display-mode: standalone) {
    body {
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        padding-left: calc(16px + env(safe-area-inset-left));
        padding-right: calc(16px + env(safe-area-inset-right));
    }
}

/* Contenedor Principal */
.app-container {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Tarjetas */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-premium);
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 2.2rem;
    color: var(--neon-blue);
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.logo-area p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.settings-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

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

/* ==========================================================================
   PANEL DE CONFIGURACIÓN
   ========================================================================== */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
    max-height: 500px;
    opacity: 1;
}

.settings-panel.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
    border: none;
    overflow: hidden;
    margin: -10px 0;
}

.settings-panel h3 {
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 768px) {
    .settings-grid {
        grid-template-columns: 1.2fr 0.9fr 0.9fr;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input,
.input-group select {
    background-color: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    padding: 10px;
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}

.input-group select option {
    background-color: var(--bg-card);
    color: #fff;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--neon-blue);
}

.custom-model-input {
    margin-top: 8px;
}

.password-wrapper {
    display: flex;
    position: relative;
}

.password-wrapper input {
    width: 100%;
    padding-right: 44px;
}

.password-wrapper button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.password-wrapper button:hover {
    color: #fff;
}

.help-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.action-btn-primary {
    background-color: var(--neon-blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn-primary:hover {
    background-color: #2563eb;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* ==========================================================================
   AREA DE GRABACIÓN
   ========================================================================== */
.main-record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
}

.wave-visualizer-container {
    width: 100%;
    height: 140px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

#wave-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.record-timer {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 0.05em;
    color: #fff;
}

.control-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.record-btn {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background-color: var(--neon-red);
    border: 5px solid rgba(244, 63, 94, 0.2);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(244, 63, 94, 0.25);
    transition: var(--transition);
}

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

/* Pulsación cuando graba */
.record-btn.recording {
    background-color: #000;
    border-color: rgba(255,255,255,0.15);
    color: var(--neon-red);
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.5); }
    70% { box-shadow: 0 0 0 15px rgba(244, 63, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

.record-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 500;
}

/* ==========================================================================
   LOADING OVERLAY
   ========================================================================== */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 30px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--neon-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    animation: blinkText 1.5s infinite;
}

@keyframes blinkText {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   DASHBOARD DE RESULTADOS
   ========================================================================== */
.results-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1.1fr 0.9fr;
    }
}

.dashboard-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Transcripción texto container */
.transcription-container {
    background-color: rgba(0,0,0,0.25);
    border-radius: 12px;
    padding: 16px;
    height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.transcription-container p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.transcription-legend {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.muletilla { background-color: var(--neon-yellow); }
.legend-dot.error { background-color: var(--neon-red); }

/* Resaltados */
.hl-muletilla {
    background-color: rgba(245, 158, 11, 0.25);
    border-bottom: 2px solid var(--neon-yellow);
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

.hl-error {
    background-color: rgba(244, 63, 94, 0.25);
    border-bottom: 2px solid var(--neon-red);
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* Puntuación radial y radial rings */
.scores-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0;
}

.score-circle-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring__circle {
    stroke-dasharray: 213.62; /* 2 * PI * r (r=34) */
    stroke-dashoffset: 213.62;
    transition: stroke-dashoffset 0.6s ease-in-out;
}

.score-value {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translate(-50%, -70%);
    font-size: 1.25rem;
    font-weight: 700;
}

.score-label {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.quick-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.stat-value small {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Badges de Muletillas */
.muletillas-list-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.muletillas-list-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.muletillas-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.muletilla-tag {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--neon-yellow);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.empty-msg {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ==========================================================================
   TABLA DE SUGERENCIAS Y RECOMENDACIONES
   ========================================================================== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.recommendations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
    background-color: rgba(0,0,0,0.15);
}

.recommendations-table th, 
.recommendations-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.recommendations-table th {
    background-color: rgba(255, 255, 255, 0.02);
    font-weight: 700;
    color: var(--text-secondary);
}

.recommendations-table tbody tr:last-child td {
    border-bottom: none;
}

.font-red { color: var(--neon-red); }
.font-green { color: var(--neon-green); }

.badge-type {
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-type.error {
    background-color: rgba(244, 63, 94, 0.15);
    color: var(--neon-red);
}

.badge-type.muletilla {
    background-color: rgba(245, 158, 11, 0.15);
    color: var(--neon-yellow);
}

.empty-table {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px !important;
}

/* Feedback general */
.analysis-feedback-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #cbd5e0;
}

/* ==========================================================================
   MÓVIL MEDIA QUERY
   ========================================================================== */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

    .logo-area p {
        display: none; /* Ocultar subtítulo para ahorrar espacio vertical */
    }

    .settings-toggle-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .card {
        padding: 16px;
    }

    .wave-visualizer-container {
        height: 100px;
    }

    .record-btn {
        width: 66px;
        height: 66px;
        font-size: 1.5rem;
    }

    .scores-container {
        flex-wrap: wrap;
        gap: 16px;
    }

    .recommendations-table th, 
    .recommendations-table td {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}
