/**
 * Frontend Styles
 * VB-HelpDesk Plugin
 * Modern Professional Theme
 *
 * USAGE NOTES:
 * ------------
 * For two-column layouts (Create Ticket + My Tickets), wrap shortcodes in a flex container:
 *
 * <div style="display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;">
 *   <div style="flex: 1; min-width: 400px;">[helpdesk_form]</div>
 *   <div style="flex: 0 1 400px;">[helpdesk_my_tickets]</div>
 * </div>
 *
 * Or use WordPress columns block or theme column layouts.
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
	/* Primary Colors */
	--hd-primary: #4F46E5;
	--hd-primary-hover: #4338CA;
	--hd-primary-light: #EEF2FF;
	--hd-primary-subtle: #C7D2FE;

	/* Status Colors */
	--hd-success: #10B981;
	--hd-success-light: #D1FAE5;
	--hd-success-dark: #065F46;

	--hd-warning: #F59E0B;
	--hd-warning-light: #FEF3C7;
	--hd-warning-dark: #92400E;

	--hd-error: #EF4444;
	--hd-error-light: #FEE2E2;
	--hd-error-dark: #991B1B;

	--hd-info: #3B82F6;
	--hd-info-light: #DBEAFE;
	--hd-info-dark: #1E40AF;

	/* Neutrals */
	--hd-gray-50: #F9FAFB;
	--hd-gray-100: #F3F4F6;
	--hd-gray-200: #E5E7EB;
	--hd-gray-300: #D1D5DB;
	--hd-gray-400: #9CA3AF;
	--hd-gray-500: #6B7280;
	--hd-gray-600: #4B5563;
	--hd-gray-700: #374151;
	--hd-gray-800: #1F2937;
	--hd-gray-900: #111827;

	/* Surfaces */
	--hd-bg: var(--hd-gray-50);
	--hd-surface: #FFFFFF;
	--hd-surface-elevated: #FFFFFF;
	--hd-border: var(--hd-gray-200);
	--hd-border-light: var(--hd-gray-100);

	/* Text */
	--hd-text-primary: var(--hd-gray-900);
	--hd-text-secondary: var(--hd-gray-600);
	--hd-text-muted: var(--hd-gray-500);
	--hd-text-inverse: #FFFFFF;

	/* Spacing Scale */
	--hd-space-1: 4px;
	--hd-space-2: 8px;
	--hd-space-3: 12px;
	--hd-space-4: 16px;
	--hd-space-5: 20px;
	--hd-space-6: 24px;
	--hd-space-8: 32px;
	--hd-space-10: 40px;
	--hd-space-12: 48px;

	/* Border Radius */
	--hd-radius-sm: 6px;
	--hd-radius-md: 8px;
	--hd-radius-lg: 12px;
	--hd-radius-xl: 16px;
	--hd-radius-full: 9999px;

	/* Shadows */
	--hd-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
	--hd-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
	--hd-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
	--hd-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

	/* Transitions */
	--hd-transition-fast: 150ms ease;
	--hd-transition-normal: 200ms ease;
	--hd-transition-slow: 300ms ease;

	/* Focus Ring */
	--hd-focus-ring: 0 0 0 3px var(--hd-primary-subtle);
}

/* ============================================
   Base & Reset
   ============================================ */
.hd-form-wrapper,
.hd-ticket-detail {
	width: 100%;
	max-width: 800px;
	padding: var(--hd-space-6);
	font-family: inherit;
	line-height: 1.6;
	color: var(--hd-text-primary);
}

/* When form-wrapper is standalone (not in a flex/grid container), center it */
.hd-form-wrapper:only-child,
.hd-ticket-detail:only-child {
	margin: 0 auto;
}

.hd-tickets-wrapper {
	width: 100%;
	padding: var(--hd-space-6);
	font-family: inherit;
	line-height: 1.6;
	color: var(--hd-text-primary);
}

.hd-form-wrapper *,
.hd-tickets-wrapper *,
.hd-ticket-detail * {
	box-sizing: border-box;
}

/* ============================================
   Notices / Alerts
   ============================================ */
.hd-notice {
	display: flex;
	align-items: flex-start;
	gap: var(--hd-space-3);
	padding: var(--hd-space-4) var(--hd-space-5);
	margin-bottom: var(--hd-space-6);
	border-radius: var(--hd-radius-lg);
	border: 1px solid transparent;
	font-size: 14px;
	line-height: 1.5;
}

.hd-notice::before {
	content: '';
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	margin-top: 1px;
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
}

.hd-notice p {
	margin: 0;
}

.hd-notice p + p {
	margin-top: var(--hd-space-2);
}

