:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    
    --chart-temp: #ef4444; /* Vermelho para temperatura */
    --chart-ur: #3b82f6; /* Azul para umidade */
    
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.header {
    margin-bottom: 2rem;
    text-align: center;
}

.header h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #818cf8, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.version-badge {
    -webkit-text-fill-color: #38bdf8; /* Brighter blue for contrast */
    background: rgba(56, 189, 248, 0.15); /* Tinted background */
    font-size: 0.875rem;
    font-weight: 600; /* Bolder text */
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(56, 189, 248, 0.3); /* Tinted border */
}

.header p {
    color: var(--text-muted);
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
    min-width: 250px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hidden-input {
    display: none;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.file-label:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.file-name {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.limits-config {
    flex: 2;
    min-width: 350px;
    border-left: 1px solid var(--border-color);
    padding-left: 2rem;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.section-header h3 {
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 600;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: help;
    transition: var(--transition);
}

.tooltip-icon:hover {
    color: var(--primary);
}

.settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.settings-group {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    padding: 1rem;
    flex: 1;
    min-width: 200px;
}

.settings-group.other-group {
    margin-bottom: 0;
}

.settings-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.inputs-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.input-badge {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: var(--transition);
}

.input-badge:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.input-badge label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    font-weight: 500;
}

.input-badge input,
.input-badge select {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    width: 70px;
}

.input-badge select {
    width: auto;
    padding-right: 0.5rem;
}

.input-badge select option {
    background: var(--bg-color);
    color: var(--text-main);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Linha com os dois botões "Baixar Todos" (Imagem | PDF) lado a lado */
.download-all-row {
    display: flex;
    gap: 0.75rem;
}

.download-all-row .btn {
    flex: 1;
}

/* Aviso de configuração desatualizada: aparece quando algum campo diverge
   do que gerou os gráficos exibidos, pedindo para reprocessar. */
.reprocess-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.35;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
}

.reprocess-hint[hidden] {
    display: none;
}

.reprocess-hint svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.reprocess-hint strong {
    color: #fcd34d;
    font-weight: 600;
}

/* Destaque pulsante no botão enquanto há configuração pendente de reprocessar */
.btn.primary.needs-reprocess:not(:disabled) {
    animation: pulse-attention 1.6s ease-in-out infinite;
}

@keyframes pulse-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background-color: var(--primary);
    color: white;
}

.btn.primary:not(:disabled):hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn.secondary {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn.secondary:not(:disabled):hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.btn.icon-btn {
    padding: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.btn.icon-btn:hover {
    color: var(--text-main);
    border-color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.chart-card .btn.icon-btn {
    color: #64748b;
    border-color: #cbd5e1;
}

.chart-card .btn.icon-btn:hover {
    color: #0f172a;
    border-color: #94a3b8;
    background-color: #f1f5f9;
}

.charts-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    color: var(--text-muted);
    background: rgba(30, 41, 59, 0.3);
    border: 1px dashed var(--border-color);
    border-radius: 1rem;
    gap: 1rem;
}

.chart-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #ffffff;
    border-color: #e2e8f0;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    border-right: 1px solid #e2e8f0;
    padding-right: 1.25rem;
    margin-right: 0.75rem;
}

.device-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0f172a;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    transition: var(--transition);
    flex: 1;
    min-width: 0;
}

.device-title[contenteditable="true"]:hover {
    background: #ffffff;
    border-color: #94a3b8;
    cursor: text;
}

.device-title[contenteditable="true"]:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    outline: none;
}

.edit-icon {
    color: var(--text-muted);
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px;
    width: 32px;
    height: 32px;
    box-sizing: border-box;
    transition: var(--transition);
    flex-shrink: 0;
}

.title-wrapper:hover .edit-icon {
    color: var(--primary);
    border-color: #c7d2fe;
    background-color: #e0e7ff;
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

.chart-body {
    position: relative;
    /* 600px de gráfico + 72px reservados para a legenda de Limites Operacionais
       (ver OPERATIONAL_LIMITS_LEGEND_HEIGHT em app.js) */
    height: 672px;
    width: 100%;
}

/* Responsividade */
@media (max-width: 1024px) {
    .limits-config {
        border: none;
        padding: 0;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        padding-top: 1rem;
        padding-bottom: 1rem;
        flex-basis: 100%;
        order: 3;
    }
}

@media (max-width: 768px) {
    .actions {
        flex-basis: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .actions .btn {
        flex: 1;
        min-width: 150px;
    }
}

/* Print e Exportação (PDF) styles */
.pdf-export-mode .app-container {
    padding: 0;
    max-width: none;
}

.pdf-export-mode .chart-card {
    page-break-inside: avoid;
    page-break-after: always;
    border: none;
    box-shadow: none;
    border-radius: 0;
    margin-bottom: 0;
    background: white; /* Fundo branco pra impressão */
    color: black; /* Texto preto pra impressão */
}

.pdf-export-mode .device-title {
    color: black;
}

.pdf-export-mode .chart-header {
    border-bottom-color: #e2e8f0;
}

.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(1rem);
    transition: var(--transition);
    z-index: 100;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
