/* ============================================
   CORRECTOR M3 - Design System
   Minimalista, elegante, funcional
   ============================================ */

:root {
    /* Paleta de colores - Tonos cálidos y profesionales */
    --bg-primary: #faf9f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f4f2;
    
    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #9a9a9a;
    
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: rgba(37, 99, 235, 0.08);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.12);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    
    --border: #e5e5e5;
    --border-focus: #2563eb;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    
    /* Tipografía */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Space Mono', monospace;
    
    /* Espaciado */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Bordes */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f0f0f;
        --bg-secondary: #1a1a1a;
        --bg-tertiary: #242424;
        
        --text-primary: #f5f5f5;
        --text-secondary: #a0a0a0;
        --text-muted: #666666;
        
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-light: rgba(59, 130, 246, 0.15);
        
        --success-light: rgba(16, 185, 129, 0.2);
        --error-light: rgba(239, 68, 68, 0.2);
        
        --border: #2a2a2a;
        --border-focus: #3b82f6;
        
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    margin-bottom: var(--space-xl);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand {
    color: var(--accent);
    margin-left: 2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}

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

.status-indicator.loading .status-dot {
    background: var(--warning);
    animation: blink 0.6s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.status-indicator.error .status-dot {
    background: var(--error);
    animation: none;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.main {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--space-lg);
    flex: 1;
    align-items: start;
}

/* Paneles de texto */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 420px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.panel:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-light);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.panel-footer {
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.char-count {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Textarea de entrada */
.text-area {
    flex: 1;
    width: 100%;
    padding: var(--space-lg);
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    resize: none;
    outline: none;
}

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

/* Área de salida */
.output-area {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.7;
}

.placeholder-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: var(--space-sm);
}

.placeholder-icon {
    font-size: 32px;
    opacity: 0.5;
}

/* Diferencias marcadas */
.diff-added {
    background: var(--success-light);
    color: var(--success);
    padding: 1px 4px;
    border-radius: 3px;
    text-decoration: none;
}

.diff-removed {
    background: var(--error-light);
    color: var(--error);
    padding: 1px 4px;
    border-radius: 3px;
    text-decoration: line-through;
    opacity: 0.7;
}

/* Botones de acción en paneles */
.btn-clear,
.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-clear:hover,
.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-icon[data-active="true"] {
    background: var(--accent-light);
    color: var(--accent);
}

.output-actions {
    display: flex;
    gap: var(--space-xs);
}

/* ============================================
   BOTÓN DE CORRECCIÓN
   ============================================ */

.action-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
}

.btn-correct {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md), 0 0 0 0 var(--accent-light);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn-correct:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg), 0 0 0 8px var(--accent-light);
}

.btn-correct:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-correct:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-text {
    position: absolute;
    white-space: nowrap;
    font-size: 0;
}

.btn-text::before {
    content: '→';
    font-size: 22px;
}

.btn-correct.loading .btn-text {
    display: none;
}

.btn-loader {
    display: none;
    gap: 4px;
}

.btn-correct.loading .btn-loader {
    display: flex;
}

.loader-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: loaderBounce 1s infinite;
}

.loader-dot:nth-child(2) { animation-delay: 0.15s; }
.loader-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes loaderBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.shortcut-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ============================================
   RESUMEN DE CAMBIOS
   ============================================ */

.changes-summary {
    margin-top: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-slow);
}

.changes-summary.visible {
    opacity: 1;
    transform: translateY(0);
}

.summary-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.summary-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.summary-content {
    padding: var(--space-lg);
    font-size: 14px;
    line-height: 1.6;
}

.summary-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-md);
}

.summary-stats {
    display: flex;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.stat-number {
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.stat-number.additions { color: var(--success); }
.stat-number.deletions { color: var(--error); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.summary-text {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    margin-top: auto;
    padding-top: var(--space-xl);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-brand {
    color: var(--accent);
    font-weight: 500;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: var(--space-md) var(--space-lg);
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-slow);
    z-index: 1000;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--error);
    color: white;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .action-container {
        padding: var(--space-md) 0;
    }
    
    .btn-correct {
        width: 100%;
        height: 48px;
        border-radius: var(--radius-md);
    }
    
    .btn-text {
        font-size: 15px;
    }
    
    .btn-text::before {
        content: 'Corregir texto';
    }
    
    .panel {
        height: 280px;
    }
    
    .summary-stats {
        flex-direction: column;
        gap: var(--space-md);
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--space-md);
    }
    
    .header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }
    
    .panel {
        height: 220px;
    }
}

/* ============================================
   SCROLLBAR PERSONALIZADO
   ============================================ */

.output-area::-webkit-scrollbar,
.text-area::-webkit-scrollbar {
    width: 6px;
}

.output-area::-webkit-scrollbar-track,
.text-area::-webkit-scrollbar-track {
    background: transparent;
}

.output-area::-webkit-scrollbar-thumb,
.text-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.output-area::-webkit-scrollbar-thumb:hover,
.text-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   HEADER MEJORADO
   ============================================ */

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.tone-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.tone-select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tone-select:hover {
    border-color: var(--accent);
}

.tone-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Contador de palabras */
.panel-footer {
    display: flex;
    gap: var(--space-lg);
}

.word-count {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ============================================
   PANEL DE MARKETING
   ============================================ */

.marketing-panel {
    margin-top: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-slow);
}

.marketing-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

.marketing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, var(--accent-light), transparent);
    border-bottom: 1px solid var(--border);
}

.marketing-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-enhance {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-enhance:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-enhance:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.enhance-icon {
    font-size: 14px;
}

.marketing-content {
    padding: var(--space-lg);
}

/* Métricas */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.metric-card .metric-icon {
    font-size: 20px;
}

.metric-info {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.metric-value {
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

.metric-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.metric-fill.persuasion {
    background: var(--accent);
}

.metric-fill.seo {
    background: var(--warning);
}

/* Sugerencias */
.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.suggestion-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.suggestion-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.suggestion-icon {
    font-size: 16px;
}

.suggestion-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.suggestion-content {
    padding: var(--space-md);
    font-size: 13px;
    line-height: 1.6;
    min-height: 120px;
    max-height: 180px;
    overflow-y: auto;
}

.suggestion-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-xl) var(--space-md);
}

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-bullet {
    color: var(--accent);
    font-weight: bold;
}

.suggestion-text {
    color: var(--text-secondary);
}

.suggestion-example {
    display: block;
    margin-top: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
}

/* Keywords */
.keywords-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.keywords-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.keywords-icon {
    font-size: 16px;
}

.keywords-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.keywords-placeholder {
    color: var(--text-muted);
    font-size: 13px;
}

.keyword-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    font-size: 12px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.keyword-tag:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.keyword-count {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font-weight: 600;
}

/* ============================================
   ANIMACIONES DE ENTRADA
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel {
    animation: fadeInUp 0.5s ease backwards;
}

.panel-input { animation-delay: 0.1s; }
.action-container { animation: fadeInUp 0.5s ease 0.2s backwards; }
.panel-output { animation-delay: 0.3s; }

/* ============================================
   RESPONSIVE MARKETING PANEL
   ============================================ */

@media (max-width: 900px) {
    .header-right {
        flex-direction: column;
        align-items: flex-end;
        gap: var(--space-sm);
    }
    
    .metrics-row {
        grid-template-columns: 1fr;
    }
    
    .suggestions-grid {
        grid-template-columns: 1fr;
    }
    
    .marketing-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
    }
    
    .btn-enhance {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tone-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
    
    .tone-select {
        width: 100%;
    }
}
