/**
 * SF Client Portal - frontend styles.
 * Mobile-first, RTL, editorial look: wide whitespace, big Arabic type,
 * peach background accents and orange details.
 */

.sf-portal {
	--sf-radius: 14px;
	font-family: var( --sf-font, system-ui, sans-serif );
	color: var( --sf-text, #141414 );
	max-width: 720px;
	margin: 0 auto;
	padding: 24px 16px 64px;
	line-height: 1.7;
	-webkit-font-smoothing: antialiased;
}

.sf-portal *,
.sf-portal *::before,
.sf-portal *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Buttons, inputs, links                                              */
/* ------------------------------------------------------------------ */

.sf-btn {
	font-family: inherit;
	font-size: 16px;
	font-weight: 700;
	border: 0;
	border-radius: var( --sf-radius );
	padding: 14px 22px;
	cursor: pointer;
	transition: transform 0.08s ease, opacity 0.15s ease;
}

.sf-btn:active {
	transform: scale( 0.98 );
}

.sf-btn--primary {
	background: var( --sf-primary, #ff4d00 );
	color: #fff;
}

.sf-btn--ghost {
	background: transparent;
	color: var( --sf-primary, #ff4d00 );
	border: 2px solid var( --sf-primary, #ff4d00 );
}

.sf-btn--whatsapp {
	display: inline-block;
	background: #25d366;
	color: #fff;
	text-decoration: none;
	margin-top: 12px;
}

.sf-btn--block {
	display: block;
	width: 100%;
}

.sf-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

.sf-btn--loading {
	position: relative;
	color: transparent !important;
}

.sf-btn--loading::after {
	content: '';
	position: absolute;
	inset: 0;
	margin: auto;
	width: 20px;
	height: 20px;
	border: 3px solid rgba( 255, 255, 255, 0.4 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: sf-spin 0.7s linear infinite;
}

.sf-link {
	background: none;
	border: 0;
	font-family: inherit;
	font-size: 15px;
	color: var( --sf-primary, #ff4d00 );
	cursor: pointer;
	padding: 6px 2px;
	text-decoration: underline;
	text-underline-offset: 4px;
}

.sf-link:disabled {
	color: #9a9a9a;
	text-decoration: none;
	cursor: default;
}

.sf-input {
	width: 100%;
	font-family: inherit;
	font-size: 18px;
	padding: 14px 16px;
	border: 2px solid #e5d5cc;
	border-radius: var( --sf-radius );
	background: #fff;
	color: var( --sf-text, #141414 );
	margin-bottom: 16px;
	outline: none;
	transition: border-color 0.15s ease;
}

.sf-input:focus {
	border-color: var( --sf-primary, #ff4d00 );
}

.sf-input--phone {
	text-align: left;
	letter-spacing: 2px;
}

.sf-label {
	display: block;
	font-weight: 700;
	margin-bottom: 8px;
}

/* ------------------------------------------------------------------ */
/* Alerts                                                              */
/* ------------------------------------------------------------------ */

.sf-alert {
	border-radius: var( --sf-radius );
	padding: 12px 16px;
	margin: 12px 0;
	font-size: 15px;
}

.sf-alert--error {
	background: #fdecea;
	color: #b3261e;
}

.sf-alert--success {
	background: #e6f4ea;
	color: #1e7e34;
}

/* ------------------------------------------------------------------ */
/* Auth screens                                                        */
/* ------------------------------------------------------------------ */

.sf-auth {
	background: var( --sf-bg, #fdd8c6 );
	border-radius: calc( var( --sf-radius ) * 1.6 );
	padding: 40px 24px;
	margin-top: 24px;
	text-align: center;
}

.sf-auth-title {
	font-size: 32px;
	font-weight: 900;
	margin: 0 0 8px;
	color: var( --sf-text, #141414 );
}

.sf-auth-sub {
	color: #5a4a42;
	margin: 0 0 20px;
}

.sf-auth-form {
	max-width: 360px;
	margin: 0 auto;
	text-align: right;
}

/* OTP boxes */

.sf-otp-row {
	display: flex;
	justify-content: center;
	gap: 10px;
	margin: 20px 0 24px;
}

.sf-otp-box {
	width: 56px;
	height: 64px;
	font-family: inherit;
	font-size: 28px;
	font-weight: 700;
	text-align: center;
	border: 2px solid #e5d5cc;
	border-radius: var( --sf-radius );
	background: #fff;
	outline: none;
}

.sf-otp-box:focus {
	border-color: var( --sf-primary, #ff4d00 );
}

.sf-otp-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px 18px;
	margin-top: 18px;
}

.sf-auth .sf-btn--block {
	max-width: 360px;
	margin: 0 auto;
}

/* ------------------------------------------------------------------ */
/* Home                                                                */
/* ------------------------------------------------------------------ */

.sf-home-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 20px;
}

.sf-hello {
	margin: 0;
	color: var( --sf-primary, #ff4d00 );
	font-weight: 700;
}

.sf-client-name {
	margin: 0;
	font-size: 30px;
	font-weight: 900;
}

.sf-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 18px;
	border-bottom: 2px solid #f0e2d9;
}

.sf-tab {
	background: none;
	border: 0;
	font-family: inherit;
	font-size: 17px;
	font-weight: 700;
	color: #8a7a72;
	padding: 10px 14px;
	cursor: pointer;
	border-bottom: 3px solid transparent;
	margin-bottom: -2px;
}

.sf-tab--active {
	color: var( --sf-text, #141414 );
	border-bottom-color: var( --sf-primary, #ff4d00 );
}

.sf-tab-count {
	display: inline-block;
	background: var( --sf-bg, #fdd8c6 );
	color: var( --sf-primary, #ff4d00 );
	border-radius: 20px;
	font-size: 13px;
	padding: 0 8px;
	margin-inline-start: 4px;
}

.sf-doc-list {
	display: grid;
	gap: 14px;
}

.sf-card {
	background: #fff;
	border: 1px solid #f0e2d9;
	border-radius: var( --sf-radius );
	padding: 18px;
}

.sf-doc-card {
	display: block;
	width: 100%;
	text-align: right;
	font-family: inherit;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sf-doc-card:hover {
	border-color: var( --sf-primary, #ff4d00 );
	box-shadow: 0 4px 18px rgba( 255, 77, 0, 0.08 );
}

.sf-doc-top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 6px;
}

.sf-doc-number {
	font-weight: 700;
	color: var( --sf-primary, #ff4d00 );
}

.sf-doc-title {
	display: block;
	font-size: 19px;
	font-weight: 900;
	color: var( --sf-text, #141414 );
	margin-bottom: 8px;
}

.sf-doc-meta {
	display: flex;
	justify-content: space-between;
	color: #8a7a72;
	font-size: 14px;
}

.sf-doc-amount {
	font-weight: 700;
	color: var( --sf-text, #141414 );
}

.sf-empty {
	text-align: center;
	color: #8a7a72;
	padding: 40px 0;
}

/* Status badges */

.sf-badge {
	display: inline-block;
	font-size: 13px;
	font-weight: 700;
	border-radius: 20px;
	padding: 3px 12px;
	white-space: nowrap;
}

.sf-badge--draft { background: #eee; color: #666; }
.sf-badge--sent { background: #e8f0fe; color: #1a56db; }
.sf-badge--viewed { background: #fef3e2; color: #b45309; }
.sf-badge--approved,
.sf-badge--paid { background: #e6f4ea; color: #1e7e34; }
.sf-badge--expired,
.sf-badge--cancelled { background: #f3f4f6; color: #6b7280; }
.sf-badge--declined { background: #fdecea; color: #b3261e; }
.sf-badge--unpaid { background: #fdecea; color: #b3261e; }
.sf-badge--partially_paid { background: #fef3e2; color: #b45309; }

/* ------------------------------------------------------------------ */
/* Document view                                                       */
/* ------------------------------------------------------------------ */

.sf-doc-head {
	margin-bottom: 10px;
}

.sf-back {
	margin-bottom: 12px;
	display: inline-block;
}

.sf-doc-head-row {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
}

.sf-doc-kicker {
	margin: 0;
	color: var( --sf-primary, #ff4d00 );
	font-weight: 700;
}

.sf-doc-big-title {
	margin: 2px 0 6px;
	font-size: 28px;
	font-weight: 900;
	line-height: 1.35;
}

.sf-doc-dates {
	color: #8a7a72;
	font-size: 14px;
	margin: 4px 0 0;
}

.sf-section {
	margin-top: 28px;
}

.sf-section-title {
	font-size: 20px;
	font-weight: 900;
	color: var( --sf-primary, #ff4d00 );
	margin: 0 0 12px;
}

.sf-items-table {
	width: 100%;
	border-collapse: collapse;
	background: #fff;
	border-radius: var( --sf-radius );
	overflow: hidden;
}

.sf-items-table th {
	text-align: right;
	font-size: 13px;
	color: var( --sf-primary, #ff4d00 );
	border-bottom: 2px solid var( --sf-primary, #ff4d00 );
	padding: 12px 14px;
}

.sf-items-table td {
	border-bottom: 1px solid #f0e2d9;
	padding: 14px;
	vertical-align: top;
}

.sf-item-desc {
	color: #8a7a72;
	font-size: 14px;
	font-weight: 400;
	margin-top: 4px;
	white-space: pre-line;
}

.sf-item-days {
	white-space: nowrap;
	color: #5a4a42;
	font-size: 14px;
}

.sf-item-cost {
	white-space: nowrap;
	font-weight: 700;
}

.sf-items-table tfoot td {
	border-bottom: 0;
	font-weight: 900;
	font-size: 17px;
}

.sf-total-cell {
	color: var( --sf-primary, #ff4d00 );
}

.sf-amount-text {
	background: var( --sf-bg, #fdd8c6 );
	border-radius: var( --sf-radius );
	padding: 12px 16px;
	font-size: 15px;
	margin-top: 12px;
}

.sf-pay-box,
.sf-bank-box {
	background: #fff;
	border: 1px solid #f0e2d9;
	border-radius: var( --sf-radius );
	padding: 8px 16px;
}

.sf-pay-row,
.sf-bank-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid #f7ede6;
}

.sf-pay-row:last-child,
.sf-bank-row:last-child {
	border-bottom: 0;
}

.sf-bank-box .sf-btn {
	margin: 10px 0 12px;
}

.sf-term {
	background: #fff;
	border: 1px solid #f0e2d9;
	border-radius: var( --sf-radius );
	margin-bottom: 10px;
	padding: 4px 16px;
}

.sf-term-title {
	font-weight: 700;
	cursor: pointer;
	padding: 10px 0;
	color: var( --sf-text, #141414 );
}

.sf-term-body {
	padding: 0 0 14px;
	color: #5a4a42;
	line-height: 1.9;
}

.sf-doc-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 32px;
	align-items: center;
}

.sf-expired-note {
	color: #b3261e;
	font-size: 14px;
}

/* Approve modal */

.sf-modal {
	position: fixed;
	inset: 0;
	background: rgba( 20, 20, 20, 0.55 );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	z-index: 99999;
}

.sf-modal[hidden] {
	display: none;
}

.sf-modal-card {
	background: #fff;
	border-radius: calc( var( --sf-radius ) * 1.4 );
	padding: 28px 24px;
	max-width: 420px;
	width: 100%;
}

.sf-modal-title {
	margin: 0 0 16px;
	font-size: 20px;
	font-weight: 900;
}

.sf-check {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	cursor: pointer;
	margin-bottom: 16px;
}

.sf-check input {
	width: 20px;
	height: 20px;
	margin-top: 4px;
	accent-color: var( --sf-primary, #ff4d00 );
}

.sf-modal-actions {
	display: flex;
	gap: 10px;
}

/* ------------------------------------------------------------------ */
/* Skeletons & spinner                                                 */
/* ------------------------------------------------------------------ */

.sf-portal-boot {
	display: flex;
	justify-content: center;
	padding: 60px 0;
}

.sf-spinner {
	width: 34px;
	height: 34px;
	border: 4px solid #f0e2d9;
	border-top-color: var( --sf-primary, #ff4d00 );
	border-radius: 50%;
	display: inline-block;
	animation: sf-spin 0.7s linear infinite;
}

@keyframes sf-spin {
	to { transform: rotate( 360deg ); }
}

.sf-skeleton {
	pointer-events: none;
}

.sf-skel-line {
	height: 14px;
	border-radius: 7px;
	background: linear-gradient( 90deg, #f3e7de 25%, #faf2ec 50%, #f3e7de 75% );
	background-size: 200% 100%;
	animation: sf-shimmer 1.2s infinite;
	margin: 10px 0;
	width: 60%;
}

.sf-skel-line--wide { width: 90%; }
.sf-skel-line--short { width: 35%; }

@keyframes sf-shimmer {
	to { background-position: -200% 0; }
}

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */

.sf-portal-footer {
	margin-top: 40px;
	padding-top: 20px;
	border-top: 1px solid #f0e2d9;
	color: #8a7a72;
	font-size: 13px;
	text-align: center;
	white-space: pre-line;
}

/* ------------------------------------------------------------------ */
/* Larger screens                                                      */
/* ------------------------------------------------------------------ */

@media ( min-width: 640px ) {
	.sf-portal {
		padding: 40px 24px 80px;
	}

	.sf-auth {
		padding: 56px 40px;
	}

	.sf-doc-big-title {
		font-size: 34px;
	}

	.sf-client-name {
		font-size: 36px;
	}
}

/* ------------------------------------------------------------------ */
/* Print                                                               */
/* ------------------------------------------------------------------ */

@media print {
	.sf-doc-actions,
	.sf-back,
	.sf-modal,
	.sf-portal-footer,
	.sf-print-btn {
		display: none !important;
	}

	.sf-portal {
		max-width: none;
		padding: 0;
	}

	.sf-card,
	.sf-items-table,
	.sf-pay-box,
	.sf-bank-box,
	.sf-term {
		border-color: #ccc;
	}

	.sf-term {
		break-inside: avoid;
	}

	.sf-term:not([open]) .sf-term-body {
		display: block;
	}
}
