/**
 * EHERO Woo Gesio Invoices — estilos del portal Mi Cuenta.
 * Marca EHERO: #017cba (primario) / #00b2e2 (acento).
 * Se encola en todo Mi cuenta. Los colores salen de las variables --ehgi-*,
 * que los ajustes de aspecto cambian con CSS en línea (tema / EHERO / propio).
 */

.ehgi-wrapper {
	--ehgi-primary: #017cba;
	--ehgi-primary-dark: #01699e;
	--ehgi-accent: #00b2e2;
	--ehgi-text: #1f2937;
	--ehgi-text-soft: #6b7280;
	--ehgi-border: #e5e7eb;
	--ehgi-bg-soft: #f9fafb;
	--ehgi-bg-hover: #f0f9ff;

	max-width: 1100px;
	margin: 0 auto;
	color: var(--ehgi-text);
	line-height: 1.6;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ── Título ── */
.ehgi-wrapper .ehgi-title {
	position: relative;
	margin: 0 0 28px;
	padding: 0 0 14px;
	font-size: 1.6em;
	font-weight: 700;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-title::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 3px;
	border-radius: 3px;
	background: linear-gradient(90deg, var(--ehgi-primary) 0%, var(--ehgi-accent) 55%, transparent 100%);
}

/* ── Avisos / estados ── */
.ehgi-wrapper .ehgi-notice {
	background: var(--ehgi-bg-soft);
	border: 1px solid var(--ehgi-border);
	border-left: 4px solid var(--ehgi-primary);
	border-radius: 8px;
	padding: 16px 20px;
	margin: 0 0 16px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-notice--error {
	border-left-color: #dc2626;
	background: #fef7f7;
}

.ehgi-wrapper .ehgi-hint {
	color: var(--ehgi-text-soft);
	font-size: 14px;
	margin: 0 0 16px;
}

.ehgi-wrapper .ehgi-hint a {
	color: var(--ehgi-primary);
	font-weight: 600;
}

/* ── Pestañas ── */
.ehgi-wrapper .ehgi-tabs {
	display: flex;
	gap: 4px;
	flex-wrap: wrap;
	margin: 0 0 20px;
	border-bottom: 2px solid var(--ehgi-border);
}

.ehgi-wrapper .ehgi-tab {
	display: inline-block;
	padding: 10px 20px;
	margin-bottom: -2px;
	background: var(--ehgi-bg-soft);
	color: #4b5563;
	font-weight: 600;
	font-size: 14px;
	text-decoration: none;
	border: 1px solid var(--ehgi-border);
	border-bottom: none;
	border-radius: 8px 8px 0 0;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.ehgi-wrapper .ehgi-tab:hover {
	background: var(--ehgi-bg-hover);
	color: var(--ehgi-primary);
	text-decoration: none;
}

.ehgi-wrapper .ehgi-tab.is-active {
	background: linear-gradient(135deg, var(--ehgi-primary) 0%, var(--ehgi-accent) 140%);
	color: #fff;
	border-color: var(--ehgi-primary);
}

.ehgi-wrapper .ehgi-tab:focus-visible {
	outline: 2px solid var(--ehgi-accent);
	outline-offset: 2px;
}

/* ── Barra de filtros ── */
.ehgi-wrapper .ehgi-toolbar {
	background: var(--ehgi-bg-soft);
	border: 1px solid var(--ehgi-border);
	border-radius: 8px;
	padding: 14px 18px;
	margin: 0 0 20px;
}

.ehgi-wrapper .ehgi-filter-form {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin: 0;
}

.ehgi-wrapper .ehgi-filter-form select {
	padding: 8px 12px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	min-width: 120px;
	font-size: 14px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-filter-form select:focus {
	outline: none;
	border-color: var(--ehgi-primary);
	box-shadow: 0 0 0 2px var(--ehgi-focus, rgba(1, 124, 186, 0.15));
}

.ehgi-wrapper .ehgi-search {
	flex: 1;
	min-width: 200px;
	max-width: 320px;
	padding: 8px 14px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	font-size: 14px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-search:focus {
	outline: none;
	border-color: var(--ehgi-accent);
	box-shadow: 0 0 0 2px var(--ehgi-focus, rgba(0, 178, 226, 0.18));
}

/* ── Botones ── */
.ehgi-wrapper .ehgi-btn {
	display: inline-block;
	padding: 8px 16px;
	background: var(--ehgi-primary);
	color: #fff;
	border: 1px solid var(--ehgi-primary);
	border-radius: 6px;
	font-weight: 600;
	font-size: 13px;
	line-height: 1.4;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ehgi-wrapper .ehgi-btn:hover {
	background: var(--ehgi-primary-dark);
	border-color: var(--ehgi-primary-dark);
	color: #fff;
	text-decoration: none;
}

.ehgi-wrapper .ehgi-btn:focus-visible {
	outline: 2px solid var(--ehgi-accent);
	outline-offset: 2px;
}

.ehgi-wrapper .ehgi-btn--ghost {
	background: #fff;
	color: var(--ehgi-primary);
	border-color: var(--ehgi-primary);
}

.ehgi-wrapper .ehgi-btn--ghost:hover {
	background: var(--ehgi-bg-hover);
	color: var(--ehgi-primary-dark);
	border-color: var(--ehgi-primary-dark);
}

.ehgi-wrapper .ehgi-btn--pdf {
	padding: 6px 14px;
	font-size: 12px;
	white-space: nowrap;
}

/* ── Contador ── */
.ehgi-wrapper .ehgi-count {
	margin: 0 0 10px;
	color: var(--ehgi-text-soft);
	font-size: 13px;
	font-weight: 500;
}

/* ── Tablas ── */
.ehgi-wrapper .ehgi-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--ehgi-border);
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ehgi-wrapper .ehgi-table {
	width: 100%;
	min-width: 560px;
	margin: 0;
	border: none;
	border-collapse: collapse;
	background: #fff;
	font-size: 14px;
}

.ehgi-wrapper .ehgi-table th,
.ehgi-wrapper .ehgi-table td {
	padding: 12px 16px;
	text-align: left;
	border: none;
	border-bottom: 1px solid #f3f4f6;
	vertical-align: middle;
}

.ehgi-wrapper .ehgi-table thead th {
	background: var(--ehgi-bg-soft);
	color: #374151;
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	border-bottom: 2px solid var(--ehgi-border);
}

.ehgi-wrapper .ehgi-table tbody tr:last-child td {
	border-bottom: none;
}

.ehgi-wrapper .ehgi-table tbody tr:hover {
	background: var(--ehgi-bg-hover);
}

.ehgi-wrapper .ehgi-doc-number {
	font-weight: 600;
	color: var(--ehgi-primary);
	white-space: nowrap;
}

.ehgi-wrapper .ehgi-col-actions {
	text-align: right;
	white-space: nowrap;
}

/* ── Badges de estado ── */
.ehgi-wrapper .ehgi-badge {
	display: inline-block;
	min-width: 64px;
	padding: 4px 12px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.3px;
	text-align: center;
	text-transform: uppercase;
	white-space: nowrap;
}

.ehgi-wrapper .ehgi-badge--success {
	background: #d1fae5;
	color: #065f46;
}

.ehgi-wrapper .ehgi-badge--warning {
	background: #fef3c7;
	color: #92400e;
}

.ehgi-wrapper .ehgi-badge--danger {
	background: #fee2e2;
	color: #991b1b;
}

.ehgi-wrapper .ehgi-badge--muted {
	background: #e5e7eb;
	color: #374151;
}

.ehgi-wrapper .ehgi-badge--info {
	background: #dff4fb;
	color: #01546f;
}

/* ── Estado vacío ── */
.ehgi-wrapper .ehgi-empty {
	background: var(--ehgi-bg-soft);
	border: 1px dashed #d1d5db;
	border-radius: 8px;
	padding: 32px 20px;
	margin: 8px 0 0;
	text-align: center;
	color: var(--ehgi-text-soft);
	font-size: 14px;
}

/* ── Detalle de pedido ── */
.ehgi-wrapper .ehgi-back-wrap {
	margin: 0 0 16px;
}

.ehgi-wrapper .ehgi-back {
	color: var(--ehgi-primary);
	font-weight: 600;
	font-size: 14px;
	text-decoration: none;
}

.ehgi-wrapper .ehgi-back:hover {
	color: var(--ehgi-primary-dark);
	text-decoration: underline;
}

.ehgi-wrapper .ehgi-detail-card {
	background: #fff;
	border: 1px solid var(--ehgi-border);
	border-left: 4px solid var(--ehgi-primary);
	border-radius: 8px;
	padding: 20px 24px;
	margin: 0 0 20px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ehgi-wrapper .ehgi-detail-head {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin: 0 0 8px;
}

.ehgi-wrapper .ehgi-detail-title {
	margin: 0;
	font-size: 1.2em;
	font-weight: 700;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-detail-meta {
	display: flex;
	gap: 24px;
	flex-wrap: wrap;
	font-size: 14px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-detail-label {
	display: inline-block;
	margin-right: 6px;
	color: var(--ehgi-text-soft);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.ehgi-wrapper .ehgi-detail-comment {
	margin: 14px 0 0;
	padding: 12px 16px;
	background: var(--ehgi-bg-soft);
	border-radius: 6px;
	font-size: 14px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-sku {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 7px;
	background: var(--ehgi-bg-soft);
	border: 1px solid var(--ehgi-border);
	border-radius: 4px;
	color: var(--ehgi-text-soft);
	font-family: SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 11px;
	white-space: nowrap;
}

.ehgi-wrapper .ehgi-table--detail .ehgi-col-product {
	min-width: 220px;
}

.ehgi-wrapper .ehgi-table tfoot .ehgi-total-row th,
.ehgi-wrapper .ehgi-table tfoot .ehgi-total-row td {
	background: var(--ehgi-bg-soft);
	border-top: 2px solid var(--ehgi-border);
	border-bottom: none;
	font-weight: 700;
	font-size: 15px;
	color: var(--ehgi-text);
}

.ehgi-wrapper .ehgi-table tfoot .ehgi-total-row th {
	text-align: right;
}

/* ── Botón del escritorio de Mi cuenta ──
 * Vive fuera de .ehgi-wrapper (el escritorio no lleva el wrapper), así que
 * declara aquí sus variables; los ajustes de aspecto las cambian en línea.
 */
.ehgi-dashboard-button-wrap {
	--ehgi-primary: #017cba;
	--ehgi-accent: #00b2e2;
	margin-top: 1em;
}

/* «Automático»: si el tema ya pone en el escritorio un enlace a Facturas
 * (Flatsome pinta ahí todo el menú de la cuenta), no se repite. */
.woocommerce-MyAccount-content:has(.woocommerce-MyAccount-navigation-link--gesio-facturas) .ehgi-dashboard-button-wrap.is-auto,
.woocommerce-MyAccount-content:has(.dashboard-links a[href*="gesio-facturas"]) .ehgi-dashboard-button-wrap.is-auto {
	display: none;
}

a.ehgi-dashboard-button {
	display: block;
	padding: 14px 24px;
	background: var(--ehgi-primary, #017cba);
	color: #fff;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	border-radius: 6px;
	transition: background-color 0.2s ease;
}

a.ehgi-dashboard-button:hover,
a.ehgi-dashboard-button:focus {
	background: var(--ehgi-primary-dark, var(--ehgi-accent, #00b2e2));
	color: #fff;
	text-decoration: none;
}

/* ── Accesibilidad ── */
.ehgi-wrapper .ehgi-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Responsive ── */
@media (max-width: 640px) {
	.ehgi-wrapper .ehgi-filter-form {
		align-items: stretch;
		flex-direction: column;
	}

	.ehgi-wrapper .ehgi-filter-form select,
	.ehgi-wrapper .ehgi-search {
		width: 100%;
		max-width: none;
	}

	.ehgi-wrapper .ehgi-tab {
		padding: 9px 14px;
		font-size: 13px;
	}

	.ehgi-wrapper .ehgi-table th,
	.ehgi-wrapper .ehgi-table td {
		padding: 10px 12px;
	}

	.ehgi-wrapper .ehgi-detail-meta {
		gap: 12px;
		flex-direction: column;
	}
}