/* Compact Success Notice */
.hd-success-compact {
	flex-direction: column;
	gap: var(--hd-space-2);
}

.hd-success-compact::before {
	display: none;
}

.hd-success-content strong {
	display: block;
	font-size: 15px;
	font-weight: 600;
	margin-bottom: var(--hd-space-1);
}

.hd-success-content p {
	font-size: 14px;
	margin: 0;
}

/* Success Actions */
.hd-ticket-success-wrapper {
	max-width: 100%;
}

.hd-success-actions {
	display: flex;
	gap: var(--hd-space-3);
	margin-top: var(--hd-space-4);
}

@media (max-width: 480px) {
	.hd-success-actions {
		flex-direction: column;
	}

	.hd-success-actions .hd-button {
		width: 100%;
		text-align: center;
	}
}

.hd-notice-success {
	background: var(--hd-success-light);
	border-color: var(--hd-success);
	color: var(--hd-success-dark);
}

.hd-notice-success::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23065F46'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E");
}

.hd-notice-error {
	background: var(--hd-error-light);
	border-color: var(--hd-error);
	color: var(--hd-error-dark);
}

.hd-notice-error::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23991B1B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E");
}

.hd-notice-info {
	background: var(--hd-info-light);
	border-color: var(--hd-info);
	color: var(--hd-info-dark);
}

.hd-notice-info::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%231E40AF'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E");
}

/* ============================================
   Form Card Container
   ============================================ */
.hd-form-wrapper .hd-ticket-form {
	background: var(--hd-gray-50);
	border-radius: var(--hd-radius-xl);
	box-shadow: var(--hd-shadow-md);
	padding: var(--hd-space-8);
	border: 1px solid var(--hd-border);
}

.hd-form-card {
	background: var(--hd-surface);
	border-radius: var(--hd-radius-xl);
	box-shadow: var(--hd-shadow-lg);
	padding: var(--hd-space-8);
	border: 1px solid var(--hd-border-light);
}

/* ============================================
   Form Elements
   ============================================ */
.hd-form-group {
	margin-bottom: var(--hd-space-6);
}

.hd-form-group label {
	display: block;
	font-weight: 600;
	margin-bottom: var(--hd-space-2);
	color: var(--hd-text-primary);
	font-size: 14px;
}

.hd-form-group .required {
	color: var(--hd-error);
	margin-left: 2px;
}

.hd-input,
.hd-select,
.hd-textarea {
	width: 100%;
	padding: var(--hd-space-3) var(--hd-space-4);
	border: 1px solid var(--hd-border);
	border-radius: var(--hd-radius-md);
	font-size: 15px;
	font-family: inherit;
	color: var(--hd-text-primary);
	background-color: #FFFFFF !important;
	transition: border-color var(--hd-transition-fast),
	            box-shadow var(--hd-transition-fast),
	            background-color var(--hd-transition-fast);
}

/* Ensure editable inputs in ticket form have white background */
.hd-ticket-form .hd-input:not([readonly]),
.hd-ticket-form .hd-select,
.hd-ticket-form .hd-textarea {
	background-color: #FFFFFF !important;
}

.hd-input::placeholder,
.hd-textarea::placeholder {
	color: var(--hd-gray-400);
}

.hd-input:hover,
.hd-select:hover,
.hd-textarea:hover {
	border-color: var(--hd-gray-300);
}

.hd-input:focus,
.hd-select:focus,
.hd-textarea:focus {
	outline: none;
	border-color: var(--hd-primary);
	box-shadow: var(--hd-focus-ring);
}

.hd-input[readonly] {
	background-color: var(--hd-gray-200) !important;
	color: var(--hd-text-muted);
	cursor: not-allowed;
	border-color: var(--hd-gray-300);
}

.hd-input[readonly]:focus {
	box-shadow: none;
	border-color: var(--hd-gray-300);
}

.hd-textarea {
	min-height: 150px;
	resize: vertical;
	line-height: 1.6;
}

.hd-select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 18px;
	padding-right: 44px;
	cursor: pointer;
}

/* File Input */
.hd-file-input-wrapper {
	position: relative;
}

.hd-file-input {
	padding: var(--hd-space-3);
	border: 2px dashed var(--hd-border);
	border-radius: var(--hd-radius-md);
	background: var(--hd-gray-50);
	cursor: pointer;
	transition: border-color var(--hd-transition-fast),
	            background-color var(--hd-transition-fast);
}

.hd-file-input:hover {
	border-color: var(--hd-primary-subtle);
	background: var(--hd-primary-light);
}

.hd-file-input:focus {
	outline: none;
	border-color: var(--hd-primary);
	box-shadow: var(--hd-focus-ring);
}

