/* ============================================================
   Design System Corporativo - FlyerScout Analytics (GitHub Pages)
   ============================================================ */

:root {
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-subtle: #F1F5F9;
    
    --border-color: #E2E8F0;
    --border-subtle: #EDF2F7;
    --border-focus: #2563EB;
    
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;
    
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    
    --success: #16A34A;
    --success-hover: #15803D;
    --success-light: #F0FDF4;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius: 8px;
    --radius-sm: 5px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.light-theme {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-layout {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
}

/* NAVBAR */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

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

.brand-badge {
    width: 10px;
    height: 36px;
    background: linear-gradient(180deg, #2563EB 0%, #16A34A 100%);
    border-radius: 3px;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-subtle);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* BOTÕES */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-success {
    background-color: var(--success);
    color: #FFFFFF;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-primary {
    background-color: var(--primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* MÉTRICAS */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.metric-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-success { color: var(--success) !important; }

/* PAINEL DE DADOS E ABAS */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.tabs-nav {
    display: flex;
    gap: 6px;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.tab-button:hover {
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.tab-button.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    min-width: 220px;
}

.form-control {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: inherit;
    background: #FFFFFF;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.select-sm {
    max-width: 190px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* TABELA */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.table th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.table tbody tr:hover {
    background-color: #F8FAFC;
}

.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

.price-text {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--success);
}

.category-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
}

/* ============================================================
   ESTILOS DE COMPARATIVO DE PRODUTO ENTRE MERCADOS
   ============================================================ */

.comparison-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px;
}

.comparison-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.comparison-card:hover {
    border-color: #CBD5E1;
    box-shadow: var(--shadow-md);
}

.compare-card-header {
    padding: 14px 18px;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.compare-prod-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.compare-prod-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.compare-highlights {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.saving-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #DCFCE7;
    color: #15803D;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: 20px;
    border: 1px solid #BBF7D0;
}

.cheapest-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #EFF6FF;
    color: #1D4ED8;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid #DBEAFE;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.compare-table th {
    background: var(--bg-subtle);
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.compare-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.compare-row-best {
    background-color: #F0FDF4 !important;
}

.status-badge-best {
    display: inline-block;
    padding: 2px 8px;
    background: #16A34A;
    color: #FFFFFF;
    font-size: 10.5px;
    font-weight: 700;
    border-radius: 10px;
}

.status-badge-diff {
    font-size: 11px;
    font-weight: 600;
    color: #DC2626;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-dialog {
    background: #FFFFFF;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 650px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-image-body {
    padding: 16px;
    text-align: center;
    background: #0B0F17;
    max-height: 75vh;
    overflow: auto;
}

.modal-image-body img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================
   HISTÓRICO DE PREÇOS E GRÁFICOS (DOCS)
   ============================================================ */

.history-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.history-toolbar-left {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex: 1;
    flex-wrap: wrap;
}

.history-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.history-select-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 170px;
}

.history-select-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================================
   HISTÓRICO DE PREÇOS E GRÁFICOS (ESTILO MODERNO E RESPONSIVO)
   ============================================================ */

.history-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-surface, #FFFFFF);
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius, 12px);
    margin: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    flex-wrap: wrap;
}

.history-toolbar-left {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex: 1;
    flex-wrap: wrap;
}

.history-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.history-select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.history-select-group label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-search-group {
    flex: 1;
    min-width: 200px;
}

.history-product-group {
    flex: 1.8;
    min-width: 280px;
}

.select-highlight {
    border-color: #3B82F6 !important;
    background-color: #F8FAFC !important;
    font-weight: 600;
    color: #0F172A;
    box-shadow: 0 1px 2px rgba(59, 130, 246, 0.08);
}

.select-highlight:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    border-color: #2563EB !important;
}

/* Banner de Detalhes do Produto */
.history-product-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%);
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius, 12px);
    margin: 0 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

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

.product-badge-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #EFF6FF;
    border: 1px solid #DBEAFE;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.product-main-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.product-main-title h2 {
    font-size: 18px;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
}

.product-sub-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

/* GRADE DE CARDS KPIS (4 COLUNAS RESPONSIVAS) */
.stats-grid, .history-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    margin: 0 16px 20px 16px !important;
}

@media (max-width: 1024px) {
    .stats-grid, .history-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {
    .stats-grid, .history-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

.stat-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius, 12px);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
    border-color: #CBD5E1;
}

.stat-card:nth-child(1) {
    border-left: 4px solid #16A34A;
}

.stat-card:nth-child(2) {
    border-left: 4px solid #DC2626;
}

.stat-card:nth-child(3) {
    border-left: 4px solid #2563EB;
}

.stat-card:nth-child(4), .stat-card-highlight {
    border-left: 4px solid #D97706;
    background: linear-gradient(135deg, #FFFBEB 0%, #FFFFFF 100%);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: #0F172A;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.stat-subdetail {
    font-size: 11.5px;
    color: #64748B;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-sm, 6px);
}

.trend-badge-down {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.trend-badge-up {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.trend-badge-neutral {
    background: #F1F5F9;
    color: #475569;
    border: 1px solid #E2E8F0;
}

/* Container do Gráfico */
.chart-wrapper-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius, 12px);
    padding: 22px 24px;
    margin: 0 16px 20px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
}

.chart-subtitle {
    font-size: 12px;
    color: #64748B;
}

.chart-legend-custom {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.legend-item-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-sm, 6px);
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
}

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

.chart-canvas-wrapper {
    position: relative;
    height: 380px;
    width: 100%;
}

.chart-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface, #FFFFFF);
    text-align: center;
    gap: 8px;
}

.chart-empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    color: #0F172A;
}

.chart-empty-state p {
    font-size: 13px;
    color: #64748B;
}

/* Tabela Histórica */
.history-table-section {
    background: #FFFFFF;
    border: 1px solid var(--border-color, #E2E8F0);
    border-radius: var(--radius, 12px);
    padding: 20px 22px;
    margin: 0 16px 20px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.history-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.history-table-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #0F172A;
    margin: 0;
}

.diff-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm, 6px);
}

.diff-tag-negative {
    background: #DCFCE7;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.diff-tag-positive {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.diff-tag-neutral {
    background: #F1F5F9;
    color: #475569;
    border: 1px solid #E2E8F0;
}

.cursor-pointer {
    cursor: pointer;
}

.cursor-pointer:hover {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .navbar { flex-direction: column; align-items: flex-start; gap: 12px; }
    .panel-header { flex-direction: column; align-items: stretch; }
    .tabs-nav { overflow-x: auto; }
    .tab-actions { flex-direction: column; align-items: stretch; }
    .select-sm { max-width: 100%; }
    .history-toolbar { flex-direction: column; align-items: stretch; margin: 12px; padding: 12px; }
    .history-toolbar-left, .history-toolbar-right { flex-direction: column; width: 100%; }
    .history-select-group { width: 100%; }
    .history-product-banner, .chart-wrapper-card, .history-table-section { margin: 0 12px 14px 12px; padding: 14px; }
}
