/* ============================================
   RESET & VARIÁVEIS
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Cores do Tema Moderno */
    --white: #ffffff;
    --black: #0f172a;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Cores Semânticas de Risco */
    --ai-red: #ef4444;
    --ai-orange: #f97316;
    --ai-yellow: #f59e0b;
    --ai-green: #10b981;

    /* Espaçamentos */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    --spacing-2xl: 24px;
    --spacing-3xl: 32px;

    /* Raios de Borda */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Sombras Elevadas */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
    --shadow-xl: 0 20px 35px rgba(15, 23, 42, 0.12);
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: var(--spacing-xl);
    line-height: 1.6;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    min-height: 100vh;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--gray-900);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}

.tag {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* Banner Informativo de Escopo */
.scope-banner {
    display: flex;
    gap: var(--spacing-md);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    align-items: flex-start;
}

.scope-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.scope-content strong {
    color: #1e3a8a;
    font-size: 0.88rem;
    display: block;
    margin-bottom: 2px;
}

.scope-content p {
    color: #1e40af;
    font-size: 0.82rem;
    margin: 0;
}

/* Duas Colunas Adaptáveis */
.layout {
    display: grid;
    grid-template-columns: 1fr 410px;
    gap: var(--spacing-xl);
    align-items: start;
}

/* Painéis Base */
.panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

/* Cabeçalho do Editor com Abas */
.panel-header-editor {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--gray-100);
}

.editor-tabs {
    display: flex;
    gap: var(--spacing-xs);
}

.tab-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.tab-btn:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--gray-900);
}

.tab-btn.active {
    background: var(--gray-900);
    color: var(--white);
}

.tab-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ============================================
   ÁREA DE ESCRITA & VISUALIZAÇÃO
   ============================================ */

.editor-wrapper {
    position: relative;
    width: 100%;
}

.input-panel textarea {
    width: 100%;
    min-height: 420px;
    max-height: 65vh;
    padding: var(--spacing-lg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.98rem;
    color: var(--gray-900);
    resize: vertical;
    transition: all 0.2s ease;
    background: var(--white);
    line-height: 1.75;
}

.input-panel textarea:focus {
    outline: none;
    border-color: var(--gray-900);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}

/* Modo Correção (Texto estático com os grifos e interatividade) */
.interactive-text-container {
    width: 100%;
    min-height: 420px;
    max-height: 65vh;
    padding: var(--spacing-lg);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    overflow-y: auto;
    font-size: 0.98rem;
    line-height: 1.85;
    color: var(--gray-900);
}

.highlighted-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Controles de Ação */
.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--spacing-md);
    gap: var(--spacing-lg);
}

.right-controls {
    display: flex;
    gap: var(--spacing-xs);
}

.shortcut-hint {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--gray-600);
    border: 1px dashed var(--gray-200);
}

/* ============================================
   BOTÕES
   ============================================ */

.btn {
    padding: 10px var(--spacing-lg);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--gray-900);
    color: var(--white);
    border: 1px solid var(--gray-900);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gray-800);
    border-color: var(--gray-800);
}

.btn-primary:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    border-color: var(--gray-200);
    cursor: not-allowed;
}

.btn-ghost {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-ghost:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

/* ============================================
   PANEL RESULT & SCROLL
   ============================================ */

.result-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.result-panel::-webkit-scrollbar {
    width: 6px;
}

.result-panel::-webkit-scrollbar-track {
    background: transparent;
}

.result-panel::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border-radius: 3px;
}

.result-panel::-webkit-scrollbar-thumb:hover {
    background: var(--gray-300);
}

/* Estados da Análise */
.state-empty,
.state-loading,
.state-result {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.state-empty {
    align-items: center;
    justify-content: center;
    padding: var(--spacing-3xl) var(--spacing-lg);
    text-align: center;
    color: var(--gray-400);
}

.state-empty svg {
    width: 44px;
    height: 44px;
    stroke: var(--gray-300);
    margin-bottom: var(--spacing-md);
}

.state-empty p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--gray-500);
}

.state-loading {
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--gray-950);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--spacing-md);
}

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

.hidden {
    display: none !important;
}

/* ============================================
   GAUGE (Velocímetro de risco)
   ============================================ */

.gauge-section {
    display: flex;
    justify-content: center;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--gray-100);
    margin-bottom: var(--spacing-md);
}

.gauge-wrapper {
    position: relative;
    width: 160px;
    height: 100px;
}

.gauge-svg {
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: var(--gray-100);
    stroke-width: 12;
    stroke-linecap: round;
}

.gauge-progress {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 219;
    stroke-dashoffset: 219;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gauge-content {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
}

.gauge-percentage {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--gray-900);
}

