/**
 * TCB Steel Price Tracker — Frontend Styles
 * Brand colors matched to TheCharterBox Laytime Calculator:
 * Navy #1B2A4A, Teal #2CA6A4, Red #D64045, Green #4CAF50
 */

/* CSS Custom Properties for Theming */
.tcb-sp-container,
.tcb-sp-chart-container {
	--tcb-navy: #1B2A4A;
	--tcb-teal: #2CA6A4;
	--tcb-bg: #F5F7FA;
	--tcb-text: #333333;
	--tcb-border: #D1D5DB;
	--tcb-white: #ffffff;
	--tcb-muted: #6B7280;
	--tcb-positive: #4CAF50;
	--tcb-negative: #D64045;
	--tcb-neutral: #6B7280;
	--tcb-hover: rgba(44, 166, 164, 0.04);
	--tcb-category-bg: #F5F7FA;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--tcb-text);
	background: var(--tcb-white);
	border: 1px solid var(--tcb-border);
	border-radius: 8px;
	overflow: hidden;
}

/* Dark theme */
.tcb-sp-container[data-theme="dark"],
.tcb-sp-chart-container[data-theme="dark"] {
	--tcb-bg: #0f172a;
	--tcb-text: #e2e8f0;
	--tcb-border: #334155;
	--tcb-white: #1e293b;
	--tcb-hover: rgba(44, 166, 164, 0.08);
	--tcb-category-bg: #1e293b;
}

/* Auto theme */
@media (prefers-color-scheme: dark) {
	.tcb-sp-container[data-theme="auto"],
	.tcb-sp-chart-container[data-theme="auto"] {
		--tcb-bg: #0f172a;
		--tcb-text: #e2e8f0;
		--tcb-border: #334155;
		--tcb-white: #1e293b;
		--tcb-hover: rgba(44, 166, 164, 0.08);
		--tcb-category-bg: #1e293b;
	}
}

/* ==========================================
   Header — Navy bar matching Laytime Calculator
   ========================================== */

.tcb-sp-header {
	background: var(--tcb-navy);
	color: #ffffff;
	padding: 0;
	border-radius: 8px 8px 0 0;
}

.tcb-sp-header-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 24px;
	gap: 12px;
}

.tcb-sp-title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: #ffffff;
}

.tcb-sp-date {
	font-size: 13px;
	color: rgba(255, 255, 255, 0.7);
}

/* ==========================================
   Login Notice Bar (header, non-logged-in)
   ========================================== */

.tcb-sp-login-notice {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 24px;
	background: rgba(255, 255, 255, 0.1);
	border-top: 1px solid rgba(255, 255, 255, 0.15);
	font-size: 13px;
	color: rgba(255, 255, 255, 0.9);
}

.tcb-sp-lock-icon {
	font-size: 16px;
	line-height: 1;
	flex-shrink: 0;
}

.tcb-sp-notice-text {
	flex: 1;
}

.tcb-sp-notice-btn {
	display: inline-block;
	padding: 5px 16px;
	background: var(--tcb-teal);
	color: #ffffff;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	transition: opacity 0.2s;
	white-space: nowrap;
	flex-shrink: 0;
}

.tcb-sp-notice-btn:hover {
	opacity: 0.85;
	color: #ffffff;
}

/* ==========================================
   Category Tabs — underline style
   ========================================== */

.tcb-sp-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
	padding: 0 24px;
	border-bottom: 2px solid var(--tcb-border);
	background: var(--tcb-white);
}

.tcb-sp-tab {
	padding: 12px 20px;
	border: none;
	border-bottom: 3px solid transparent;
	border-radius: 0;
	background: none;
	color: var(--tcb-muted);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	margin-bottom: -2px;
}

.tcb-sp-tab:hover {
	color: var(--tcb-navy);
}

.tcb-sp-tab.active {
	color: var(--tcb-teal);
	border-bottom-color: var(--tcb-teal);
	background: none;
}

/* ==========================================
   Price Table
   ========================================== */

.tcb-sp-table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
	background: var(--tcb-white);
}

.tcb-sp-table thead {
	background: var(--tcb-navy);
	color: #ffffff;
}

.tcb-sp-table th {
	padding: 10px 16px;
	text-align: left;
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #ffffff;
	border-bottom: none;
	white-space: nowrap;
}

.tcb-sp-table th:nth-child(n+2) {
	text-align: right;
}

.tcb-sp-table td {
	padding: 10px 16px;
	border-bottom: 1px solid var(--tcb-bg);
	vertical-align: middle;
}

.tcb-sp-table td:nth-child(n+2) {
	text-align: right;
}