.hd-form-group small {
	display: block;
	margin-top: var(--hd-space-2);
	color: var(--hd-text-muted);
	font-size: 13px;
}

/* ============================================
   Buttons
   ============================================ */
.hd-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--hd-space-2);
	padding: var(--hd-space-3) var(--hd-space-6);
	border: 2px solid transparent;
	border-radius: var(--hd-radius-md);
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	text-decoration: none;
	cursor: pointer;
	transition: all var(--hd-transition-fast);
	white-space: nowrap;
}

.hd-button:focus {
	outline: none;
	box-shadow: var(--hd-focus-ring);
}

.hd-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Primary Button */
.hd-button,
.hd-button-primary {
	background: var(--hd-primary);
	border-color: var(--hd-primary);
	color: var(--hd-text-inverse);
}

.hd-button:hover,
.hd-button-primary:hover {
	background: var(--hd-primary-hover);
	border-color: var(--hd-primary-hover);
	color: var(--hd-text-inverse);
	transform: translateY(-1px);
	box-shadow: var(--hd-shadow-md);
}

.hd-button:active,
.hd-button-primary:active {
	transform: translateY(0);
	box-shadow: none;
}

/* Secondary Button */
.hd-button-secondary {
	background: var(--hd-surface);
	border-color: var(--hd-border);
	color: var(--hd-text-secondary);
}

.hd-button-secondary:hover {
	background: var(--hd-gray-50);
	border-color: var(--hd-gray-300);
	color: var(--hd-text-primary);
	transform: translateY(-1px);
}

/* Danger Button */
.hd-button-danger {
	background: var(--hd-error);
	border-color: var(--hd-error);
	color: var(--hd-text-inverse);
}

.hd-button-danger:hover {
	background: var(--hd-error-dark);
	border-color: var(--hd-error-dark);
	color: var(--hd-text-inverse);
	transform: translateY(-1px);
}

/* Ghost Button */
.hd-button-ghost {
	background: transparent;
	border-color: transparent;
	color: var(--hd-primary);
}

.hd-button-ghost:hover {
	background: var(--hd-primary-light);
	color: var(--hd-primary-hover);
}

/* Small Button */
.hd-button-small {
	padding: var(--hd-space-2) var(--hd-space-4);
	font-size: 13px;
	border-radius: var(--hd-radius-sm);
}

/* Form Actions */
.hd-form-actions {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
	margin-top: var(--hd-space-5);
	padding-top: var(--hd-space-4);
	border-top: 1px solid var(--hd-border-light);
}

/* Split layout: primary actions left, danger action right */
.hd-form-actions-split {
	justify-content: space-between;
	flex-wrap: wrap;
}

.hd-actions-left {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
}

/* ============================================
   Ticket Filters / Search Bar
   ============================================ */
.hd-ticket-filters {
	margin-bottom: var(--hd-space-5);
}

.hd-ticket-filters form {
	display: flex;
	flex-wrap: wrap;
	gap: var(--hd-space-3);
	align-items: center;
}

.hd-ticket-filters .hd-search-input {
	flex: 1;
	min-width: 200px;
	max-width: 350px;
}

.hd-ticket-filters .hd-status-filter {
	width: auto;
	min-width: 160px;
}

@media (max-width: 480px) {
	.hd-ticket-filters .hd-search-input,
	.hd-ticket-filters .hd-status-filter {
		width: 100%;
		max-width: none;
	}
}

/* ============================================
   Sort Bar
   ============================================ */
.hd-sort-bar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	margin-bottom: var(--hd-space-3);
}

.hd-sort-bar form {
	display: flex;
	align-items: center;
	gap: var(--hd-space-2);
}

.hd-sort-bar label {
	font-size: 13px;
	font-weight: 600;
	color: var(--hd-text-secondary);
	white-space: nowrap;
}

.hd-sort-bar .hd-select {
	width: auto;
	min-width: 180px;
	padding: var(--hd-space-2) var(--hd-space-4);
	padding-right: 36px;
	font-size: 13px;
}

/* ============================================
   Tickets Table
   ============================================ */
.hd-tickets-table {
	margin: var(--hd-space-6) 0;
	overflow: hidden;
	border-radius: var(--hd-radius-lg);
	border: 1px solid var(--hd-border);
	background: var(--hd-surface);
	box-shadow: var(--hd-shadow-sm);
}

.hd-tickets-table-inner {
	overflow-x: auto;
}

.hd-tickets-table table {
	width: 100%;
	border-collapse: collapse;
}

.hd-tickets-table thead {
	background: var(--hd-gray-50);
	border-bottom: 1px solid var(--hd-border);
}