.gauge-label {
    font-size: 0.65rem;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cores Dinâmicas */
.gauge-progress.level-low { stroke: var(--ai-green); }
.gauge-progress.level-medium { stroke: var(--ai-yellow); }
.gauge-progress.level-high { stroke: var(--ai-orange); }
.gauge-progress.level-critical { stroke: var(--ai-red); }

/* Percentuais em Grid */
.percentage-labels {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.percentage-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.percentage-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.percentage-name {
    font-size: 0.72rem;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
}

/* ============================================
   VEREDITO
   ============================================ */

.verdict-box {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    text-align: center;
    border-left: 4px solid;
    margin-bottom: var(--spacing-md);
    font-size: 0.88rem;
}

.verdict-human {
    background: #ecfdf5;
    color: #047857;
    border-left-color: var(--ai-green);
}

.verdict-low {
    background: #f0f9ff;
    color: #0369a1;
    border-left-color: #0284c7;
}

.verdict-medium {
    background: #fffbeb;
    color: #b45309;
    border-left-color: var(--ai-yellow);
}

.verdict-high {
    background: #fef2f2;
    color: #b91c1c;
    border-left-color: var(--ai-red);
}

/* ============================================
   GRIFOS DE ANÁLISE COMPATIVEL COM ENEM
   ============================================ */

.highlight {
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline;
    border-bottom: 2.5px solid;
    font-weight: 500;
}

.highlight:hover {
    background-color: rgba(15, 23, 42, 0.05);
}

/* Cores Amigáveis dos Grifos */
.highlight.linguistic {
    background-color: #fef3c7;
    border-bottom-color: #d97706;
}

.highlight.structure {
    background-color: #dbeafe;
    border-bottom-color: #2563eb;
}

.highlight.argument {
    background-color: #d1fae5;
    border-bottom-color: #059669;
}

.highlight.repertoire {
    background-color: #fce7f3;
    border-bottom-color: #db2777;
}

.highlight.ai-pattern {
    background-color: #fee2e2;
    border-bottom-color: #dc2626;
}

/* Legendas Inteligentes */
.highlight-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm) var(--spacing-md);
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: help;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--gray-300);
    display: inline-block;
}

/* ============================================
   CARD FLUTUANTE (SUGESTÃO E SUBSTITUIÇÃO)
   ============================================ */

.floating-card {
    position: absolute;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: var(--spacing-md);
    width: 330px;
    z-index: 1000;
    pointer-events: auto;
    display: none;
    animation: scaleIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-card.visible {
    display: block;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-arrow {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    border-top: 1px solid var(--gray-200);
    transform: rotate(45deg);
    top: -6px;
    left: 20px;
}

.card-header {
    margin-bottom: var(--spacing-xs);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--gray-100);
}

.card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--gray-900);
}

.card-category {
    font-size: 0.65rem;
    color: var(--gray-400);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.card-text {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: var(--spacing-sm);
}

/* Área de sugestões detalhadas do Enem */
.card-suggestion {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border-left: 3.5px solid var(--ai-green);
    margin-bottom: var(--spacing-sm);
}

.card-suggestion strong {
    display: block;
    color: var(--gray-800);
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.card-suggestion p {
    color: var(--gray-600);
    font-size: 0.75rem;
    margin: 0;
    line-height: 1.4;
}

/* Substituição Rápida de Palavras */
.alternatives-box strong {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-700);
}

.alternatives-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.alternative-btn {
    background: var(--white);
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    padding: 5px 9px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.1s ease;
}

.alternative-btn:hover {
    background: var(--gray-900);
    color: var(--white);
    border-color: var(--gray-900);
}

/* Animação rápida de transição para sucesso */
.replaced-flash {
    animation: flashGreen 1.2s ease-out;
}

@keyframes flashGreen {
    0% {
        background-color: rgba(16, 185, 129, 0.25);
        border-color: var(--ai-green);
    }
    100% {
        background-color: transparent;
        border-color: transparent;
    }
}

/* ============================================
   SEÇÕES DA ANÁLISE DETALHADA
   ============================================ */

.analysis-section {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-100);
}

.analysis-section h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* Itens de Análise */
.signals-list, .improvements-list, .phrases-list, .characteristics-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.signal-item {
    padding: var(--spacing-md);
    background: var(--white);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--ai-red);
    font-size: 0.8rem;
}

.improvement-item {
    padding: var(--spacing-md);
    background: var(--white);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--ai-green);
    font-size: 0.8rem;
}

.signal-label, .improvement-label {
    font-weight: 600;
    color: var(--gray-900);
    display: block;
    margin-bottom: 2px;
}

.signal-detail, .improvement-detail {
    color: var(--gray-500);
    font-size: 0.78rem;
}

.phrase-item {
    padding: var(--spacing-md);
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--gray-700);
    font-style: italic;
}

.characteristic-item {
    padding: var(--spacing-md);
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    font-size: 0.8rem;
}

.characteristic-trait {
    font-weight: 600;
    color: var(--gray-900);
    display: block;
    margin-bottom: 4px;
}

.characteristic-evidence {
    color: var(--gray-500);
    font-size: 0.78rem;
}

/* Footer & Responsividade */
.result-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--gray-100);
}

.footer {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.78rem;
    padding: var(--spacing-lg);
    margin-top: auto;
}

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .result-panel {
        max-height: none;
    }
}