/* Category header row */
.tcb-sp-category-header td {
	font-weight: 700;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	background: var(--tcb-category-bg);
	padding: 10px 16px;
}

/* Price row hover */
.tcb-sp-row:hover {
	background: var(--tcb-hover);
}

/* Commodity cell */
.tcb-sp-commodity {
	display: flex;
	flex-direction: column;
	text-align: left !important;
}

.tcb-sp-name {
	font-weight: 500;
}

.tcb-sp-symbol {
	font-size: 11px;
	color: var(--tcb-muted);
	font-family: monospace;
}

/* Price */
.tcb-sp-price {
	font-weight: 600;
	font-size: 14px;
}

/* Change indicators */
.tcb-sp-change.positive,
.tcb-sp-pct.positive {
	color: var(--tcb-positive);
}

.tcb-sp-change.negative,
.tcb-sp-pct.negative {
	color: var(--tcb-negative);
}

.tcb-sp-change.neutral,
.tcb-sp-pct.neutral {
	color: var(--tcb-neutral);
}

/* Unit */
.tcb-sp-unit {
	font-size: 12px;
	color: var(--tcb-neutral);
}

/* Footer */
.tcb-sp-footer {
	padding: 10px 20px;
	border-top: 1px solid var(--tcb-border);
	text-align: right;
}

.tcb-sp-source {
	font-size: 11px;
	color: var(--tcb-neutral);
}

/* Compact mode */
.tcb-sp-compact .tcb-sp-table th,
.tcb-sp-compact .tcb-sp-table td {
	padding: 5px 10px;
	font-size: 12px;
}

.tcb-sp-compact .tcb-sp-symbol {
	display: none;
}

/* ==========================================
   Chart Container
   ========================================== */

.tcb-sp-chart-container {
	padding: 20px;
}

.tcb-sp-chart-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	margin-bottom: 16px;
	flex-wrap: wrap;
}

.tcb-sp-chart-select {
	min-width: 250px;
	max-width: 400px;
	padding: 6px 10px;
	border: 1px solid var(--tcb-border);
	border-radius: 6px;
	background: var(--tcb-white);
	color: var(--tcb-text);
	font-size: 13px;
	min-height: 80px;
}

.tcb-sp-chart-periods {
	display: flex;
	gap: 4px;
}

.tcb-sp-chart-periods button {
	padding: 6px 14px;
	border: 1px solid var(--tcb-border);
	border-radius: 6px;
	background: transparent;
	color: var(--tcb-text);
	font-size: 13px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.tcb-sp-chart-periods button:hover {
	background: var(--tcb-hover);
}

.tcb-sp-chart-periods button.active {
	background: var(--tcb-teal);
	color: #fff;
	border-color: var(--tcb-teal);
}

.tcb-sp-chart-wrapper {
	position: relative;
	width: 100%;
}

.tcb-sp-chart-wrapper canvas {
	width: 100% !important;
}

/* ==========================================
   Blur (login-gated prices)
   ========================================== */

/* Blur price values only */
.tcb-sp-blurred .tcb-sp-price,
.tcb-sp-blurred .tcb-sp-change,
.tcb-sp-blurred .tcb-sp-pct {
	filter: blur(7px) !important;
	user-select: none !important;
	pointer-events: none !important;
}

/* Chart placeholder */
.tcb-sp-chart-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--tcb-category-bg);
	border-radius: 8px;
	overflow: hidden;
}

.tcb-sp-chart-placeholder-svg {
	width: 100%;
	height: 100%;
}

/* ==========================================
   Responsive
   ========================================== */

@media screen and (max-width: 600px) {
	.tcb-sp-header-top {
		flex-direction: column;
		gap: 4px;
		text-align: center;
	}

	.tcb-sp-login-notice {
		flex-wrap: wrap;
		justify-content: center;
		text-align: center;
		gap: 8px;
		padding: 10px 16px;
	}

	.tcb-sp-notice-text {
		flex: unset;
		width: 100%;
	}

	.tcb-sp-tabs {
		padding: 0 12px;
	}

	.tcb-sp-tab {
		padding: 10px 14px;
		font-size: 13px;
	}

	.tcb-sp-table th:nth-child(4),
	.tcb-sp-table td:nth-child(4) {
		display: none; /* Hide % change on small screens */
	}

	.tcb-sp-symbol {
		display: none;
	}

	.tcb-sp-table {
		display: block;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.tcb-sp-chart-controls {
		flex-direction: column;
		align-items: stretch;
	}

	.tcb-sp-chart-select {
		max-width: 100%;
	}

	.tcb-sp-chart-periods {
		justify-content: center;
	}
}
