/**
 * HDL Support System – Customer Portal
 * Premium, calm, trust-building experience
 */

:root {
	--portal-primary: #4f46e5;
	--portal-primary-hover: #4338ca;
	--portal-primary-soft: #eef2ff;
	--portal-success: #059669;
	--portal-warning: #d97706;
	--portal-danger: #dc2626;

	--portal-bg: #f8fafc;
	--portal-surface: #ffffff;
	--portal-border: #e2e8f0;
	--portal-text: #0f172a;
	--portal-text-secondary: #475569;
	--portal-text-muted: #94a3b8;

	--portal-radius: 12px;
	--portal-radius-sm: 8px;
	--portal-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
	--portal-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
	--portal-shadow-lg: 0 10px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);

	--portal-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== Base ========== */

.hdl-portal {
	font-family: var(--portal-font);
	background: var(--portal-bg);
	color: var(--portal-text);
	min-height: 100vh;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

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

/* ========== Header ========== */

.hdl-portal-header {
	background: var(--portal-surface);
	border-bottom: 1px solid var(--portal-border);
	position: sticky;
	top: 0;
	z-index: 100;
	backdrop-filter: blur(8px);
	background: rgba(255, 255, 255, 0.92);
}

.hdl-portal-header-inner {
	max-width: 1100px;
	margin: 0 auto;
	padding: 0 24px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.hdl-portal-logo {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	font-size: 1.15rem;
	color: var(--portal-text);
	text-decoration: none;
}

.hdl-portal-logo img {
	height: 32px;
	width: auto;
}

.hdl-portal-nav {
	display: flex;
	align-items: center;
	gap: 8px;
}

.hdl-portal-nav a {
	padding: 8px 14px;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--portal-text-secondary);
	text-decoration: none;
	border-radius: var(--portal-radius-sm);
	transition: all 0.15s;
}

.hdl-portal-nav a:hover,
.hdl-portal-nav a.is-active {
	color: var(--portal-primary);
	background: var(--portal-primary-soft);
}

.hdl-portal-user {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-left: 12px;
	padding-left: 16px;
	border-left: 1px solid var(--portal-border);
}

.hdl-portal-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--portal-primary-soft);
	color: var(--portal-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 0.85rem;
}

/* ========== Main Content ========== */

.hdl-portal-main {
	max-width: 1100px;
	margin: 0 auto;
	padding: 32px 24px 60px;
}

.hdl-portal-page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 28px;
	flex-wrap: wrap;
	gap: 16px;
}

.hdl-portal-page-header h1 {
	font-size: 1.75rem;
	font-weight: 700;
	letter-spacing: -0.03em;
	margin: 0;
	color: var(--portal-text);
}

.hdl-portal-page-header p {
	margin: 6px 0 0;
	color: var(--portal-text-secondary);
	font-size: 0.95rem;
}

/* ========== Cards ========== */

.hdl-portal-card {
	background: var(--portal-surface);
	border: 1px solid var(--portal-border);
	border-radius: var(--portal-radius);
	box-shadow: var(--portal-shadow);
	overflow: hidden;
}

