/* ── Shared Components ───────────────────────────────────────
   UI components reused across multiple pages: page cards,
   buttons, forms, tables, flash messages, modals, etc.
   ─────────────────────────────────────────────────────────── */

/* ── Your Project badge ── */

.your-project-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 8px;
	background: rgba(59, 130, 246, 0.1);
	border: 1px solid rgba(59, 130, 246, 0.3);
	border-radius: var(--radius-pill, 999px);
	font-size: 11px;
	font-weight: 600;
	color: #3b82f6;
	vertical-align: middle;
	white-space: nowrap;
}

/* ── Page card (base content container) ── */

.page-card {
	width: 100%;
	max-width: 100%;
	background: #ffffff;
	border-radius: var(--radius-lg);
	border: 1px solid var(--border);
	padding: 28px 30px;
	box-shadow: var(--shadow-md);
	animation: card-in 320ms ease-out;
}

body[data-turbo-preview] .page-card {
	animation: none;
}

.page-card h1 {
	margin: 8px 0 12px;
	font-size: 28px;
	color: var(--blue-900);
}

.page-card p {
	margin: 0;
	color: #334155;
	line-height: 1.6;
}

.page-kicker {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--blue-600);
}

.page-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 18px;
	flex-wrap: wrap;
	margin-bottom: 18px;
}

.page-header p {
	margin-top: 6px;
}

/* ── Buttons ── */

.button-primary,
.button-secondary,
.button-danger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-md);
	font-weight: 600;
	text-decoration: none;
	padding: 10px 16px;
	transition: transform 120ms ease, box-shadow 120ms ease, background 150ms ease, color 150ms ease;
}

.button-primary {
	background: var(--blue-600);
	color: #ffffff;
	box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
	border: none;
}

.button-primary:hover {
	background: var(--blue-700);
	transform: translateY(-1px);
}

.button-secondary {
	background: #ffffff;
	color: var(--blue-700);
	border: 1px solid var(--blue-200);
}

.button-secondary:hover {
	border-color: var(--blue-500);
	box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.button-danger {
	background: var(--red-500);
	color: #ffffff;
	border: none;
	box-shadow: 0 12px 24px rgba(239, 68, 68, 0.2);
}

.button-danger:hover {
	background: #dc2626;
	transform: translateY(-1px);
}

/* ── Flash messages ── */

.flash-stack {
	display: grid;
	gap: 10px;
	margin-bottom: 16px;
}

.flash-message {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: #f8fafc;
	color: var(--ink);
	font-size: 14px;
}

.flash-message.is-alert,
.flash-message.is-error {
	background: #fff1f2;
	border-color: #fecdd3;
	color: #9f1239;
}

.flash-message.is-notice {
	background: #ecfeff;
	border-color: #a5f3fc;
	color: #0e7490;
}

/* ── Data tables ── */

.table-card {
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	overflow: hidden;
	background: #ffffff;
}

.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.data-table thead {
	background: var(--blue-50);
}

.data-table th,
.data-table td {
	text-align: left;
	padding: 12px 16px;
	border-bottom: 1px solid var(--blue-100);
}

.data-table th {
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--blue-700);
}

.data-table tbody tr:hover {
	background: #f8fbff;
}

.data-table th.col-actions,
.data-table td.col-actions {
	text-align: right;
}

.data-table td.col-actions .inline-actions {
	justify-content: flex-end;
}

/* ── Status pills ── */

.status-pill {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: var(--radius-pill);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border: 1px solid transparent;
}

.status-pill.is-active {
	background: #ecfdf3;
	border-color: #bbf7d0;
	color: #166534;
}

.status-pill.is-inactive {
	background: #fff1f2;
	border-color: #fecdd3;
	color: #9f1239;
}

/* ── Action groups ── */

.table-actions,
.detail-actions,
.form-actions,
.inline-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

.form-actions--end {
	justify-content: flex-end;
}

.inline-actions form {
	margin: 0;
}

.inline-actions .button_to,
.inline-actions form {
	display: inline-flex;
}

/* ── Empty states ── */

.empty-state {
	margin: 12px 0 0;
	padding: 16px 18px;
	border-radius: var(--radius-md);
	background: var(--surface);
	border: 1px solid #e8e5e0;
	color: var(--ink-soft);
	font-weight: 500;
}

/* ── Forms ── */

.form-stack {
	display: grid;
	gap: 18px;
}

.form-field {
	display: grid;
	gap: 8px;
}

.form-field label {
	font-size: 14px;
	font-weight: 600;
	color: var(--blue-900);
}

.form-hint {
	font-size: 12px;
	color: #64748b;
	margin: 0;
}

