/* =========================================================
   Demonstrativo de Cálculo de Preço — Popup Styles
   ========================================================= */

.demonstrativo-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #333;
    max-width: 460px;
    min-width: 460px;
    padding: 0;
    background: #fff;
}

.demonstrativo-container h3.demonstrativo-titulo {
    background: linear-gradient(135deg, #148C87, #1aada7);
    color: #fff;
    margin: 0;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 4px 4px 0 0;
    letter-spacing: 0.3px;
}

.demonstrativo-container h3.demonstrativo-titulo span.demonstrativo-peca-nome {
    font-weight: 500;
    font-size: 13px;
    display: block;
    margin-top: 3px;
    opacity: 0.95;
}

.demonstrativo-container h3.demonstrativo-titulo span.demonstrativo-meio-venda {
    font-weight: 400;
    font-size: 13px;
    display: block;
    margin-top: 2px;
    opacity: 0.85;
}

/* Section headers */
.demonstrativo-section-header {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 5px 14px;
    margin: 0;
    color: #555;
}

.demonstrativo-section-header.custo-base {
    background: #dbeafe;
    color: #1e40af;
}

.demonstrativo-section-header.custos-variaveis {
    background: #fed7aa;
    color: #9a3412;
}

.demonstrativo-section-header.lucro {
    background: #bbf7d0;
    color: #166534;
}

.demonstrativo-section-header.preco-final {
    background: linear-gradient(135deg, #115e59, #148C87);
    color: #fff;
    font-size: 14px;
    padding: 6px 14px;
}

/* Line items */
.demonstrativo-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 14px;
    border-bottom: 1px solid #f0f0f0;
}

.demonstrativo-line:last-child {
    border-bottom: none;
}

.demonstrativo-line .demo-label {
    flex: 1;
    color: #555;
}

.demonstrativo-line .demo-label .demo-pct {
    color: #888;
    font-size: 12px;
    margin-left: 3px;
}

.demonstrativo-line .demo-label .demo-formula {
    display: block;
    color: #999;
    font-size: 12px;
    font-style: italic;
    margin-top: 1px;
}

.demonstrativo-line .demo-value {
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
    min-width: 75px;
}

/* Subtotal lines */
.demonstrativo-line.subtotal {
    border-top: 1px solid #ccc;
    border-bottom: 2px solid #ddd;
    padding: 5px 14px;
    background: #fafafa;
}

.demonstrativo-line.subtotal .demo-label {
    font-weight: 700;
    color: #333;
}

.demonstrativo-line.subtotal .demo-value {
    font-weight: 700;
    color: #333;
}

/* Preço final highlight */
.demonstrativo-line.preco-final-value {
    padding: 8px 14px;
    background: #f0fdfa;
}

.demonstrativo-line.preco-final-value .demo-label {
    font-weight: 700;
    font-size: 16px;
    color: #115e59;
}

.demonstrativo-line.preco-final-value .demo-value {
    font-weight: 700;
    font-size: 18px;
    color: #148C87;
}

/* Meu Preço comparison */
.demonstrativo-line.meu-preco-line {
    background: #fffbeb;
}

.demonstrativo-line.meu-preco-line .demo-label {
    color: #92400e;
}

.demonstrativo-line.meu-preco-line .demo-value {
    color: #b45309;
    font-weight: 600;
}

.demonstrativo-line.excedente-line .demo-label {
    color: #166534;
}
.demonstrativo-line.excedente-line .demo-value {
    color: #166534;
    font-weight: 600;
}

.demonstrativo-line.deficit-line .demo-label {
    color: #991b1b;
}
.demonstrativo-line.deficit-line .demo-value {
    color: #991b1b;
    font-weight: 600;
}

/* Faixa callout */
.demonstrativo-callout {
    margin: 6px 14px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
}

.demonstrativo-callout.faixa {
    background: #fef9c3;
    border: 1px solid #facc15;
    color: #854d0e;
}

.demonstrativo-callout.faixa .demo-callout-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.demonstrativo-callout.faixa .demo-faixa-highlight {
    font-weight: 600;
    color: #92400e;
}

.demonstrativo-callout.convergencia {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0c4a6e;
    font-size: 12px;
}

.demonstrativo-callout.fonte {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    color: #5b21b6;
    font-size: 12px;
}

/* Footer */
.demonstrativo-footer {
    text-align: center;
    padding: 8px 14px;
    border-top: 1px solid #eee;
}

.demonstrativo-footer button.demonstrativo-btn-fechar {
    background: #148C87;
    color: #fff;
    border: none;
    padding: 6px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.demonstrativo-footer button.demonstrativo-btn-fechar:hover {
    background: #0e6b67;
}

/* Receipt icon button */
.btn-demonstrativo {
    cursor: pointer;
    color: #148C87;
    font-size: 13px;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
}

.btn-demonstrativo:hover {
    opacity: 1;
    color: #0e6b67;
}

/* Icon in the graph area */
.btn-demonstrativo-graph {
    cursor: pointer;
    color: #148C87;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
    position: relative;
    top: -1px;
}

.btn-demonstrativo-graph:hover {
    opacity: 1;
    color: #0e6b67;
}

/* =========================================================
   Collapsible detail sub-sections
   ========================================================= */

/* Expandable line — shows a toggle arrow */
.demonstrativo-line.demo-expandable {
    cursor: pointer;
    user-select: none;
}

.demonstrativo-line.demo-expandable:hover {
    background: #f8f8f8;
}

.demonstrativo-line.demo-expandable .demo-toggle {
    display: inline-block;
    font-size: 11px;
    margin-right: 5px;
    transition: transform 0.2s;
    color: #999;
}

.demonstrativo-line.demo-expandable.expanded .demo-toggle {
    transform: rotate(90deg);
}

/* Hidden detail panel */
.demo-detail-panel {
    display: none;
    padding: 4px 14px 6px 28px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #666;
}

.demo-detail-panel.open {
    display: block;
}

/* Detail lines inside panel */
.demo-detail-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 2px 0;
    border-bottom: 1px dashed #e8e8e8;
}

.demo-detail-line:last-child {
    border-bottom: none;
}

.demo-detail-line .demo-detail-label {
    flex: 1;
    color: #777;
    font-size: 13px;
}

.demo-detail-line .demo-detail-value {
    text-align: right;
    white-space: nowrap;
    min-width: 65px;
    font-size: 13px;
    color: #555;
}

.demo-detail-line .demo-detail-formula {
    font-style: italic;
    color: #aaa;
    font-size: 12px;
    margin-left: 4px;
}

/* Faixa callout inside detail panel */
.demo-detail-panel .demonstrativo-callout.faixa {
    margin: 6px 0;
}

/* =========================================================
   Forbidden zone alerts
   ========================================================= */

/* Warning icon in table cells */
.zona-proibida-icon {
    color: #d97706;
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
    display: inline-block;
    vertical-align: middle;
    animation: zona-pulse 2s ease-in-out infinite;
}

/* Meu Preço icon — vertically centered with the input */
.icon-zona-meu-preco {
    margin-left: 0;
    margin-right: -4px;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

@keyframes zona-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Contextual alert bar (reuses Fix 3 pattern) */
.alerta-zona-proibida {
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    padding: 6px 10px;
    margin-top: 5px;
    line-height: 1.5;
}

.alerta-zona-proibida .zona-sugestao {
    display: block;
    margin-top: 3px;
    font-weight: 600;
    color: #78350f;
}

/* Callout inside Demonstrativo popup */
.demonstrativo-callout.zona-proibida {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}

.demonstrativo-callout.zona-proibida .demo-callout-title {
    font-weight: 700;
    margin-bottom: 2px;
}
