/* ============================================================
   MIPB — Essential Amino Acid Profiles Table & Comparison Tool
   Stylesheet for [amino_table] and [compare_amino]
   Theme: Deep Purple — amino acid focus
   ============================================================ */

/* ── Header grid ───────────────────────────────────────────── */
.maa-header-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.5rem;
	margin: 0 auto 2rem;
	max-width: 1040px;
	align-items: start;
}
@media (max-width: 720px) {
	.maa-header-grid { grid-template-columns: 1fr; }
}

/* ── Top-10 SEO block ────────────────────────────────────────── */
.maa-top10 { margin-bottom: 0; }
.maa-top10 h2 { font-size: 1.25rem; margin-bottom: .5rem; color: #4A148C; }
.maa-top10-list { margin: 0; padding-left: 1.4rem; }
.maa-top10-list li { margin-bottom: .3rem; line-height: 1.5; }

/* ── Insight box ─────────────────────────────────────────────── */
.maa-insight-box {
	background: #F3E5F5;
	border: 1px solid #CE93D8;
	border-left: 4px solid #4A148C;
	border-radius: 6px;
	padding: .85rem 1rem;
	margin-bottom: .9rem;
}
.maa-insight-title {
	font-size: .8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: #4A148C;
	margin: 0 0 .55rem;
}
.maa-insight-list {
	margin: 0;
	padding-left: 1.1rem;
	font-size: .88rem;
	color: #333;
}
.maa-insight-list li { margin-bottom: .28rem; line-height: 1.5; }

/* ── Context card ─────────────────────────────────────────────── */
.maa-context-card {
	background: #F3E5F5;
	border: 1px solid #CE93D8;
	border-left: 4px solid #7B1FA2;
	border-radius: 6px;
	padding: .75rem 1rem;
	font-size: .87rem;
	color: #333;
	line-height: 1.55;
}
.maa-context-label {
	font-size: .75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .07em;
	color: #7B1FA2;
	margin: 0 0 .35rem;
}
.maa-context-card p { margin: 0; }
.maa-context-card a { color: #4A148C; font-weight: 600; text-decoration: underline; }
.maa-context-card a:hover { color: #7B1FA2; }

/* ── Main wrap ────────────────────────────────────────────────── */
.maa-wrap {
	--primary:  #4A148C;
	--bg-light: #F3E5F5;
	--border:   #CE93D8;
	--bar-bg:   #7B1FA2;
	max-width: 1040px;
	margin: 0 auto;
	font-family: inherit;
}

/* ── Controls row ────────────────────────────────────────────── */
.maa-controls {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
	align-items: center;
	margin-bottom: .75rem;
}
.maa-search,
.maa-select {
	padding: .45rem .7rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: .9rem;
	background: #fff;
	color: #333;
	outline: none;
	transition: border-color .15s;
}
.maa-search { flex: 1 1 200px; min-width: 150px; }
.maa-select { flex: 0 1 220px; }
.maa-search:focus,
.maa-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px #F3E5F5; }

.maa-btn {
	padding: .45rem .9rem;
	background: var(--primary);
	color: #fff;
	border: none;
	border-radius: 4px;
	font-size: .88rem;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s;
}
.maa-btn:hover { background: #7B1FA2; }

/* ── Table ────────────────────────────────────────────────────── */
.maa-table-wrap { overflow-x: auto; margin-top: .6rem; }
.maa-table {
	width: 100%;
	border-collapse: collapse;
	font-size: .9rem;
}
.maa-table th {
	background: var(--primary);
	color: #fff;
	padding: .55rem .75rem;
	text-align: left;
	white-space: nowrap;
	font-weight: 600;
}
.maa-table td {
	padding: .45rem .75rem;
	border-bottom: 1px solid #F0F0F0;
	vertical-align: middle;
	color: #222;
}
.maa-table tr:hover td { background: var(--bg-light); }
.maa-table tr:last-child td { border-bottom: none; }

.col-rank  { width: 3rem; text-align: center; color: #777; font-size: .82rem; }
.col-food  { min-width: 160px; }
.col-group { min-width: 120px; color: #555; font-size: .85rem; }
.col-val   { width: 8rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-bar   { width: 140px; padding-right: .5rem; }

/* ── Amino acid bar breakdown ────────────────────────────────── */
.maa-bar-container {
	display: flex;
	gap: 1px;
	height: 20px;
	background: #eee;
	border-radius: 3px;
	overflow: visible;
	position: relative;
}
.maa-bar-container .maa-bar-segment:first-child {
	border-radius: 3px 0 0 3px;
}
.maa-bar-container .maa-bar-segment:last-child {
	border-radius: 0 3px 3px 0;
}
.maa-bar-segment {
	flex: 1;
	transition: opacity .2s;
	position: relative;
	cursor: pointer;
}
.maa-bar-segment:hover { opacity: 0.7; }

/* ── Custom instant tooltip (JS-positioned, appended to body) ── */
.maa-tip {
	position: fixed;
	background: #1a1a1a;
	color: #fff;
	font-size: 12px;
	line-height: 1.3;
	padding: 5px 9px;
	border-radius: 5px;
	white-space: nowrap;
	pointer-events: none;
	z-index: 999999;
	opacity: 0;
	transition: opacity .08s;
}
.maa-tip.maa-tip--visible {
	opacity: 1;
}
.maa-tip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 5px solid transparent;
	border-top-color: #1a1a1a;
}

/* ── Pagination ──────────────────────────────────────────────── */
.maa-pagination {
	display: flex;
	gap: .3rem;
	justify-content: center;
	margin-top: 1rem;
	flex-wrap: wrap;
}
.maa-page-btn {
	padding: .35rem .6rem;
	background: #fff;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: .85rem;
	cursor: pointer;
	transition: all .15s;
	color: var(--primary);
}
.maa-page-btn:hover {
	background: var(--bg-light);
	border-color: var(--primary);
}
.maa-page-active {
	background: var(--primary);
	color: #fff;
	border-color: var(--primary);
}

/* ── Loading / Empty ─────────────────────────────────────────── */
.maa-loading,
.maa-empty {
	text-align: center;
	color: #999;
	padding: 1.5rem !important;
	font-style: italic;
}

/* ── Attribution ─────────────────────────────────────────────── */
.maa-attribution {
	font-size: .85rem;
	color: #666;
	text-align: center;
	margin-top: 1.2rem;
	padding: 0 .75rem;
}
.maa-attribution a { color: var(--primary); text-decoration: none; }
.maa-attribution a:hover { text-decoration: underline; }

/* ── FAQ Section ─────────────────────────────────────────────── */
.maa-faq {
	max-width: 1040px;
	margin: 2rem auto;
	font-size: .95rem;
	line-height: 1.65;
}
.maa-faq h2 {
	color: var(--primary);
	font-size: 1.5rem;
	margin-bottom: 1.2rem;
	border-bottom: 2px solid var(--bg-light);
	padding-bottom: .5rem;
}
.maa-faq details {
	background: #fafafa;
	border: 1px solid #eee;
	border-left: 3px solid var(--primary);
	border-radius: 4px;
	padding: .75rem 1rem;
	margin-bottom: .6rem;
	cursor: pointer;
}
.maa-faq details[open] {
	background: #fff;
	border-left-color: var(--primary);
}
.maa-faq summary {
	font-weight: 600;
	color: var(--primary);
	outline: none;
}
.maa-faq summary:hover { text-decoration: underline; }
.maa-faq details p {
	margin: .6rem 0 0 0;
	color: #333;
}

/* ──────────────────────────────────────────────────────────── */
/* COMPARISON TOOL STYLES ([compare_amino])                    */
/* ──────────────────────────────────────────────────────────── */

.maac-wrap {
	--primary:  #4A148C;
	--bg-light: #F3E5F5;
	--border:   #CE93D8;
	max-width: 1040px;
	margin: 0 auto;
	font-family: inherit;
}

/* ── Search section ──────────────────────────────────────────── */
.maac-search-section {
	margin-bottom: 1.2rem;
}
.maac-search-section label {
	display: block;
	font-weight: 600;
	color: var(--primary);
	margin-bottom: .4rem;
	font-size: .95rem;
}
.maac-search-box {
	position: relative;
	margin-bottom: .8rem;
}
#maac-search-input {
	width: 100%;
	padding: .6rem .85rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: .95rem;
	background: #fff;
	color: #333;
	outline: none;
	transition: border-color .15s;
	box-sizing: border-box;
}
#maac-search-input:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 2px var(--bg-light);
}

.maac-suggestions {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid var(--border);
	border-top: none;
	border-radius: 0 0 4px 4px;
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 250px;
	overflow-y: auto;
	z-index: 10;
}
.maac-result {
	padding: .6rem .85rem;
	border-bottom: 1px solid #eee;
	cursor: pointer;
	transition: background .15s;
	font-size: .9rem;
}
.maac-result:hover,
.maac-result.maac-selected {
	background: var(--bg-light);
	color: var(--primary);
	font-weight: 600;
}
.maac-group {
	color: #999;
	font-size: .85rem;
	display: inline-block;
	margin-left: .4rem;
}
.maac-result.maac-selected .maac-group { color: #7B1FA2; }

/* ── Comparison table ────────────────────────────────────────── */
.maac-table-wrap {
	overflow-x: auto;
	margin-top: 1rem;
	border: 1px solid #ddd;
	border-radius: 4px;
}
.maac-table {
	width: 100%;
	border-collapse: collapse;
	font-size: .85rem;
	background: #fff;
}
.maac-table th {
	background: var(--primary);
	color: #fff;
	padding: .6rem .55rem;
	text-align: center;
	white-space: nowrap;
	font-weight: 600;
	border-right: 1px solid rgba(255, 255, 255, 0.1);
}
.maac-table th:first-child {
	text-align: left;
}
.maac-table th:last-child {
	border-right: none;
}
.maac-table td {
	padding: .55rem .55rem;
	border-bottom: 1px solid #eee;
	text-align: center;
	vertical-align: middle;
	white-space: nowrap;
	font-size: 0.85em;
	font-variant-numeric: tabular-nums;
	color: #222;
}
.maac-table td:first-child {
	text-align: left;
	font-weight: 500;
	min-width: 140px;
}
.maac-table tr:hover td { background: var(--bg-light); }
.maac-table tr:last-child td { border-bottom: none; }

.col-aa { width: 4.5rem; }
.col-aa { min-width: 50px; }
.col-total { width: 5rem; font-weight: 600; background: rgba(74, 20, 140, 0.02); }
.col-remove { width: 2.5rem; padding: .3rem; }

.maac-remove-btn {
	padding: .25rem .4rem;
	background: #f0f0f0;
	border: 1px solid #ddd;
	border-radius: 3px;
	font-size: 1rem;
	cursor: pointer;
	color: #d32f2f;
	transition: all .15s;
	line-height: 1;
}
.maac-remove-btn:hover {
	background: #d32f2f;
	color: #fff;
	border-color: #d32f2f;
}

/* ── Empty state ─────────────────────────────────────────────── */
.maac-empty {
	text-align: center;
	color: #999;
	padding: 2rem 1rem !important;
	font-style: italic;
	background: #fafafa;
}

/* ── Attribution ─────────────────────────────────────────────── */
.maac-attribution {
	font-size: .85rem;
	color: #666;
	text-align: center;
	margin-top: 1.2rem;
	padding: 0 .75rem;
}
.maac-attribution a { color: var(--primary); text-decoration: none; }
.maac-attribution a:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
	.maa-controls {
		gap: .35rem;
	}
	.maa-search,
	.maa-select {
		font-size: .85rem;
		padding: .4rem .6rem;
	}
	.maa-table-wrap { font-size: .8rem; }
	.maa-table th, .maa-table td { padding: .35rem .5rem; }
	.col-rank { width: 2.5rem; }
	.col-bar { width: 100px; }

	.maac-table-wrap { margin-top: .75rem; }
	.maac-table { font-size: .75rem; }
	.maac-table th, .maac-table td { padding: .4rem .35rem; }
	.col-aa { min-width: 45px; }
}

@media (max-width: 480px) {
	.maa-header-grid { gap: 1rem; }
	.maa-top10 h2, .maa-insight-title { font-size: .75rem; }
	.maa-controls { flex-direction: column; }
	.maa-search, .maa-select { width: 100%; }
	.maa-btn { width: 100%; }

	.maac-search-section { margin-bottom: 0.8rem; }
	.maac-table { font-size: .7rem; }
	.maac-table th, .maac-table td { padding: .3rem .25rem; }
	.col-aa { min-width: 40px; }
	.col-remove { width: 2rem; }
}
