/**
 * CoMo Affiliate Credit Manager — Portal Styles
 *
 * Designed to harmonize with the Neve theme + dark/gold brand.
 *
 * @since 0.2.0
 */

/* Container — explicit dark text colour so themes that set the page text
   to white (Como's Neve dark/gold variant) don't leak white text into
   the white portal card on any unstyled descendant. Every per-element
   color rule below has higher specificity and still wins; this is just
   the safety net for elements without their own colour rule. */
.cacm-portal {
	max-width: 560px;
	margin: 20px auto;
	padding: 24px;
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	color: #1d2327;
}

.cacm-portal h3 {
	margin: 0 0 16px;
	font-size: 1.3em;
	color: #1a1a2e;
	border-bottom: 2px solid #d4a843;
	padding-bottom: 8px;
}

/* Buttons — scoped under .cacm-portal so themes can't override the
   colours via more-specific button{} rules. */
.cacm-portal .cacm-btn,
.cacm-portal button.cacm-btn,
.cacm-portal input[type="submit"].cacm-btn,
.cacm-portal a.cacm-btn {
	display: inline-block;
	padding: 10px 24px;
	border: none;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.2s, color 0.2s;
	line-height: 1.4;
}

.cacm-portal .cacm-btn--primary,
.cacm-portal button.cacm-btn--primary,
.cacm-portal input[type="submit"].cacm-btn--primary,
.cacm-portal a.cacm-btn--primary {
	background: #1a1a2e;
	color: #d4a843;
	border: 1px solid #1a1a2e;
}

.cacm-portal .cacm-btn--primary:hover,
.cacm-portal button.cacm-btn--primary:hover,
.cacm-portal input[type="submit"].cacm-btn--primary:hover,
.cacm-portal a.cacm-btn--primary:hover {
	background: #2a2a4e;
	color: #e8c664;
}

/* Form */
.cacm-portal .cacm-form__field {
	margin-bottom: 16px;
}

.cacm-portal .cacm-form__field label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	color: #333;
}

/* Inputs — scoped + element-typed AND !important on the colour-critical
   declarations so Elementor's `.elementor-kit-NN input:not(...)` rule
   (which has equal specificity and loads after ours) can't repaint the
   field to its default grey-on-grey. The form must remain a recognisable
   white text-input from the affiliate's POV. */
.cacm-portal .cacm-form__input,
.cacm-portal input.cacm-form__input,
.cacm-portal input[type="text"].cacm-form__input,
.cacm-portal input[type="number"].cacm-form__input,
.cacm-portal input[type="email"].cacm-form__input {
	width: 100%;
	max-width: 400px;
	padding: 10px 12px;
	border: 1px solid #ccc !important;
	border-radius: 4px !important;
	font-size: 15px;
	box-sizing: border-box;
	background: #fff !important;
	color: #1d2327 !important;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.cacm-portal .cacm-form__input:focus,
.cacm-portal input.cacm-form__input:focus {
	outline: none;
	border-color: #d4a843 !important;
	box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.2) !important;
}

/* Generate-coupon helper text "Maximum: $X.XX. One active coupon..." */
.cacm-portal .cacm-form__hint,
.cacm-portal .description {
	color: #666;
	font-size: 0.88em;
}

.cacm-form__actions {
	margin-top: 20px;
}

/* Notices */
.cacm-notice {
	padding: 12px 16px;
	border-radius: 4px;
	margin-bottom: 16px;
}

.cacm-notice--success {
	background: #e8f5e9;
	border: 1px solid #4caf50;
	color: #2e7d32;
}

.cacm-notice--error {
	background: #fce4ec;
	border: 1px solid #ef5350;
	color: #c62828;
}

/* Pending claim state */
.cacm-portal--claim-pending {
	text-align: center;
}

.cacm-portal__submitted-at {
	font-size: 0.9em;
	color: #666;
}

/* Status states */
.cacm-portal--suspended,
.cacm-portal--rejected {
	text-align: center;
	color: #666;
}

/* Dashboard — wider for balance cards */
.cacm-portal--dashboard {
	max-width: 680px;
}

/* Balance grid — four cards, consistent height + alignment regardless of
   label length. Cards are flex columns so the value sits at the same
   vertical position whether the label wraps or not. min-height pins them
   so the active-card highlight doesn't reflow others.
   Explicit 4-up at desktop (rather than auto-fit) so PENDING never
   orphans onto its own row at common portal widths; 2-up at <540px. */
.cacm-balance-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin: 16px 0;
}

