/* Supplier portal theme.
 *
 * Self-contained on purpose: the ERP's css/<theme>/ is deployment-only and not
 * in the repository, so nothing here depends on it.  The green is #3c843b, the
 * value used consistently across the ERP's inline styles (SweetAlert2
 * confirmButtonColor, ~49 occurrences).  If the deployed theme differs, change
 * the four --p* custom properties below and nothing else.
 */

:root {
	--p-green:       #3c843b;
	--p-green-dark:  #2f6a2e;
	--p-green-light: #e8f2e8;
	--p-green-tint:  #f4f8f4;

	--p-text:    #23282a;
	--p-muted:   #6c757d;
	--p-border:  #d9e0d9;
	--p-bg:      #f2f5f2;
	--p-card:    #ffffff;

	--p-danger:  #c62828;
	--p-warn:    #ef6c00;
	--p-info:    #1565c0;

	--p-radius:  8px;
	--p-shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--p-bg);
	color: var(--p-text);
	font-family: 'Sarabun', 'Nanum Gothic', -apple-system, BlinkMacSystemFont,
	             'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	font-size: 15px;
	line-height: 1.55;
	-webkit-text-size-adjust: 100%;
}

a        { color: var(--p-green-dark); }
a:hover  { color: var(--p-green); }

/* ---------- layout ------------------------------------------------------ */

.p-shell   { min-height: 100vh; display: flex; flex-direction: column; }
.p-main    { flex: 1 0 auto; width: 100%; max-width: 1040px;
             margin: 0 auto; padding: 24px 16px 48px; }
.p-main--narrow { max-width: 460px; }

/* ---------- header ------------------------------------------------------ */

.p-header {
	background: var(--p-green);
	color: #fff;
	box-shadow: var(--p-shadow);
}
.p-header-inner {
	max-width: 1040px; margin: 0 auto; padding: 0 16px;
	display: flex; align-items: center; gap: 16px; min-height: 58px;
	flex-wrap: wrap;
}
.p-brand {
	display: flex; align-items: center; gap: 10px;
	font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none;
	margin-right: auto;
}
.p-brand img  { height: 30px; width: auto; display: block; }
.p-brand span { white-space: nowrap; }

