/**
 * dashboard-analytics.css
 *
 * Convenção: prefixo "sda-" em todas as classes para evitar conflito com
 * WordPress admin, Redux Framework ou outros plugins.
 */

/* =============================================================================
   CONTÊINER PRINCIPAL
   ============================================================================= */

.sda-wrap {
	padding: 16px 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

/* =============================================================================
   BARRA DE FILTRO
   ============================================================================= */

.sda-filter-bar {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 24px;
	padding: 12px 16px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
	box-sizing: border-box;
	width: 100%;
}

.sda-filter-bar label {
	font-weight: 600;
	color: #1d2327;
	white-space: nowrap;
}

.sda-filter-bar select {
	padding: 5px 10px;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	font-size: 13px;
	min-width: 0;
	max-width: 100%;
	width: 220px;
	background: #fff;
	color: #1d2327;
	cursor: pointer;
	box-sizing: border-box;
}

.sda-filter-bar select:focus {
	border-color: #2271b1;
	outline: 2px solid #2271b1;
	outline-offset: 0;
}

.sda-loading-text {
	color: #50575e;
	font-size: 13px;
	font-style: italic;
}

/* =============================================================================
   GRADE DE KPIs
   ============================================================================= */

.sda-kpi-row {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 12px;
	margin-bottom: 20px;
}

@media (max-width: 1300px) {
	.sda-kpi-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 780px) {
	.sda-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.sda-kpi-card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	border-top: 3px solid #4CAF50;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
	transition: box-shadow .15s ease;
	/* Impede que conteúdo longo estoure o grid */
	min-width: 0;
	box-sizing: border-box;
}

.sda-kpi-card:hover {
	box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

.sda-kpi-label {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	color: #50575e;
	text-transform: uppercase;
	letter-spacing: 0.6px;
	font-weight: 600;
}

.sda-kpi-value {
	font-size: 24px;
	font-weight: 700;
	color: #1d2327;
	word-break: break-word;
	overflow-wrap: break-word;
	line-height: 1.2;
}

.sda-kpi-value.sda-kpi-small {
	font-size: 14px;
	font-weight: 600;
}

/* =============================================================================
   LINHAS DE GRÁFICOS
   ============================================================================= */

.sda-charts-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin-bottom: 16px;
}

@media (max-width: 960px) {
	.sda-charts-row { grid-template-columns: 1fr; }
}

/* =============================================================================
   CARD DE GRÁFICO
   ============================================================================= */

.sda-chart-card {
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 16px;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
	/* min-width: 0 é obrigatório em filhos de grid para não vazar */
	min-width: 0;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}

.sda-chart-card h3 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
	margin: 0 0 14px 0;
	padding-bottom: 10px;
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	border-bottom: 1px solid #f0f0f1;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}

.sda-chart-scroll-area {
	width: 100%;
	overflow-x: hidden;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
}

.sda-chart-scroll-area--active {
	overflow-x: auto;
}

/* Wrapper direto do canvas — Chart.js usa este elemento para calcular o tamanho.
   Em modo scroll, min-width é aplicado aqui via JS para expandir o gráfico. */
.sda-chart-inner {
	width: 100%;
}

.sda-chart-card canvas {
	max-height: 300px;
	display: block;
}

/* =============================================================================
   BOTÃO DE EXPORTAÇÃO
   ============================================================================= */

.sda-export-btn {
	flex-shrink: 0;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 600;
	color: #2271b1;
	background: transparent;
	border: 1px solid #2271b1;
	border-radius: 3px;
	cursor: pointer;
	letter-spacing: 0;
	text-transform: none;
	line-height: 1.6;
	transition: background .12s, color .12s;
}

.sda-export-btn:hover {
	background: #2271b1;
	color: #fff;
}

/* Botão de scroll horizontal — mesmo estilo do export-btn mas com estado ativo */
.sda-scroll-btn {
	flex-shrink: 0;
	padding: 2px 8px;
	font-size: 11px;
	font-weight: 600;
	color: #50575e;
	background: transparent;
	border: 1px solid #c3c4c7;
	border-radius: 3px;
	cursor: pointer;
	line-height: 1.6;
	transition: background .12s, color .12s, border-color .12s;
}

.sda-scroll-btn:hover {
	border-color: #2271b1;
	color: #2271b1;
}

/* Quando ativo, fica preenchido para indicar visualmente que o scroll está ligado */
.sda-scroll-btn--active {
	background: #2271b1;
	border-color: #2271b1;
	color: #fff;
}

/* =============================================================================
   CARD DE STATUS DO CICLO
   ============================================================================= */

.sda-cycle-info-card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 20px;
	padding: 14px 16px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-left: 4px solid #4CAF50;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
	box-sizing: border-box;
	width: 100%;
}

.sda-cycle-info-card.sda-cycle-closed {
	border-left-color: #8c8f94;
}

.sda-cycle-info-main {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.sda-status-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	white-space: nowrap;
}