@media (max-width: 540px) {
	.cacm-balance-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

.cacm-balance-card {
	background: #f8f8f8;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	padding: 14px 12px;
	text-align: center;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	min-height: 92px;
	box-sizing: border-box;
}

.cacm-balance-card--available {
	background: #1a1a2e;
	border-color: #d4a843;
}

.cacm-balance-card__label {
	display: block;
	font-size: 0.78em;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #5a5a5a;
	margin: 0 0 6px 0;
	line-height: 1.15;
	white-space: nowrap;
	font-weight: 600;
}

.cacm-balance-card--available .cacm-balance-card__label {
	color: rgba(212, 168, 67, 0.85);
}

.cacm-balance-card__value {
	display: block;
	font-size: 1.55em;
	font-weight: 700;
	color: #1a1a2e;
	line-height: 1.1;
	margin: 0;
}

.cacm-balance-card--available .cacm-balance-card__value {
	color: #d4a843;
}

.cacm-dashboard__order-count {
	font-size: 0.85em;
	color: #888;
	margin-top: 8px;
}

/* Active coupon card */
.cacm-coupon-card {
	background: #f5f5f5;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	padding: 20px;
	margin: 12px 0;
}

.cacm-coupon-card__code code {
	font-size: 1.3em;
	background: #1a1a2e;
	color: #d4a843;
	padding: 6px 14px;
	border-radius: 4px;
	display: inline-block;
	letter-spacing: 1px;
}

.cacm-coupon-card__details {
	margin-top: 12px;
}

.cacm-coupon-card__amount {
	font-size: 1.2em;
	font-weight: 700;
	color: #1a1a2e;
	margin-right: 12px;
}

.cacm-coupon-card__status {
	font-size: 0.85em;
	color: #666;
}

.cacm-coupon-card__status--generated { color: #2e7d32; }
.cacm-coupon-card__status--used_pending { color: #e65100; }

.cacm-coupon-card__hint {
	font-size: 0.85em;
	color: #666;
	margin: 10px 0 4px;
}

.cacm-coupon-card__cancel {
	margin-top: 12px;
}

/* Small + danger button variants */
.cacm-btn--small {
	padding: 6px 14px;
	font-size: 12px;
}

.cacm-btn--danger {
	background: #c62828;
	color: #fff;
}

.cacm-btn--danger:hover {
	background: #b71c1c;
}

/* Inline form field (amount + button) */
.cacm-form__field--inline {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.cacm-form__field--inline label {
	margin-bottom: 0;
}

.cacm-form__input--short {
	width: 120px;
	max-width: 120px;
}

.cacm-form__help {
	font-size: 0.85em;
	color: #888;
	margin-top: 6px;
}

/* Redemption history table */
.cacm-table {
	width: 100%;
	border-collapse: collapse;
	margin: 12px 0;
	font-size: 0.9em;
}

.cacm-table th {
	text-align: left;
	padding: 8px 10px;
	background: #f0f0f1;
	border-bottom: 2px solid #ddd;
	font-weight: 600;
	color: #50575e;
	font-size: 0.85em;
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

/* Explicit dark text — themes (Neve dark mode) inherit white otherwise,
   producing white-on-white inside the white portal card. */
.cacm-table td {
	padding: 8px 10px;
	border-bottom: 1px solid #f0f0f1;
	color: #1d2327;
	background: transparent;
}

.cacm-table code {
	font-size: 0.9em;
	background: #f0f0f1;
	color: #1d2327;
	padding: 2px 6px;
	border-radius: 3px;
}

/* Status badges — every status the redemption state machine can produce
   needs a colour rule, otherwise the badge inherits the page's text colour
   (white on dark themes) and disappears on white cards. */
.cacm-status {
	font-size: 0.85em;
	font-weight: 600;
}

.cacm-status--pending_creation { color: #6c757d; }
.cacm-status--generated        { color: #2e7d32; }
.cacm-status--used_pending     { color: #e65100; }
.cacm-status--completed        { color: #1565c0; }
.cacm-status--cancelled        { color: #6e6e6e; }
.cacm-status--failed           { color: #c62828; font-weight: 700; }

/* Muted text */
.cacm-text--muted {
	color: #888;
	font-style: italic;
}

/* Dashboard section spacing */
.cacm-dashboard__balance,
.cacm-dashboard__active-coupon,
.cacm-dashboard__redeem,
.cacm-dashboard__first-confirm,
.cacm-dashboard__no-balance,
.cacm-dashboard__history {
	margin-bottom: 28px;
}

/* Responsive */
@media (max-width: 480px) {
	.cacm-balance-grid {
		grid-template-columns: 1fr 1fr;
	}
	.cacm-form__field--inline {
		flex-direction: column;
		align-items: stretch;
	}
	.cacm-form__input--short {
		width: 100%;
		max-width: 100%;
	}
}