.hd-tickets-table th {
	padding: var(--hd-space-4);
	text-align: left;
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--hd-text-secondary);
}

.hd-tickets-table td {
	padding: var(--hd-space-4);
	border-bottom: 1px solid var(--hd-border-light);
	font-size: 14px;
	color: var(--hd-text-primary);
}

.hd-tickets-table tbody tr {
	transition: background-color var(--hd-transition-fast);
}

.hd-tickets-table tbody tr:hover {
	background: var(--hd-gray-50);
}

.hd-tickets-table tbody tr:last-child td {
	border-bottom: none;
}

.hd-ticket-number {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
	font-size: 13px;
	color: var(--hd-text-secondary);
}

.hd-ticket-subject {
	font-weight: 500;
	color: var(--hd-text-primary);
}

.hd-ticket-subject a {
	color: inherit;
	text-decoration: none;
	transition: color var(--hd-transition-fast);
}

.hd-ticket-subject a:hover {
	color: var(--hd-primary);
}

/* ============================================
   Status Badges
   ============================================ */
.hd-status-badge {
	display: inline-flex;
	align-items: center;
	gap: var(--hd-space-1);
	padding: var(--hd-space-1) var(--hd-space-3);
	border-radius: var(--hd-radius-full);
	font-size: 12px;
	font-weight: 600;
	text-transform: capitalize;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

.hd-status-badge::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	flex-shrink: 0;
}

.hd-status-open {
	background: var(--hd-info-light);
	color: var(--hd-info-dark);
}

.hd-status-open::before {
	background: var(--hd-info);
}

.hd-status-waiting {
	background: var(--hd-warning-light);
	color: var(--hd-warning-dark);
}

.hd-status-waiting::before {
	background: var(--hd-warning);
}

.hd-status-closed {
	background: var(--hd-success-light);
	color: var(--hd-success-dark);
}

.hd-status-closed::before {
	background: var(--hd-success);
}

/* ============================================
   Priority Badges
   ============================================ */
.hd-priority-badge {
	display: inline-flex;
	align-items: center;
	gap: var(--hd-space-1);
	padding: var(--hd-space-1) var(--hd-space-3);
	border-radius: var(--hd-radius-full);
	font-size: 12px;
	font-weight: 600;
	text-transform: capitalize;
	letter-spacing: 0.01em;
	white-space: nowrap;
}

.hd-priority-low {
	background: var(--hd-gray-100);
	color: var(--hd-gray-600);
}

.hd-priority-medium {
	background: var(--hd-info-light);
	color: var(--hd-info-dark);
}

.hd-priority-high {
	background: var(--hd-warning-light);
	color: var(--hd-warning-dark);
}

.hd-priority-urgent {
	background: var(--hd-error-light);
	color: var(--hd-error-dark);
}

/* ============================================
   Ticket Detail View
   ============================================ */
.hd-ticket-header {
	margin-bottom: var(--hd-space-8);
	padding-bottom: var(--hd-space-6);
	border-bottom: 1px solid var(--hd-border);
}

.hd-ticket-header h2 {
	margin: 0 0 var(--hd-space-4);
	font-size: 24px;
	font-weight: 700;
	color: var(--hd-text-primary);
	line-height: 1.3;
}

.hd-ticket-meta {
	display: flex;
	flex-wrap: wrap;
	gap: var(--hd-space-4);
}

.hd-meta-item {
	display: flex;
	flex-direction: column;
	gap: var(--hd-space-1);
}

.hd-meta-item strong {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--hd-text-muted);
}

.hd-meta-item span {
	font-size: 14px;
	color: var(--hd-text-primary);
}

/* ============================================
   Messages / Conversation
   ============================================ */
.hd-ticket-messages {
	margin-bottom: var(--hd-space-8);
}

.hd-messages-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: var(--hd-space-5);
}

.hd-messages-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	color: var(--hd-text-primary);
}

.hd-message {
	position: relative;
	margin-bottom: var(--hd-space-5);
	padding: var(--hd-space-5);
	background: var(--hd-surface);
	border-radius: var(--hd-radius-lg);
	box-shadow: var(--hd-shadow-sm);
	border: 1px solid var(--hd-border-light);
	transition: box-shadow var(--hd-transition-fast);
}

.hd-message:hover {
	box-shadow: var(--hd-shadow-md);
}

.hd-message-user {
	border-left: 4px solid var(--hd-primary);
}

.hd-message-agent {
	border-left: 4px solid var(--hd-success);
	background: linear-gradient(135deg, var(--hd-surface) 0%, var(--hd-success-light) 100%);
}

.hd-message-header {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
	margin-bottom: var(--hd-space-4);
	padding-bottom: var(--hd-space-3);
	border-bottom: 1px solid var(--hd-border-light);
}