.hdl-portal-card-header {
	padding: 18px 22px;
	border-bottom: 1px solid var(--portal-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.hdl-portal-card-header h2 {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
}

.hdl-portal-card-body {
	padding: 22px;
}

/* ========== Buttons ========== */

.hdl-portal-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 18px;
	font-family: var(--portal-font);
	font-size: 0.9rem;
	font-weight: 500;
	border-radius: var(--portal-radius-sm);
	border: 1px solid transparent;
	cursor: pointer;
	transition: all 0.15s ease;
	text-decoration: none;
	line-height: 1.25;
}

.hdl-portal-btn-primary {
	background: var(--portal-primary);
	color: #fff;
}

.hdl-portal-btn-primary:hover {
	background: var(--portal-primary-hover);
	color: #fff;
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgb(79 70 229 / 0.25);
}

.hdl-portal-btn-secondary {
	background: var(--portal-surface);
	color: var(--portal-text);
	border-color: var(--portal-border);
}

.hdl-portal-btn-secondary:hover {
	background: var(--portal-bg);
	border-color: #cbd5e1;
}

.hdl-portal-btn-lg {
	padding: 13px 24px;
	font-size: 1rem;
}

/* ========== Ticket List ========== */

.hdl-portal-ticket-list {
	display: flex;
	flex-direction: column;
}

.hdl-portal-ticket-item {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	padding: 18px 22px;
	border-bottom: 1px solid var(--portal-border);
	text-decoration: none;
	color: inherit;
	transition: background 0.15s;
}

.hdl-portal-ticket-item:last-child {
	border-bottom: none;
}

.hdl-portal-ticket-item:hover {
	background: #f8fafc;
}

.hdl-portal-ticket-status {
	flex-shrink: 0;
	margin-top: 3px;
}

.hdl-portal-ticket-content {
	flex: 1;
	min-width: 0;
}

.hdl-portal-ticket-subject {
	font-weight: 600;
	font-size: 0.95rem;
	color: var(--portal-text);
	margin: 0 0 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hdl-portal-ticket-meta {
	font-size: 0.8125rem;
	color: var(--portal-text-muted);
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.hdl-portal-ticket-id {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-size: 0.8rem;
	color: var(--portal-text-muted);
}

/* Status pills (portal version) */
.hdl-portal-status {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 10px;
	font-size: 0.75rem;
	font-weight: 500;
	border-radius: 999px;
}

.hdl-portal-status::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.hdl-portal-status-received   { background: #fef3c7; color: #92400e; }
.hdl-portal-status-in-progress { background: #dbeafe; color: #1e40af; }
.hdl-portal-status-waiting-reply { background: #fce7f3; color: #9d174d; }
.hdl-portal-status-waiting-approval { background: #ede9fe; color: #5b21b6; }
.hdl-portal-status-on-hold    { background: #f1f5f9; color: #475569; }
.hdl-portal-status-resolved   { background: #d1fae5; color: #065f46; }
.hdl-portal-status-closed     { background: #e2e8f0; color: #334155; }
.hdl-portal-status-cancelled  { background: #f1f5f9; color: #64748b; }

/* ========== New Ticket Form ========== */

.hdl-portal-form-group {
	margin-bottom: 22px;
}

.hdl-portal-form-group label {
	display: block;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--portal-text);
	margin-bottom: 7px;
}

.hdl-portal-form-group .hint {
	font-size: 0.8125rem;
	color: var(--portal-text-muted);
	margin-top: 6px;
}

.hdl-portal-input,
.hdl-portal-select,
.hdl-portal-textarea {
	width: 100%;
	padding: 11px 14px;
	border: 1px solid var(--portal-border);
	border-radius: var(--portal-radius-sm);
	font-size: 0.95rem;
	font-family: var(--portal-font);
	color: var(--portal-text);
	background: var(--portal-surface);
	transition: border-color 0.15s, box-shadow 0.15s;
}

.hdl-portal-input:focus,
.hdl-portal-select:focus,
.hdl-portal-textarea:focus {
	outline: none;
	border-color: var(--portal-primary);
	box-shadow: 0 0 0 4px rgb(79 70 229 / 0.12);
}

.hdl-portal-textarea {
	min-height: 160px;
	resize: vertical;
	line-height: 1.6;
}

/* ========== Ticket Detail (Customer view) ========== */

.hdl-portal-conversation {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.hdl-portal-message {
	display: flex;
	gap: 14px;
}

.hdl-portal-message-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--portal-primary-soft);
	color: var(--portal-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 0.9rem;
	flex-shrink: 0;
}

.hdl-portal-message.is-agent .hdl-portal-message-avatar {
	background: #ecfdf5;
	color: #059669;
}

.hdl-portal-message-bubble {
	flex: 1;
	background: var(--portal-surface);
	border: 1px solid var(--portal-border);
	border-radius: var(--portal-radius);
	padding: 16px 18px;
	box-shadow: var(--portal-shadow);
}

.hdl-portal-message-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.hdl-portal-message-author {
	font-weight: 600;
	font-size: 0.9rem;
}

.hdl-portal-message-time {
	font-size: 0.8rem;
	color: var(--portal-text-muted);
}

.hdl-portal-message-body {
	font-size: 0.95rem;
	line-height: 1.65;
	color: var(--portal-text-secondary);
}

.hdl-portal-message-body p:last-child {
	margin-bottom: 0;
}

/* Reply box */
.hdl-portal-reply-box {
	margin-top: 28px;
	background: var(--portal-surface);
	border: 1px solid var(--portal-border);
	border-radius: var(--portal-radius);
	padding: 20px;
	box-shadow: var(--portal-shadow);
}

/* ========== Empty State ========== */

.hdl-portal-empty {
	text-align: center;
	padding: 80px 24px;
}

.hdl-portal-empty-icon {
	width: 64px;
	height: 64px;
	margin: 0 auto 20px;
	background: var(--portal-primary-soft);
	color: var(--portal-primary);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hdl-portal-empty h2 {
	font-size: 1.25rem;
	font-weight: 600;
	margin: 0 0 8px;
}

.hdl-portal-empty p {
	color: var(--portal-text-secondary);
	margin: 0 0 24px;
	max-width: 360px;
	margin-left: auto;
	margin-right: auto;
}

/* ========== Responsive ========== */

@media (max-width: 640px) {
	.hdl-portal-header-inner {
		padding: 0 16px;
	}

	.hdl-portal-main {
		padding: 24px 16px 48px;
	}

	.hdl-portal-page-header h1 {
		font-size: 1.4rem;
	}

	.hdl-portal-ticket-item {
		padding: 16px;
	}
}

/* Avatars */
.hdl-avatar {
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

