/* Reef Stocking Planner — scoped styles. All selectors are .rsp-* to avoid theme collisions.
   Color strategy: deep-ocean dark theme. Teal accent (60%), coral secondary (30%), sand warm (10%).
   Cards sit ABOVE panels (lighter, not darker) — fixes the original hierarchy bug. */

.rsp-app {
	/* Surfaces */
	--rsp-bg:        #061726;   /* deep ocean */
	--rsp-panel:     #0e2740;   /* panel surface */
	--rsp-card:      #173356;   /* card — LIFTED above panel */
	--rsp-card-hover:#1f4072;
	--rsp-input:     #0a1d31;   /* form fields recede */
	--rsp-border:    #2d527a;
	--rsp-border-soft:#1f3e60;

	/* Text */
	--rsp-text:      #f1f7fc;
	--rsp-text-soft: #d6e4f1;
	--rsp-muted:     #b8cfe2;   /* AA contrast on --rsp-card */
	--rsp-muted-low: #7a9bb8;

	/* Brand & accents */
	--rsp-accent:        #14b8a6;   /* teal — dominant brand */
	--rsp-accent-strong: #5eead4;
	--rsp-accent-deep:   #0d9488;
	--rsp-coral:         #fb7185;   /* coral — secondary */
	--rsp-coral-deep:    #e11d48;
	--rsp-sand:          #d4b483;
	--rsp-sand-deep:     #b08855;

	/* Semantic */
	--rsp-ok:   #4ade80;
	--rsp-warn: #fbbf24;
	--rsp-bad:  #f87171;
	--rsp-info: #60a5fa;

	/* Water */
	--rsp-water-top:    #0f4c75;
	--rsp-water-mid:    #0c3956;
	--rsp-water-bottom: #0a2942;

	display: grid;
	grid-template-columns: 340px 1fr 320px;
	gap: 16px;
	background: var(--rsp-bg);
	color: var(--rsp-text);
	padding: 16px;
	border-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.45;
	box-sizing: border-box;
}

.rsp-app *, .rsp-app *::before, .rsp-app *::after { box-sizing: border-box; }

/* Defensive heading reset — neutralize WordPress theme styles on h1-h6 inside the planner.
   Themes commonly enforce dark colors and large sizes that override our scoped styles. */
.rsp-app h1, .rsp-app h2, .rsp-app h3, .rsp-app h4, .rsp-app h5, .rsp-app h6 {
	color: inherit;
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-weight: inherit;
	line-height: 1.3;
	border: 0;
	background: none;
	text-shadow: none;
}

/* Light theme */
.rsp-theme-light.rsp-app {
	--rsp-bg:        #eef4f9;
	--rsp-panel:     #ffffff;
	--rsp-card:      #ffffff;
	--rsp-card-hover:#f1f7fc;
	--rsp-input:     #f8fafc;
	--rsp-border:    #cbd9e6;
	--rsp-border-soft:#e2e8f0;
	--rsp-text:      #0c1f33;
	--rsp-text-soft: #1e3a5f;
	--rsp-muted:     #475569;
	--rsp-muted-low: #94a3b8;
	--rsp-water-top:    #38bdf8;
	--rsp-water-mid:    #0ea5e9;
	--rsp-water-bottom: #0284c7;
}

@media (max-width: 1024px) {
	.rsp-app { grid-template-columns: 1fr; }
}

.rsp-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.rsp-card {
	background: var(--rsp-panel);
	border: 1px solid var(--rsp-border);
	border-radius: 10px;
	padding: 14px;
}

.rsp-card__title {
	margin: 0 0 12px !important;
	font-size: 12px !important;
	font-weight: 700 !important;
	letter-spacing: 0.12em !important;
	text-transform: uppercase !important;
	color: var(--rsp-accent-strong) !important;
	line-height: 1.2 !important;
	text-shadow: 0 0 12px rgba(94, 234, 212, 0.25);
}

.rsp-tank-title {
	font-size: 20px !important;
	font-weight: 700 !important;
	letter-spacing: 0 !important;
	text-transform: none !important;
	color: #ffffff !important;
	margin: 0 !important;
	text-shadow: none !important;
}

/* "IN TANK" sub-heading uses the same teal so all section titles match. */
.rsp-stocked h3 {
	margin: 0 0 8px !important;
	font-size: 12px !important;
	font-weight: 700 !important;
	text-transform: uppercase !important;
	letter-spacing: 0.12em !important;
	color: var(--rsp-accent-strong) !important;
	line-height: 1.2 !important;
}