.hd-message-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--hd-primary-light);
	color: var(--hd-primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 14px;
	flex-shrink: 0;
}

.hd-message-agent .hd-message-avatar {
	background: var(--hd-success-light);
	color: var(--hd-success-dark);
}

.hd-message-meta {
	flex: 1;
	min-width: 0;
}

.hd-message-author {
	font-weight: 600;
	color: var(--hd-text-primary);
	font-size: 14px;
}

.hd-message-date {
	color: var(--hd-text-muted);
	font-size: 12px;
	margin-top: 2px;
}

.hd-message-badge {
	padding: var(--hd-space-1) var(--hd-space-3);
	background: var(--hd-success);
	color: var(--hd-text-inverse);
	border-radius: var(--hd-radius-full);
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.hd-message-content {
	line-height: 1.7;
	color: var(--hd-text-primary);
	font-size: 15px;
}

.hd-message-content p {
	margin: 0 0 var(--hd-space-3);
}

.hd-message-content p:last-child {
	margin-bottom: 0;
}

/* Message Attachments */
.hd-message-attachments {
	margin-top: var(--hd-space-4);
	padding-top: var(--hd-space-4);
	border-top: 1px solid var(--hd-border-light);
}

.hd-message-attachments strong {
	display: flex;
	align-items: center;
	gap: var(--hd-space-2);
	margin-bottom: var(--hd-space-3);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--hd-text-muted);
}

.hd-message-attachments ul {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: var(--hd-space-2);
}

.hd-message-attachments li {
	margin: 0;
}

.hd-attachment-link {
	display: inline-flex;
	align-items: center;
	gap: var(--hd-space-2);
	padding: var(--hd-space-2) var(--hd-space-3);
	background: var(--hd-gray-100);
	border-radius: var(--hd-radius-sm);
	color: var(--hd-text-secondary);
	text-decoration: none;
	font-size: 13px;
	transition: all var(--hd-transition-fast);
}

.hd-attachment-link:hover {
	background: var(--hd-primary-light);
	color: var(--hd-primary);
}

.hd-attachment-link::before {
	content: '';
	width: 16px;
	height: 16px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13'/%3E%3C/svg%3E");
	background-size: contain;
	flex-shrink: 0;
}

.hd-attachment-size {
	color: var(--hd-text-muted);
	font-size: 11px;
	margin-left: var(--hd-space-1);
}

/* ============================================
   Reply Form
   ============================================ */
.hd-reply-form {
	padding: var(--hd-space-5);
	background: var(--hd-gray-50);
	border-radius: var(--hd-radius-lg);
	border: 1px solid var(--hd-border);
}

.hd-reply-form h3 {
	margin: 0 0 var(--hd-space-4);
	font-size: 16px;
	font-weight: 600;
	color: var(--hd-text-primary);
}

.hd-reply-form .hd-form-group {
	margin-bottom: var(--hd-space-4);
}

/* Close Ticket Form */
.hd-close-ticket-form {
	margin-top: var(--hd-space-4);
	padding-top: var(--hd-space-4);
	border-top: 1px solid var(--hd-border-light);
}

/* ============================================
   Empty State
   ============================================ */
.hd-empty-state {
	text-align: center;
	padding: var(--hd-space-12) var(--hd-space-6);
	color: var(--hd-text-secondary);
}

.hd-empty-state-icon {
	width: 64px;
	height: 64px;
	margin: 0 auto var(--hd-space-4);
	opacity: 0.5;
}

.hd-empty-state h3 {
	margin: 0 0 var(--hd-space-2);
	font-size: 18px;
	font-weight: 600;
	color: var(--hd-text-primary);
}

.hd-empty-state p {
	margin: 0;
	font-size: 14px;
}

/* ============================================
   Relative Timestamps
   ============================================ */
.hd-relative-time {
	cursor: help;
	border-bottom: 1px dotted var(--hd-gray-400);
}

/* ============================================
   Last Reply By Badge
   ============================================ */
.hd-last-reply-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: var(--hd-radius-full);
	font-size: 11px;
	font-weight: 500;
	white-space: nowrap;
	max-width: 120px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.hd-last-reply-agent {
	background: var(--hd-success-light);
	color: var(--hd-success-dark);
}

.hd-last-reply-user {
	background: var(--hd-primary-light);
	color: var(--hd-primary);
}

/* ============================================
   Character Count
   ============================================ */
.hd-char-count {
	text-align: right;
	font-size: 12px;
	color: var(--hd-text-muted);
	padding: var(--hd-space-1) 0;
}

/* ============================================
   Loading States
   ============================================ */