.sda-status-open   { background: #d1e7dd; color: #0a3622; }
.sda-status-closed { background: #f0f0f1; color: #50575e; }

.sda-cycle-name {
	font-weight: 600;
	font-size: 15px;
	color: #1d2327;
	word-break: break-word;
}

.sda-cycle-times {
	font-size: 13px;
	color: #50575e;
}

.sda-cycle-suspended {
	width: 100%;
	margin-top: 4px;
	padding: 6px 10px;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 3px;
	font-size: 12px;
	color: #664d03;
	box-sizing: border-box;
}

.sda-cycle-edit-link {
	font-size: 13px;
	color: #2271b1;
	text-decoration: none;
	white-space: nowrap;
	flex-shrink: 0;
}

.sda-cycle-edit-link:hover { text-decoration: underline; }

/* =============================================================================
   CABEÇALHO DE SEÇÃO (título + botão lado a lado)
   ============================================================================= */

.sda-section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	padding-bottom: 10px;
	border-bottom: 1px solid #f0f0f1;
}

/* Remove a borda e margem do h3 quando está dentro do header flex */
.sda-section-header h3 {
	margin: 0;
	padding: 0;
	border: none;
}

/* =============================================================================
   SEÇÃO GENÉRICA
   ============================================================================= */

.sda-section-card {
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 16px;
	box-shadow: 0 1px 3px rgba(0,0,0,.04);
	margin-bottom: 16px;
	box-sizing: border-box;
	width: 100%;
}

.sda-section-card h3 {
	margin: 0 0 14px 0;
	padding-bottom: 10px;
	font-size: 13px;
	font-weight: 600;
	color: #1d2327;
	border-bottom: 1px solid #f0f0f1;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}

/* =============================================================================
   TABELA DE PEDIDOS
   ============================================================================= */

/*
 * Wrapper com scroll horizontal próprio: a tabela rola dentro do card,
 * sem vazar para a página.
 */
#sda-orders-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.sda-orders-table {
	margin: 0;
	border: none;
	width: 100%;
	border-collapse: collapse;
}

.sda-orders-table thead th {
	font-size: 12px;
	font-weight: 600;
	color: #50575e;
	text-transform: uppercase;
	letter-spacing: 0.4px;
	padding: 8px 10px;
	background: #f6f7f7;
	white-space: nowrap;
}

.sda-orders-table tbody td {
	font-size: 13px;
	padding: 8px 10px;
	vertical-align: middle;
}

.sda-col-right { text-align: right; }

.sda-orders-total-row td {
	background: #e8f5e9;
	border-top: 2px solid #2e7d32;
	font-size: 13px;
	padding: 8px 10px;
}

/* Esconde colunas menos importantes em telas pequenas */
@media (max-width: 640px) {
	.sda-orders-table th:nth-child(2),
	.sda-orders-table td:nth-child(2) { display: none; }
}

@media (max-width: 480px) {
	.sda-orders-table th:nth-child(3),
	.sda-orders-table td:nth-child(3) { display: none; }
}

/* =============================================================================
   ÍCONE ? — abre modal ao clicar
   ============================================================================= */

.sda-tip {
	flex-shrink: 0;
	font-size: 14px !important;
	width: 14px !important;
	height: 14px !important;
	color: #50575e;
	cursor: pointer;
	vertical-align: middle;
	transition: color .12s;
	text-decoration: none;
}

.sda-tip:hover { color: #2271b1; }

/* Dashicons dentro dos botões de ação dos gráficos */
.sda-export-btn .dashicons,
.sda-scroll-btn .dashicons {
	font-size: 14px;
	width: 14px;
	height: 14px;
	vertical-align: middle;
	line-height: 1;
}

/* =============================================================================
   AGRUPADOR DE AÇÕES NOS GRÁFICOS (? + exportar)
   ============================================================================= */

.sda-chart-actions {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
	margin-left: auto;
}

/* =============================================================================
   MODAL DE INFORMAÇÃO
   ============================================================================= */

.sda-modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.45);
	z-index: 99999;
	align-items: center;
	justify-content: center;
}

.sda-modal-overlay.sda-modal-open { display: flex; }

.sda-modal {
	background: #fff;
	border-radius: 6px;
	padding: 28px 24px 20px;
	max-width: 400px;
	width: 90%;
	position: relative;
	box-shadow: 0 8px 32px rgba(0,0,0,.2);
	box-sizing: border-box;
}

.sda-modal-close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: none;
	border: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: #50575e;
	padding: 2px 4px;
}

.sda-modal-close:hover { color: #1d2327; }

.sda-modal-title {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 700;
	color: #1d2327;
}

.sda-modal-text {
	margin: 0;
	font-size: 13px;
	color: #50575e;
	line-height: 1.6;
}

/* =============================================================================
   OCULTAR LAYOUT DO REDUX NO TAB DASHBOARD
   ============================================================================= */

body.sda-active-tab #redux-header,
body.sda-active-tab .redux-sidebar,
body.sda-active-tab #redux-sticky,
body.sda-active-tab #redux-footer-sticky,
body.sda-active-tab #redux-sticky-padder,
body.sda-active-tab #redux-sub-footer {
	display: none !important;
}

body.sda-active-tab .redux-container .redux-main {
	margin-left: 0 !important;
	border-left: none !important;
	padding-top: 0 !important;
}