/* Form fields */
.rsp-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.rsp-field span { font-size: 11px; color: var(--rsp-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.rsp-field input, .rsp-field select, .rsp-search, .rsp-filters select {
	background: var(--rsp-input);
	color: var(--rsp-text);
	border: 1px solid var(--rsp-border);
	border-radius: 6px;
	padding: 7px 9px;
	font-size: 14px;
	width: 100%;
	transition: border-color 0.15s, box-shadow 0.15s;
	font-family: inherit;
}

/* Suppress WordPress theme-injected dropdown arrows; render a single custom caret. */
.rsp-app select {
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23b8cfe2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
	background-repeat: no-repeat !important;
	background-position: right 10px center !important;
	background-size: 12px 8px !important;
	padding-right: 30px !important;
}
.rsp-theme-light.rsp-app select,
.rsp-theme-auto.rsp-app select {
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23475569' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
}
/* IE/Edge legacy arrow */
.rsp-app select::-ms-expand { display: none !important; }
.rsp-field input:focus, .rsp-field select:focus, .rsp-search:focus, .rsp-filters select:focus {
	outline: none;
	border-color: var(--rsp-accent);
	box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}
.rsp-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rsp-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 6px; }
.rsp-checks label { font-size: 12px; display: flex; align-items: center; gap: 6px; color: var(--rsp-text-soft); }
.rsp-checks input[type="checkbox"], .rsp-filters input[type="checkbox"] { accent-color: var(--rsp-accent); }

/* Search section — cards lifted with stronger contrast */
.rsp-card--search { background: var(--rsp-panel); }
.rsp-search { margin-bottom: 10px; }

.rsp-filters {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 12px;
}
.rsp-filter { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.rsp-filter > span { color: var(--rsp-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.rsp-filter--inline { flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--rsp-text-soft); }

/* Fish list wrap — positioned container for scroll arrows + fade gradients. */
.rsp-fish-list-wrap { position: relative; }

.rsp-fish-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 540px;
	overflow-y: auto;
	overflow-x: hidden;
	padding-right: 4px;
	/* Keep wheel events inside the list — prevents the page (or the WP theme's scroll-jack)
	   from stealing the scroll when the user wheels over the fish cards. */
	overscroll-behavior: contain;
	/* Firefox */
	scrollbar-width: auto;
	scrollbar-color: var(--rsp-accent) var(--rsp-input);
}
/* WebKit / Blink — chunky teal scrollbar that's hard to miss */
.rsp-fish-list::-webkit-scrollbar { width: 14px; }
.rsp-fish-list::-webkit-scrollbar-track {
	background: var(--rsp-input);
	border-radius: 7px;
	border: 1px solid var(--rsp-border-soft);
}
.rsp-fish-list::-webkit-scrollbar-thumb {
	background: linear-gradient(180deg, var(--rsp-accent), var(--rsp-accent-deep));
	border-radius: 7px;
	border: 2px solid var(--rsp-input);
	min-height: 40px;
	box-shadow: 0 0 4px rgba(20, 184, 166, 0.4);
}
.rsp-fish-list::-webkit-scrollbar-thumb:hover {
	background: linear-gradient(180deg, var(--rsp-accent-strong), var(--rsp-accent));
	box-shadow: 0 0 6px rgba(20, 184, 166, 0.6);
}
.rsp-fish-list::-webkit-scrollbar-thumb:active {
	background: var(--rsp-accent-strong);
}

/* Fade gradients — visible only when there's content above/below */
.rsp-fish-list-fade {
	position: absolute;
	left: 0;
	right: 14px; /* clear the scrollbar */
	height: 28px;
	pointer-events: none;
	z-index: 4;
	opacity: 0;
	transition: opacity 0.2s;
}
.rsp-fish-list-fade--top {
	top: 0;
	background: linear-gradient(to bottom, var(--rsp-panel) 10%, rgba(14, 39, 64, 0));
	border-top-left-radius: 6px;
	border-top-right-radius: 6px;
}
.rsp-fish-list-fade--bottom {
	bottom: 0;
	background: linear-gradient(to top, var(--rsp-panel) 10%, rgba(14, 39, 64, 0));
	border-bottom-left-radius: 6px;
	border-bottom-right-radius: 6px;
}
.rsp-fish-list-fade.rsp-show { opacity: 1; }


.rsp-fish-card {
	display: grid;
	grid-template-columns: 72px 1fr;
	gap: 10px;
	background: var(--rsp-card);
	border: 1px solid var(--rsp-border-soft);
	border-radius: 8px;
	padding: 10px;
	cursor: grab;
	transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.rsp-fish-card:hover {
	border-color: var(--rsp-accent);
	background: var(--rsp-card-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.rsp-fish-card:active { cursor: grabbing; }

.rsp-fish-card__media {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(180deg, rgba(20,184,166,0.10), rgba(14,116,144,0.18));
	border: 1px solid var(--rsp-border-soft);
	border-radius: 6px;
	padding: 4px;
	min-height: 56px;
}
.rsp-fish-card__media .rsp-fish-svg { width: 100%; height: auto; max-height: 56px; }

.rsp-fish-card__body { display: flex; flex-direction: column; min-width: 0; }
.rsp-fish-card__head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--rsp-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rsp-fish-card__head em { font-size: 11px; color: var(--rsp-muted); font-style: italic; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rsp-fish-card__stats { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; margin: 6px 0; align-items: center; }
.rsp-fish-card__stats div { font-size: 11px; line-height: 1.2; }
.rsp-fish-card__stats dt { color: var(--rsp-muted-low); margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.rsp-fish-card__stats dd { margin: 0; font-weight: 700; color: var(--rsp-text); font-size: 12px; }
.rsp-fish-card__agg dd { display: flex; gap: 1px; }

.rsp-fish-card__foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }

/* Aggression dots */
.rsp-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--rsp-border); }
.rsp-dot--on { background: var(--rsp-warn); box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3); }

/* Badges */
.rsp-badge {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	padding: 3px 6px;
	border-radius: 4px;
	border: 1px solid;
}
.rsp-badge--ok   { color: var(--rsp-ok);   border-color: var(--rsp-ok);   background: rgba(74, 222, 128, 0.12); }
.rsp-badge--warn { color: var(--rsp-warn); border-color: var(--rsp-warn); background: rgba(251, 191, 36, 0.12); }
.rsp-badge--bad  { color: var(--rsp-bad);  border-color: var(--rsp-bad);  background: rgba(248, 113, 113, 0.12); }

/* Tank canvas */
.rsp-tank-card { display: flex; flex-direction: column; gap: 12px; }
.rsp-tank-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.rsp-tank-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.rsp-tank {
	position: relative;
	display: grid;
	grid-template-rows: 1fr 2fr 1.5fr 0.6fr;
	min-height: 460px;
	background: linear-gradient(to bottom, var(--rsp-water-top), var(--rsp-water-mid) 60%, var(--rsp-water-bottom));
	border: 4px solid #050d18;
	border-top-width: 6px; /* lid rim */
	border-radius: 8px;
	overflow: hidden;
	box-shadow: inset 0 4px 16px rgba(0, 0, 0, 0.45);
}
.rsp-tank--no-lid { border-top: 2px dashed rgba(255,255,255,0.25); }

.rsp-zone {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: 8px;
	padding: 10px;
	transition: background-color 0.2s;
}
/* Sand bed: tan only when has_sand_bed is true. */
.rsp-zone--sand { background: linear-gradient(to bottom, transparent, var(--rsp-sand) 80%); }
.rsp-tank--no-sand .rsp-zone--sand { background: linear-gradient(to bottom, transparent, rgba(10, 41, 66, 0.6) 80%); }

.rsp-zone--hover { background-color: rgba(20, 184, 166, 0.18); outline: 2px dashed var(--rsp-accent); outline-offset: -4px; }
.rsp-zone__label {
	position: absolute; top: 6px; left: 10px;
	font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
	color: rgba(255, 255, 255, 0.45);
	pointer-events: none;
}

/* Swimmers — use SVG fish silhouette */
.rsp-swimmer {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: grab;
	flex-shrink: 0;
	filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
	transition: transform 0.2s;
}
.rsp-swimmer:hover { transform: scale(1.08); z-index: 3; }
.rsp-swimmer:active { cursor: grabbing; }
.rsp-swimmer .rsp-fish-svg { width: 100%; height: 100%; display: block; }
.rsp-swimmer__label {
	position: absolute;
	bottom: -16px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 9px;
	color: var(--rsp-text);
	background: rgba(6, 23, 38, 0.85);
	padding: 1px 5px;
	border-radius: 3px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.15s;
}
.rsp-swimmer:hover .rsp-swimmer__label { opacity: 1; }
.rsp-swimmer__remove {
	position: absolute; top: -4px; right: -4px;
	width: 18px; height: 18px; border-radius: 50%;
	background: var(--rsp-coral); color: #fff;
	border: 0; cursor: pointer; font-size: 13px; line-height: 1;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.15s, transform 0.15s;
	z-index: 4;
}
.rsp-swimmer:hover .rsp-swimmer__remove { opacity: 1; }
.rsp-swimmer__remove:hover { transform: scale(1.15); background: var(--rsp-coral-deep); }

/* Stocked list */
.rsp-stocked-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.rsp-stocked-list li {
	display: grid;
	grid-template-columns: 32px 1fr auto;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	background: var(--rsp-card);
	border: 1px solid var(--rsp-border-soft);
	border-radius: 6px;
}
/* Empty-state message: span the whole row so it doesn't get squeezed into the icon column. */
.rsp-stocked-list li.rsp-muted {
	display: block;
	background: transparent;
	border: 1px dashed var(--rsp-border-soft);
	color: var(--rsp-muted);
	padding: 14px 12px;
	text-align: center;
	font-size: 13px;
	line-height: 1.5;
}
.rsp-stocked-icon { display: flex; align-items: center; }
.rsp-stocked-icon .rsp-fish-svg { width: 28px; height: 18px; }
.rsp-stocked-name { color: var(--rsp-text); font-size: 13px; }
.rsp-stocked-list em { color: var(--rsp-muted); font-style: normal; font-size: 11px; margin-left: 4px; }

/* Stocking score */
.rsp-score__bar { height: 14px; background: var(--rsp-input); border: 1px solid var(--rsp-border-soft); border-radius: 7px; overflow: hidden; }
.rsp-score__fill { height: 100%; width: 0%; background: var(--rsp-ok); transition: width 0.3s, background-color 0.3s; }
.rsp-score__fill[data-level="moderate"] { background: var(--rsp-info); }
.rsp-score__fill[data-level="heavy"] { background: var(--rsp-warn); }
.rsp-score__fill[data-level="overstocked"] { background: var(--rsp-bad); }
.rsp-score__text { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; font-size: 13px; }
.rsp-score__text > span:first-child { font-size: 18px; font-weight: 700; color: var(--rsp-text); }
.rsp-score__label { color: var(--rsp-muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; font-weight: 600; }

/* Warnings */
.rsp-warnings { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 480px; overflow-y: auto; }
.rsp-warning { padding: 8px 10px; border-radius: 6px; border-left: 3px solid; background: var(--rsp-card); font-size: 12px; }
.rsp-warning strong { display: block; margin-bottom: 2px; font-size: 13px; color: var(--rsp-text); }
.rsp-warning p { margin: 0; color: var(--rsp-muted); }
.rsp-warning--info    { border-color: var(--rsp-info);  background: rgba(96, 165, 250, 0.08); }
.rsp-warning--caution { border-color: var(--rsp-warn);  background: rgba(251, 191, 36, 0.08); }
.rsp-warning--warning { border-color: var(--rsp-warn);  background: rgba(251, 191, 36, 0.14); }
.rsp-warning--danger  { border-color: var(--rsp-bad);   background: rgba(248, 113, 113, 0.14); }

/* Buttons */
.rsp-btn {
	background: var(--rsp-card);
	color: var(--rsp-text);
	border: 1px solid var(--rsp-border);
	border-radius: 6px;
	padding: 7px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.rsp-btn:hover { background: var(--rsp-accent); border-color: var(--rsp-accent); color: #051c1c; }
.rsp-btn:active { transform: translateY(1px); }
.rsp-btn--small { padding: 4px 8px; font-size: 11px; }
.rsp-btn--danger { color: var(--rsp-coral); border-color: var(--rsp-coral); }
.rsp-btn--danger:hover { background: var(--rsp-coral); border-color: var(--rsp-coral); color: #fff; }

/* PROMINENT Add button */
.rsp-btn--add {
	background: linear-gradient(135deg, var(--rsp-accent), var(--rsp-accent-deep));
	border: 1px solid var(--rsp-accent-strong);
	color: #02201e;
	font-weight: 700;
	padding: 6px 12px;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	box-shadow: 0 2px 6px rgba(20, 184, 166, 0.35);
}
.rsp-btn--add:hover {
	background: linear-gradient(135deg, var(--rsp-accent-strong), var(--rsp-accent));
	color: #02201e;
	transform: translateY(-1px);
	box-shadow: 0 4px 10px rgba(20, 184, 166, 0.5);
}
.rsp-btn__plus {
	font-size: 16px;
	font-weight: 900;
	line-height: 1;
	margin-right: 1px;
}

.rsp-muted { color: var(--rsp-muted); font-size: 12px; padding: 4px 0; }
.rsp-empty { text-align: center; padding: 24px 8px; }

/* Light theme via system preference (only when theme=auto) */
@media (prefers-color-scheme: light) {
	.rsp-theme-auto.rsp-app {
		--rsp-bg:        #eef4f9;
		--rsp-panel:     #ffffff;
		--rsp-card:      #ffffff;
		--rsp-card-hover:#f1f7fc;
		--rsp-input:     #f8fafc;
		--rsp-border:    #cbd9e6;
		--rsp-border-soft:#e2e8f0;
		--rsp-text:      #0c1f33;
		--rsp-text-soft: #1e3a5f;
		--rsp-muted:     #475569;
		--rsp-muted-low: #94a3b8;
	}
}