.hd-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--hd-space-3);
	padding: var(--hd-space-8);
	color: var(--hd-text-secondary);
}

.hd-spinner {
	width: 20px;
	height: 20px;
	border: 2px solid var(--hd-border);
	border-top-color: var(--hd-primary);
	border-radius: 50%;
	animation: hd-spin 0.8s linear infinite;
}

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

/* Button Loading State */
.hd-button-loading {
	position: relative;
	color: transparent !important;
	pointer-events: none;
}

.hd-button-loading::after {
	content: '';
	position: absolute;
	width: 16px;
	height: 16px;
	top: 50%;
	left: 50%;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: hd-spin 0.8s linear infinite;
}

/* ============================================
   Closed Ticket Notice
   ============================================ */
.hd-closed-notice {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
	padding: var(--hd-space-4) var(--hd-space-5);
	background: var(--hd-gray-100);
	border-radius: var(--hd-radius-md);
	color: var(--hd-text-secondary);
	font-size: 14px;
}

/* ============================================
   Back Link
   ============================================ */
.hd-back-link {
	display: inline-flex;
	align-items: center;
	gap: var(--hd-space-2);
	margin-bottom: var(--hd-space-5);
	color: var(--hd-text-secondary);
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	transition: color var(--hd-transition-fast);
}

.hd-back-link:hover {
	color: var(--hd-primary);
}

.hd-back-link::before {
	content: '';
	width: 18px;
	height: 18px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236B7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 19l-7-7m0 0l7-7m-7 7h18'/%3E%3C/svg%3E");
	background-size: contain;
}

.hd-back-link:hover::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234F46E5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M10 19l-7-7m0 0l7-7m-7 7h18'/%3E%3C/svg%3E");
}

/* ============================================
   Pagination
   ============================================ */
.hd-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--hd-space-2);
	margin-top: var(--hd-space-6);
}

.hd-pagination a,
.hd-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 var(--hd-space-3);
	border: 1px solid var(--hd-border);
	border-radius: var(--hd-radius-md);
	font-size: 14px;
	font-weight: 500;
	color: var(--hd-text-secondary);
	text-decoration: none;
	transition: all var(--hd-transition-fast);
}

.hd-pagination a:hover {
	background: var(--hd-gray-50);
	border-color: var(--hd-gray-300);
	color: var(--hd-text-primary);
}

.hd-pagination .current {
	background: var(--hd-primary);
	border-color: var(--hd-primary);
	color: var(--hd-text-inverse);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
	.hd-form-wrapper,
	.hd-tickets-wrapper,
	.hd-ticket-detail {
		padding: var(--hd-space-4);
	}

	.hd-form-card {
		padding: var(--hd-space-5);
	}

	.hd-ticket-header h2 {
		font-size: 20px;
	}

	.hd-ticket-meta {
		gap: var(--hd-space-4);
	}

	.hd-meta-item {
		flex-basis: calc(50% - var(--hd-space-2));
	}

	.hd-tickets-table th,
	.hd-tickets-table td {
		padding: var(--hd-space-3);
		font-size: 13px;
	}

	.hd-message {
		padding: var(--hd-space-4);
	}

	.hd-message-header {
		flex-wrap: wrap;
	}

	.hd-message-avatar {
		width: 32px;
		height: 32px;
		font-size: 12px;
	}

	.hd-form-actions {
		flex-direction: column;
	}

	.hd-form-actions .hd-button {
		width: 100%;
	}

	.hd-form-actions-split {
		flex-direction: column;
	}

	.hd-actions-left {
		flex-direction: column;
		width: 100%;
	}

	.hd-actions-left .hd-button {
		width: 100%;
	}

	.hd-reply-form {
		padding: var(--hd-space-4);
	}
}

@media (max-width: 480px) {
	.hd-meta-item {
		flex-basis: 100%;
	}

	.hd-status-badge {
		font-size: 11px;
		padding: 3px var(--hd-space-2);
	}

	.hd-message-attachments ul {
		flex-direction: column;
	}

	.hd-attachment-link {
		width: 100%;
	}
}

/* ============================================
   My Tickets Widget (Compact)
   ============================================ */
.hd-my-tickets-widget {
	background: var(--hd-surface);
	border-radius: var(--hd-radius-lg);
	border: 1px solid var(--hd-border);
	box-shadow: var(--hd-shadow-sm);
	overflow: hidden;
	height: fit-content;
	align-self: flex-start;
	min-width: 300px;
	width: 100%;
}

.hd-my-tickets-widget .hd-widget-title {
	margin: 0;
	padding: var(--hd-space-5) var(--hd-space-5);
	background: linear-gradient(135deg, var(--hd-primary) 0%, var(--hd-primary-hover) 100%);
	color: var(--hd-text-inverse);
	font-size: 15px;
	font-weight: 600;
	letter-spacing: 0.02em;
	border: none;
}