.p-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.p-nav a {
	color: #fff; text-decoration: none; font-size: .92rem; font-weight: 600;
	padding: 7px 12px; border-radius: var(--p-radius); white-space: nowrap;
}
.p-nav a:hover        { background: rgba(255,255,255,.16); color: #fff; }
.p-nav a.is-active    { background: rgba(0,0,0,.18); color: #fff; }
.p-nav .p-whoami {
	font-size: .85rem; font-weight: 400; color: rgba(255,255,255,.85);
	padding: 7px 4px 7px 12px; white-space: nowrap;
}

/* ---------- footer ------------------------------------------------------ */

.p-footer {
	flex-shrink: 0; padding: 18px 16px; text-align: center;
	font-size: .82rem; color: var(--p-muted);
	border-top: 1px solid var(--p-border); background: var(--p-card);
}

/* ---------- cards ------------------------------------------------------- */

.p-card {
	background: var(--p-card); border: 1px solid var(--p-border);
	border-radius: var(--p-radius); box-shadow: var(--p-shadow);
	padding: 22px; margin-bottom: 20px;
}
.p-card h1, .p-card h2 { margin-top: 0; }

h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 1.12rem; font-weight: 700; margin: 0 0 12px; }
.p-sub { color: var(--p-muted); font-size: .9rem; margin: 0 0 18px; }

/* ---------- dashboard tiles --------------------------------------------- */

.p-tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.p-tile {
	display: block; text-decoration: none; color: inherit;
	background: var(--p-card); border: 1px solid var(--p-border);
	border-left: 4px solid var(--p-green);
	border-radius: var(--p-radius); box-shadow: var(--p-shadow);
	padding: 22px; transition: transform .12s ease, box-shadow .12s ease;
}
.p-tile:hover {
	transform: translateY(-2px); color: inherit;
	box-shadow: 0 4px 12px rgba(0,0,0,.10);
}
.p-tile-icon  { font-size: 1.9rem; line-height: 1; margin-bottom: 10px; }
.p-tile-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.p-tile-desc  { color: var(--p-muted); font-size: .88rem; }

/* ---------- forms ------------------------------------------------------- */

.p-field  { margin-bottom: 16px; }
.p-field label,
.p-label {
	display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px;
}
.p-req { color: var(--p-danger); }
.p-hint { display: block; color: var(--p-muted); font-size: .8rem; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=search], input[type=number], select, textarea {
	width: 100%; padding: 10px 12px; font: inherit; color: var(--p-text);
	background: #fff; border: 1px solid var(--p-border);
	border-radius: var(--p-radius); appearance: none;
}
input:focus, select:focus, textarea:focus {
	outline: none; border-color: var(--p-green);
	box-shadow: 0 0 0 3px rgba(60,132,59,.16);
}
input[disabled], select[disabled] { background: #f0f0f0; color: var(--p-muted); }
input.p-invalid, select.p-invalid { border-color: var(--p-danger); }
textarea { min-height: 84px; resize: vertical; }

input[type=file] {
	width: 100%; padding: 9px; font: inherit;
	background: var(--p-green-tint); border: 1px dashed var(--p-border);
	border-radius: var(--p-radius);
}

.p-check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.p-check input { width: auto; }

.p-grid2 { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .p-grid2 { grid-template-columns: 1fr; } }

/* ---------- buttons ----------------------------------------------------- */

.p-btn {
	display: inline-block; padding: 10px 20px; font: inherit; font-weight: 600;
	color: #fff; background: var(--p-green); border: 1px solid var(--p-green);
	border-radius: var(--p-radius); cursor: pointer; text-decoration: none;
	text-align: center; line-height: 1.4;
}
.p-btn:hover     { background: var(--p-green-dark); border-color: var(--p-green-dark); color: #fff; }
.p-btn:disabled  { opacity: .5; cursor: not-allowed; }
.p-btn--block    { display: block; width: 100%; }
.p-btn--ghost    { color: var(--p-green-dark); background: #fff; border-color: var(--p-border); }
.p-btn--ghost:hover { background: var(--p-green-tint); color: var(--p-green-dark); }
.p-btn--danger   { color: var(--p-danger); background: #fff; border-color: #f0c8c8; }
.p-btn--danger:hover { background: #fdf0f0; color: var(--p-danger); }
.p-btn--sm       { padding: 5px 12px; font-size: .84rem; }

.p-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- messages ---------------------------------------------------- */

.pmsg {
	display: flex; gap: 10px; align-items: flex-start;
	padding: 12px 14px; margin-bottom: 14px;
	border: 1px solid; border-left-width: 4px; border-radius: var(--p-radius);
	font-size: .92rem;
}
.pmsg-icon { font-weight: 700; line-height: 1.5; }
.pmsg-text { flex: 1; }
.pmsg-success { color: #1b5e20; background: #edf7ed; border-color: #b7dfb7; }
.pmsg-error   { color: #8e1b1b; background: #fdeded; border-color: #f2c2c2; }
.pmsg-warn    { color: #8a4b00; background: #fff5e6; border-color: #f5d3a0; }
.pmsg-info    { color: #0d3f7a; background: #eaf2fc; border-color: #bcd6f5; }

/* ---------- status banner ----------------------------------------------- */

.p-banner {
	padding: 12px 16px; margin-bottom: 20px; font-size: .92rem;
	border-radius: var(--p-radius); border: 1px solid; border-left-width: 4px;
}
.p-banner--pending  { color: #8a4b00; background: #fff5e6; border-color: #f5d3a0; }
.p-banner--rejected { color: #8e1b1b; background: #fdeded; border-color: #f2c2c2; }
.p-banner b { font-weight: 700; }

/* ---------- tables ------------------------------------------------------ */

.p-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.p-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.p-table th, .p-table td {
	padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--p-border);
	vertical-align: top;
}
.p-table thead th {
	background: var(--p-green-light); color: var(--p-green-dark);
	font-weight: 700; font-size: .82rem; text-transform: uppercase;
	letter-spacing: .02em; white-space: nowrap;
	border-bottom: 2px solid var(--p-green);
}
.p-table tbody tr:hover  { background: var(--p-green-tint); }
.p-table .p-num          { text-align: right; white-space: nowrap; }
.p-table .p-mid          { text-align: center; white-space: nowrap; }
.p-empty { padding: 28px 12px; text-align: center; color: var(--p-muted); font-style: italic; }

/* ---------- badges ------------------------------------------------------ */

.p-badge {
	display: inline-block; padding: 2px 9px; border-radius: 999px;
	font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.p-badge--ok      { color: #1b5e20; background: #d7efd7; }
.p-badge--warn    { color: #8a4b00; background: #ffe8c2; }
.p-badge--danger  { color: #8e1b1b; background: #f8d7d7; }
.p-badge--muted   { color: #444;    background: #e4e4e4; }

.p-expire-ok    { color: #2e7d32; font-weight: 700; }
.p-expire-soon  { color: #ef6c00; font-weight: 700; }
.p-expire-past  { color: #c62828; font-weight: 700; }

/* ---------- stock search ------------------------------------------------ */

.p-searchrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.p-searchrow .p-field { flex: 1 1 240px; margin-bottom: 0; }

.p-results {
	margin-top: 14px; max-height: 340px; overflow-y: auto;
	border: 1px solid var(--p-border); border-radius: var(--p-radius);
}
.p-results:empty { display: none; }

.p-selected {
	display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
	padding: 12px 14px; margin-bottom: 18px;
	background: var(--p-green-light); border: 1px solid var(--p-green);
	border-radius: var(--p-radius);
}
.p-selected-code { font-weight: 700; font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.p-selected .p-btn { margin-left: auto; }

.p-spin { display: inline-block; color: var(--p-muted); font-size: .86rem; }

/* ---------- purchase history (myitems.php, stockdocs.php) --------------- */

/* The supplied-items table nested above the search box on stockdocs.php. */
.p-histbox {
	border: 1px solid var(--p-border); border-radius: 8px;
	padding: 12px 14px; margin-bottom: 18px; background: #fcfdfc;
}
.p-histhead {
	display: flex; gap: 12px; align-items: flex-start;
	justify-content: space-between; margin-bottom: 10px; font-size: .9rem;
}
.p-histhead .p-btn { flex: 0 0 auto; }

/* Cap the nested table so a 110-row supplier does not bury the search box. */
.p-histbox .p-tablewrap { max-height: 360px; overflow-y: auto; }
.p-histbox .p-table thead th { position: sticky; top: 0; z-index: 1; }

.p-histtable td { vertical-align: top; }

.p-sumrow {
	display: flex; gap: 18px; flex-wrap: wrap;
	margin: 0 0 16px; font-size: .9rem; color: var(--p-muted);
}
.p-sumitem { display: inline-flex; align-items: center; gap: 6px; }
.p-sumitem b { color: var(--p-text); font-size: 1.05rem; }

/* The state filter buttons.  .is-active is otherwise only styled for nav
   links, which sit on the dark header and need the opposite treatment. */
.p-btn.is-active {
	background: var(--p-green-tint); border-color: var(--p-green-dark);
	color: var(--p-green-dark); font-weight: 700;
}

/* ---------- misc -------------------------------------------------------- */

.p-divider {
	display: flex; align-items: center; gap: 12px;
	margin: 22px 0; color: var(--p-muted); font-size: .82rem;
}
.p-divider::before, .p-divider::after {
	content: ''; flex: 1; height: 1px; background: var(--p-border);
}
.p-links { text-align: center; font-size: .9rem; margin-top: 18px; }
.p-links a { display: inline-block; margin: 0 8px; }

.p-login-logo { text-align: center; margin-bottom: 22px; }
.p-login-logo img { max-width: 180px; height: auto; }

.p-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.p-nowrap { white-space: nowrap; }
.p-muted  { color: var(--p-muted); }
.p-hidden { display: none !important; }

@media (max-width: 620px) {
	.p-main   { padding: 16px 12px 36px; }
	.p-card   { padding: 16px; }
	.p-header-inner { min-height: 52px; }
	.p-brand span   { font-size: .95rem; }
	.p-nav a  { padding: 6px 9px; font-size: .86rem; }
	.p-nav .p-whoami { display: none; }
}