.form-field input[type="text"],
.form-field input[type="number"] {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: var(--blue-50);
	font-size: 14px;
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.form-field input[type="time"] {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: var(--blue-50);
	font-size: 14px;
	height: 48px;
	box-sizing: border-box;
	width: 100%;
}

.form-field input[type="time"]:focus {
	outline: none;
	border-color: var(--blue-500);
	box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
	background: #ffffff;
}

.form-field select {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: var(--blue-50);
	font-size: 14px;
}

.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus {
	outline: none;
	border-color: var(--blue-500);
	box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
	background: #ffffff;
}

.form-field select:focus {
	outline: none;
	border-color: var(--blue-500);
	box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
	background: #ffffff;
}

.form-field textarea {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: var(--blue-50);
	font-size: 14px;
	font-family: inherit;
	resize: vertical;
	line-height: 1.5;
}

.form-field textarea:focus {
	outline: none;
	border-color: var(--blue-500);
	box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
	background: #ffffff;
}

.select-wrapper {
	position: relative;
	display: block;
}

.select-wrapper select {
	appearance: none;
	-webkit-appearance: none;
	padding-right: 36px;
	width: 100%;
}

.select-wrapper::after {
	content: "";
	position: absolute;
	right: 10px;
	top: 50%;
	width: 16px;
	height: 16px;
	transform: translateY(-50%) rotate(0deg);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	pointer-events: none;
	transition: transform 200ms ease;
}

.select-wrapper:focus-within::after {
	transform: translateY(-50%) rotate(180deg);
}

.form-error {
	font-size: 12px;
	color: #b91c1c;
}

/* ── Status checkbox pills ── */

.status-checkbox-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 4px;
}

.status-checkbox {
	cursor: pointer;
}

.status-checkbox input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.status-checkbox__label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 14px 5px 10px;
	border: 1.5px solid var(--border);
	border-radius: 20px;
	font-size: 13px;
	font-weight: 500;
	color: #475569;
	background: #f8fafc;
	transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
	user-select: none;
}

.status-checkbox__label::before {
	content: "";
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 1.5px solid #cbd5e1;
	border-radius: 4px;
	background: white;
	flex-shrink: 0;
	transition: background 120ms ease, border-color 120ms ease;
}

.status-checkbox:has(input:checked) .status-checkbox__label {
	background: var(--blue-50);
	border-color: var(--blue-400);
	color: var(--blue-900);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue-400) 20%, transparent);
}

.status-checkbox:has(input:checked) .status-checkbox__label::before {
	background: var(--blue-500);
	border-color: var(--blue-500);
	background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 10px 8px;
}

.status-checkbox.is-mapped {
	cursor: not-allowed;
	pointer-events: none;
}

.status-checkbox.is-mapped .status-checkbox__label {
	background: #f1f5f9;
	border-color: #e2e8f0;
	color: #94a3b8;
	box-shadow: none;
}

.status-checkbox.is-mapped .status-checkbox__label::before {
	background: #e2e8f0;
	border-color: #cbd5e1;
	background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 10px 8px;
}

.status-checkbox.is-mapped .status-checkbox__label::after {
	content: "already set";
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #94a3b8;
	margin-left: 4px;
}

/* ── Conflict rule summary ── */

.conflict-rule-summary {
	display: flex;
	align-items: center;
	gap: 16px;
	background: var(--blue-50);
	border: 1px solid var(--blue-200);
	border-radius: var(--radius-md);
	padding: 14px 18px;
	margin-bottom: 24px;
}

.conflict-rule-summary__item {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.conflict-rule-summary__label {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--blue-500);
}

.conflict-rule-summary__value {
	font-size: 15px;
	font-weight: 600;
	color: var(--blue-900);
}

.conflict-rule-summary__arrow {
	font-size: 18px;
	color: var(--blue-400);
	flex-shrink: 0;
}

/* ── Color picker (conflict rules) ── */

.color-picker-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 4px;
}

.conflict-color-input {
	width: 48px;
	height: 36px;
	padding: 2px;
	border: 1.5px solid var(--border);
	border-radius: 8px;
	background: white;
	cursor: pointer;
}

.conflict-color-input:focus {
	outline: none;
	border-color: var(--blue-400);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue-400) 20%, transparent);
}

.color-picker-hint {
	font-size: 12px;
	color: #64748b;
}

/* ── Color swatch (table display) ── */

.color-swatch {
	display: inline-block;
	width: 20px;
	height: 20px;
	border-radius: 6px;
	border: 1px solid rgba(0,0,0,0.1);
	vertical-align: middle;
}

/* ── Color picker (swatch grid for project color selection) ── */