.hd-my-tickets-list table {
	width: 100%;
	border-collapse: collapse;
}

.hd-my-tickets-list thead {
	background: var(--hd-gray-50);
	border-bottom: 1px solid var(--hd-border-light);
}

.hd-my-tickets-list th,
.hd-my-tickets-list td {
	padding: var(--hd-space-3) var(--hd-space-4);
	text-align: left !important;
	vertical-align: middle;
}

.hd-my-tickets-list th {
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--hd-text-muted);
}

.hd-my-tickets-list td {
	border-bottom: 1px solid var(--hd-border-light);
	font-size: 13px;
	color: var(--hd-text-primary);
}

/* Column widths */
.hd-my-tickets-list .hd-col-ticket,
.hd-my-tickets-list .hd-ticket-id {
	width: 28%;
}

.hd-my-tickets-list .hd-col-subject,
.hd-my-tickets-list .hd-ticket-subject {
	width: 40%;
}

.hd-my-tickets-list .hd-col-status,
.hd-my-tickets-list .hd-ticket-status {
	width: 32%;
	text-align: left !important;
}

.hd-my-tickets-list tbody tr {
	transition: background-color var(--hd-transition-fast);
}

.hd-my-tickets-list tbody tr:hover {
	background: var(--hd-gray-50);
}

.hd-my-tickets-list tbody tr:last-child td {
	border-bottom: none;
}

.hd-my-tickets-list .hd-ticket-id {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
	font-size: 12px;
	white-space: nowrap;
}

.hd-my-tickets-list .hd-ticket-id a,
.hd-my-tickets-list .hd-ticket-subject a {
	color: var(--hd-text-primary);
	text-decoration: none;
	transition: color var(--hd-transition-fast);
}

.hd-my-tickets-list .hd-ticket-id a:hover,
.hd-my-tickets-list .hd-ticket-subject a:hover {
	color: var(--hd-primary);
}

.hd-my-tickets-list .hd-ticket-subject {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hd-my-tickets-list .hd-ticket-status {
	white-space: nowrap;
}

/* Status badge in widget - ensure left alignment */
.hd-my-tickets-list .hd-ticket-status .hd-status-badge {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: flex-start !important;
	margin: 0 !important;
	float: none !important;
	text-align: left !important;
}

.hd-widget-footer {
	padding: var(--hd-space-3) var(--hd-space-4);
	background: var(--hd-gray-50);
	border-top: 1px solid var(--hd-border-light);
	text-align: center;
}

.hd-view-all-link {
	color: var(--hd-primary);
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	transition: color var(--hd-transition-fast);
}

.hd-view-all-link:hover {
	color: var(--hd-primary-hover);
}

.hd-no-tickets {
	padding: var(--hd-space-6) var(--hd-space-4);
	margin: 0;
	text-align: center;
	color: var(--hd-text-muted);
	font-size: 14px;
}

@media (max-width: 480px) {
	.hd-my-tickets-list th,
	.hd-my-tickets-list td {
		padding: var(--hd-space-2) var(--hd-space-3);
		font-size: 12px;
	}

	.hd-my-tickets-list .hd-ticket-subject {
		max-width: 120px;
	}
}

/* ============================================
   Sort Bar
   ============================================ */
.hd-sort-bar {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
	margin-bottom: var(--hd-space-4);
}

.hd-sort-bar label {
	font-size: 13px;
	font-weight: 600;
	color: var(--hd-text-secondary);
}

.hd-sort-bar select {
	padding: var(--hd-space-2) var(--hd-space-3);
	border: 2px solid var(--hd-border);
	border-radius: var(--hd-radius-md);
	font-size: 13px;
	color: var(--hd-text-primary);
	background: var(--hd-surface);
	transition: border-color var(--hd-transition-fast);
}

.hd-sort-bar select:focus {
	outline: none;
	border-color: var(--hd-primary);
	box-shadow: var(--hd-focus-ring);
}

/* ============================================
   Toast Notifications (Frontend)
   ============================================ */
#hd-toast-container {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	gap: var(--hd-space-2);
	pointer-events: none;
}

.hd-toast {
	display: flex;
	align-items: center;
	gap: var(--hd-space-3);
	min-width: 280px;
	max-width: 420px;
	padding: var(--hd-space-3) var(--hd-space-4);
	border-radius: var(--hd-radius-md);
	box-shadow: var(--hd-shadow-lg);
	font-size: 13px;
	font-weight: 500;
	pointer-events: auto;
	animation: hd-toast-in 0.3s ease forwards;
}

.hd-toast.hd-toast-out {
	animation: hd-toast-out 0.3s ease forwards;
}

.hd-toast-success { background: var(--hd-success); color: #fff; }
.hd-toast-error { background: var(--hd-error); color: #fff; }
.hd-toast-info { background: var(--hd-info); color: #fff; }
.hd-toast-warning { background: var(--hd-warning); color: #fff; }

@keyframes hd-toast-in {
	from { opacity: 0; transform: translateX(100%); }
	to { opacity: 1; transform: translateX(0); }
}

@keyframes hd-toast-out {
	from { opacity: 1; transform: translateX(0); }
	to { opacity: 0; transform: translateX(100%); }
}

/* ============================================
   Loading Skeletons (Frontend)
   ============================================ */
.hd-skeleton {
	background: linear-gradient(90deg, var(--hd-gray-100) 25%, var(--hd-gray-200) 50%, var(--hd-gray-100) 75%);
	background-size: 200% 100%;
	animation: hd-skeleton-pulse 1.5s ease-in-out infinite;
	border-radius: var(--hd-radius-sm);
}

.hd-skeleton-row {
	display: flex;
	gap: var(--hd-space-4);
	padding: var(--hd-space-4);
	border-bottom: 1px solid var(--hd-border-light);
}

.hd-skeleton-text {
	height: 14px;
	flex: 1;
}

.hd-skeleton-badge {
	width: 80px;
	height: 22px;
	border-radius: var(--hd-radius-full);
}

@keyframes hd-skeleton-pulse {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* ============================================
   Empty State (Frontend)
   ============================================ */
.hd-empty-state {
	text-align: center;
	padding: var(--hd-space-12) var(--hd-space-6);
	background: var(--hd-surface);
	border-radius: var(--hd-radius-lg);
	border: 2px dashed var(--hd-border);
}

.hd-empty-state .dashicons {
	font-size: 48px;
	width: 48px;
	height: 48px;
	color: var(--hd-gray-300);
	margin-bottom: var(--hd-space-4);
}

.hd-empty-state h3 {
	margin: 0 0 var(--hd-space-2);
	font-size: 18px;
	font-weight: 600;
	color: var(--hd-text-primary);
}

.hd-empty-state p {
	margin: 0;
	font-size: 14px;
	color: var(--hd-text-muted);
}

/* ============================================
   Notification Preferences
   ============================================ */
.hd-notification-prefs {
	margin-top: var(--hd-space-6);
	padding: var(--hd-space-4) var(--hd-space-5);
	background: var(--hd-gray-50);
	border-radius: var(--hd-radius-lg);
	border: 1px solid var(--hd-border);
}

.hd-prefs-toggle {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: var(--hd-text-secondary);
	cursor: pointer;
	user-select: none;
	transition: color var(--hd-transition-fast);
}

.hd-prefs-toggle:hover {
	color: var(--hd-primary);
}

.hd-prefs-form {
	margin-top: var(--hd-space-4);
	padding-top: var(--hd-space-4);
	border-top: 1px solid var(--hd-border-light);
}

.hd-prefs-form label {
	display: flex;
	align-items: center;
	gap: var(--hd-space-2);
	margin-bottom: var(--hd-space-3);
	font-size: 14px;
	color: var(--hd-text-primary);
	cursor: pointer;
}

.hd-prefs-form label:last-of-type {
	margin-bottom: var(--hd-space-4);
}

.hd-prefs-form input[type="checkbox"] {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	accent-color: var(--hd-primary);
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
	.hd-input,
	.hd-select,
	.hd-textarea,
	.hd-file-input,
	.hd-button,
	.hd-button-primary,
	.hd-button-secondary,
	.hd-button-danger,
	.hd-button-ghost,
	.hd-tickets-table tbody tr,
	.hd-message,
	.hd-my-tickets-list tbody tr,
	.hd-attachment-link,
	.hd-back-link,
	.hd-pagination a,
	.hd-spinner,
	.hd-button-loading::after,
	.hd-toast,
	.hd-skeleton {
		transition: none !important;
		animation: none !important;
	}

	.hd-button:hover,
	.hd-button-primary:hover,
	.hd-button-secondary:hover,
	.hd-button-danger:hover {
		transform: none !important;
	}
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
	.hd-form-wrapper,
	.hd-tickets-wrapper,
	.hd-ticket-detail {
		max-width: 100%;
		padding: 0;
	}

	.hd-button,
	.hd-reply-form,
	.hd-back-link {
		display: none !important;
	}

	.hd-message {
		box-shadow: none;
		border: 1px solid var(--hd-gray-300);
		break-inside: avoid;
	}
}