.color-picker {
	border: none;
	border-collapse: separate;
	border-spacing: 0;
	background: transparent;
}

.color-picker__cell {
	padding: 8px 10px;
	border: none;
	background: transparent;
	width: 48px;
	height: 48px;
	text-align: center;
	vertical-align: middle;
}

.color-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.color-swatch__input {
	display: none;
}

.color-swatch__dot {
	display: block;
	width: 28px;
	min-width: 28px;
	height: 28px;
	flex-shrink: 0;
	border-radius: 50%;
	border: 2px solid transparent;
	transition: transform 100ms, outline 100ms;
	outline: 3px solid transparent;
	outline-offset: 2px;
	box-sizing: content-box;
}

.color-swatch__input:checked + .color-swatch__dot {
	outline-color: var(--blue-500);
	transform: scale(1.15);
}

/* ── Project color scheme dot ── */

.scheme-dot {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	flex-shrink: 0;
}

.scheme-dot--lg {
	width: 20px;
	height: 20px;
}

/* ── Config grid (Configurations index) ── */

.config-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	margin-top: 20px;
}

.config-card {
	flex: 1 1 calc((100% - 64px) / 5);
	max-width: calc((100% - 64px) / 5);
	min-width: 160px;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 16px;
	background: #ffffff;
	text-decoration: none;
	color: inherit;
	box-shadow: var(--shadow-sm);
	transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.config-card:hover {
	transform: translateY(-2px);
	border-color: var(--blue-300);
	box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
}

.config-title {
	display: block;
	font-weight: 600;
	color: var(--blue-900);
	margin-bottom: 6px;
}

.config-meta {
	font-size: 13px;
	color: var(--blue-700);
}

/* ── Detail views ── */

.detail-name {
	margin: 8px 0 18px;
	font-size: 18px;
	font-weight: 600;
}

.detail-row {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
}

.detail-description {
	margin: 0 0 12px;
	color: var(--blue-700);
	font-size: 14px;
	line-height: 1.6;
}

.text-muted {
	color: #64748b;
}

/* ── Settings section ── */

.settings-section {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 24px;
	box-shadow: var(--shadow-sm);
	animation: card-in 320ms ease-out;
}

.settings-section h2 {
	margin: 0 0 18px;
	font-size: 20px;
	font-weight: 600;
	color: var(--blue-900);
}

/* ── Payslip layout ── */

.pay-period-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.net-salary-display {
	font-size: 2rem;
	font-weight: 700;
	color: var(--blue-900);
	margin-top: 8px;
}

.page-card,
.payslip-layout {
	margin-bottom: 24px;
}

.payslip-layout {
	display: grid;
	grid-template-columns: 3fr 7fr;
	gap: 24px;
	align-items: start;
}

.payslip-column {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.payslip-actions {
	grid-column: 1 / -1;
	display: flex;
	justify-content: flex-end;
}

#payslip_save_form {
	grid-column: 1 / -1;
}

@media (max-width: 900px) {
	.payslip-layout {
		grid-template-columns: 1fr;
	}
}

/* ── Date range field ── */

.date-range-inputs {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.date-range-sep {
	font-size: 13px;
	color: var(--blue-500);
}

/* ── Breakdown table ── */

.breakdown-table th,
.breakdown-table td {
	text-align: center;
}

.breakdown-table input {
	text-align: center;
}

.breakdown-total-row {
	font-weight: 600;
	background: var(--blue-50);
}

.breakdown-spacer-row td {
	padding: 8px;
	border-bottom: none;
	background: var(--surface);
}

.breakdown-grand-total-row {
	font-weight: 600;
	background: var(--blue-100);
}

.breakdown-table tbody tr.breakdown-grand-total-row:hover {
	background: var(--blue-100);
}

.breakdown-grand-total-pay {
	background: #6b7280;
	color: #ffffff;
}

.breakdown-grand-total-final-pay {
	background: #000000;
	color: #ffffff;
}

.breakdown-table td.breakdown-grand-total-label-closing {
	border-left: 2px solid var(--blue-300);
	border-bottom: 2px solid var(--blue-300);
}

.breakdown-table td.breakdown-grand-total-label {
	border-top: 2px solid var(--blue-300);
	border-left: 2px solid var(--blue-300);
	border-bottom: 2px solid var(--blue-300);
}

.breakdown-table td.breakdown-grand-total-top {
	border-top: 2px solid var(--blue-300);
}

.breakdown-table td.breakdown-grand-total-bottom {
	border-bottom: 2px solid var(--blue-300);
}

.breakdown-table td.breakdown-grand-total-right {
	border-right: 2px solid var(--blue-300);
}

.breakdown-table th.breakdown-col-regular,
.breakdown-table td.breakdown-col-regular {
	background: #dcfce7;
}

.breakdown-table th.breakdown-col-ot,
.breakdown-table td.breakdown-col-ot {
	background: #ffedd5;
}

.settings-grid {
	display: grid;
	gap: 14px;
}

.settings-row {
	display: grid;
	grid-template-columns: 180px 1fr;
	align-items: center;
	gap: 14px;
}

.settings-label {
	font-size: 14px;
	font-weight: 600;
	color: var(--blue-700);
}

.settings-value {
	padding: 12px 14px;
	border-radius: var(--radius-md);
	border: 1px solid var(--blue-200);
	background: var(--blue-50);
	font-size: 14px;
	color: var(--ink);
	transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.settings-value:hover {
	border-color: var(--blue-500);
	background: #ffffff;
	box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.account-summary {
	margin-bottom: 18px;
}

/* ── Manual / Info modal ── */

.manual-trigger {
	position: fixed;
	bottom: 28px;
	right: 28px;
	z-index: 900;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 2px solid var(--blue-600);
	background: #fff;
	color: var(--blue-600);
	font-family: Georgia, "Times New Roman", serif;
	font-size: 18px;
	font-weight: 700;
	font-style: italic;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 12px rgba(37, 99, 235, 0.18);
	transition: background 150ms, color 150ms, box-shadow 150ms, transform 150ms;
}

.manual-trigger:hover {
	background: var(--blue-600);
	color: #fff;
	box-shadow: 0 4px 20px rgba(37, 99, 235, 0.32);
	transform: scale(1.08);
}

.manual-trigger:focus-visible {
	outline: 3px solid var(--blue-300);
	outline-offset: 2px;
}

.manual-overlay {
	position: fixed;
	inset: 0;
	z-index: 1000;
	background: rgba(15, 23, 42, 0.5);
	backdrop-filter: blur(2px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease;
}

.manual-overlay--visible {
	opacity: 1;
	pointer-events: auto;
}

.manual-modal {
	background: #fff;
	border-radius: var(--radius-lg);
	box-shadow: 0 32px 80px rgba(15, 23, 42, 0.22);
	width: 100%;
	max-width: 640px;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform: translateY(12px) scale(0.98);
	transition: transform 200ms ease;
}

.manual-overlay--visible .manual-modal {
	transform: translateY(0) scale(1);
}

.manual-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.manual-modal__title {
	margin: 0;
	font-size: 19px;
	font-weight: 700;
	color: var(--blue-900);
	letter-spacing: 0.01em;
}

.manual-modal__close {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: #f1f5f9;
	color: #64748b;
	font-size: 14px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 140ms, color 140ms;
	flex-shrink: 0;
}

.manual-modal__close:hover {
	background: #e2e8f0;
	color: #0f172a;
}

.manual-modal__body {
	overflow-y: auto;
	padding: 8px 0 24px;
	scroll-behavior: smooth;
}

.manual-section {
	display: flex;
	gap: 14px;
	padding: 18px 24px;
	border-bottom: 1px solid #f1f5f9;
}

.manual-section:last-child {
	border-bottom: none;
}

.manual-section__icon {
	font-size: 22px;
	line-height: 1.4;
	flex-shrink: 0;
	width: 28px;
	text-align: center;
}

.manual-section__content {
	flex: 1;
	min-width: 0;
}

.manual-section__title {
	margin: 0 0 8px;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--blue-700);
}

.manual-section__content p {
	margin: 0 0 8px;
	font-size: 14px;
	line-height: 1.65;
	color: #334155;
}

.manual-section__content p:last-child {
	margin-bottom: 0;
}

.manual-list {
	margin: 0 0 8px;
	padding-left: 18px;
	font-size: 14px;
	line-height: 1.65;
	color: #334155;
}

.manual-list li {
	margin-bottom: 5px;
}

.manual-list li:last-child {
	margin-bottom: 0;
}

.manual-list a {
	color: var(--blue-600);
	font-weight: 600;
	text-decoration: none;
}

.manual-list a:hover {
	text-decoration: underline;
}

.manual-note {
	font-size: 13px;
	color: #64748b;
	font-style: italic;
}

.manual-pulse-legend {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 10px 0;
}

.manual-pulse-legend__item {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 14px;
	color: #334155;
	line-height: 1.5;
}

.manual-pulse-legend__dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--dot);
	flex-shrink: 0;
	margin-top: 5px;
}

/* ── Responsive ── */

@media (max-width: 640px) {
	.settings-row {
		grid-template-columns: 1fr;
		gap: 6px;
	}

	.settings-label {
		font-size: 13px;
	}
}
