/**
 * Smart Ticket Manager — Professional RTL Frontend + Admin Dashboard
 * Full responsive CSS with accessibility and modern design patterns
 */

/* ════════════════════════════════════════════════════════════════
   VARIABLES & BASE STYLES
   ════════════════════════════════════════════════════════════════ */

:root {
	--stm-primary: #4f46e5;
	--stm-primary-dark: #4338ca;
	--stm-primary-light: #eef2ff;
	--stm-success: #059669;
	--stm-error: #dc2626;
	--stm-warning: #d97706;
	--stm-text: #111827;
	--stm-text-muted: #6b7280;
	--stm-border: #e5e7eb;
	--stm-bg: #f8fafc;
	--stm-card: #ffffff;
	--stm-radius: 14px;
	--stm-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
	--stm-shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);
	--stm-font: "Vazirmatn", "Tahoma", "Segoe UI", "Arial", sans-serif;
	--stm-transition: all 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
}

body {
	font-family: var(--stm-font);
	color: var(--stm-text);
}

/* ════════════════════════════════════════════════════════════════
   ADMIN DASHBOARD HEADER & LAYOUT
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap {
	direction: rtl;
	text-align: right;
	padding: 24px;
	background: var(--stm-bg);
}

.stm-wrap h1 {
	font-size: 2.2rem;
	font-weight: 800;
	margin: 0 0 12px;
	color: var(--stm-text);
	line-height: 1.2;
}

.stm-dashboard-header {
	margin-bottom: 32px;
}

.stm-dash-title {
	padding: 32px;
	background: linear-gradient(135deg, var(--stm-primary) 0%, #7c3aed 100%);
	border-radius: var(--stm-radius);
	color: #fff;
	box-shadow: var(--stm-shadow-lg);
}

.stm-dash-title h1 {
	color: #fff;
	margin-bottom: 8px;
	font-size: 1.8rem;
}

.stm-dash-subtitle {
	margin: 0;
	font-size: 0.95rem;
	opacity: 0.9;
	font-weight: 500;
}

/* ════════════════════════════════════════════════════════════════
   DASHBOARD STATS GRID
   ════════════════════════════════════════════════════════════════ */

.stm-dashboard-stats,
.stm-dashboard-categories,
.stm-dashboard-recent {
	margin-bottom: 32px;
}

.stm-page-description {
	margin: 8px 0 0;
	font-size: 0.96rem;
	color: var(--stm-text-muted);
	line-height: 1.7;
}

.stm-summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 16px;
	margin-bottom: 28px;
}

.stm-summary-card {
	background: #fff;
	border: 1px solid rgba(229,231,235,0.95);
	border-radius: 16px;
	padding: 22px 20px;
	box-shadow: 0 12px 30px rgba(15,23,42,0.04);
	transition: transform 180ms ease, box-shadow 180ms ease;
}

.stm-summary-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 16px 40px rgba(15,23,42,0.08);
}

.stm-summary-label {
	display: block;
	font-size: 0.86rem;
	color: var(--stm-text-muted);
	margin-bottom: 12px;
}

.stm-summary-number {
	display: block;
	font-size: 2rem;
	font-weight: 800;
	color: var(--stm-text);
}

.stm-summary-total {
	background: linear-gradient(180deg, rgba(79,70,229,0.08) 0%, rgba(79,70,229,0.04) 100%);
}

.stm-card-panel {
	background: #fff;
	border: 1px solid rgba(229,231,235,0.95);
	border-radius: 18px;
	padding: 24px;
	box-shadow: 0 18px 40px rgba(15,23,42,0.06);
	margin-bottom: 28px;
}

.stm-header-actions {
	display: flex;
	justify-content: flex-end;
	align-items: center;
}

.stm-stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 18px;
	margin-bottom: 0;
}

.stm-stat-card {
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: 12px;
	padding: 24px;
	text-align: center;
	transition: var(--stm-transition);
	position: relative;
	overflow: hidden;
	cursor: default;
}

.stm-stat-card::before {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	width: 4px;
	height: 100%;
	background: var(--stm-primary-light);
	transition: var(--stm-transition);
}

.stm-stat-card:hover,
.stm-stat-card:focus-within {
	transform: translateY(-6px);
	box-shadow: var(--stm-shadow-lg);
	border-color: var(--stm-primary);
}

.stm-stat-card:hover::before {
	background: var(--stm-primary);
}

.stm-stat-icon {
	font-size: 2rem;
	margin-bottom: 12px;
	display: inline-block;
}

.stm-stat-number {
	display: block;
	font-size: 2.4rem;
	font-weight: 800;
	color: var(--stm-primary);
	line-height: 1;
	margin-bottom: 8px;
}

.stm-stat-label {
	display: block;
	font-size: 0.85rem;
	color: var(--stm-text-muted);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* Status-specific stat cards */
.stm-stat-open {
	border-top-color: #3b82f6;
}

.stm-stat-open .stm-stat-number {
	color: #3b82f6;
}

.stm-stat-in_progress {
	border-top-color: #f59e0b;
}

.stm-stat-in_progress .stm-stat-number {
	color: #f59e0b;
}

.stm-stat-answered {
	border-top-color: #10b981;
}

.stm-stat-answered .stm-stat-number {
	color: #10b981;
}

.stm-stat-closed {
	border-top-color: #6b7280;
}

.stm-stat-closed .stm-stat-number {
	color: #6b7280;
}

.stm-stat-total {
	border-top-color: var(--stm-primary);
	background: linear-gradient(135deg, var(--stm-primary-light) 0%, rgba(79, 70, 229, 0.05) 100%);
}

/* ════════════════════════════════════════════════════════════════
   CATEGORY GRID
   ════════════════════════════════════════════════════════════════ */

.stm-category-grid {
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.stm-cat-financial { border-top: 4px solid #059669; }
.stm-cat-warranty { border-top: 4px solid #dc2626; }
.stm-cat-support { border-top: 4px solid #2563eb; }
.stm-cat-exchange { border-top: 4px solid #7c3aed; }
.stm-cat-services { border-top: 4px solid #d97706; }

.stm-cat-financial .stm-stat-number { color: #059669; }
.stm-cat-warranty .stm-stat-number { color: #dc2626; }
.stm-cat-support .stm-stat-number { color: #2563eb; }
.stm-cat-exchange .stm-stat-number { color: #7c3aed; }
.stm-cat-services .stm-stat-number { color: #d97706; }

/* ════════════════════════════════════════════════════════════════
   ADMIN TABLES
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap table.widefat {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
	margin-top: 12px;
}

.wrap.stm-wrap table.widefat thead {
	background: linear-gradient(180deg, #fafafa 0%, #f3f3f3 100%);
	border-bottom: 2px solid var(--stm-border);
}

.wrap.stm-wrap table.widefat th {
	padding: 14px 16px;
	font-weight: 700;
	font-size: 0.85rem;
	color: var(--stm-text);
	text-transform: uppercase;
	letter-spacing: 0.3px;
	text-align: right;
}

.wrap.stm-wrap table.widefat td {
	padding: 14px 16px;
	border-bottom: 1px solid #f1f1f1;
	vertical-align: middle;
	font-size: 0.9rem;
	color: var(--stm-text);
}

.wrap.stm-wrap table.widefat tbody tr {
	transition: background 160ms ease;
}

.wrap.stm-wrap table.widefat tbody tr:hover {
	background: #fbfbff;
}

.wrap.stm-wrap table.widefat tbody tr:focus-within {
	outline: 3px solid rgba(79, 70, 229, 0.12);
	outline-offset: -3px;
	background: #fff;
}

.wrap.stm-wrap .stm-badge {
	display: inline-block;
	padding: 5px 12px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 700;
	white-space: nowrap;
	text-align: center;
	min-width: 80px;
}

.stm-status-open { background: #e6f0ff; color: #123a80; }
.stm-status-in_progress { background: #fff7e6; color: #7a4b00; }
.stm-status-answered { background: #def7ec; color: #065f46; }
.stm-status-closed { background: #f5f7fb; color: #374151; }

.stm-ticket-cat {
	background: var(--stm-primary-light);
	color: var(--stm-primary);
	min-width: auto;
}

/* ════════════════════════════════════════════════════════════════
   FILTER FORM
   ════════════════════════════════════════════════════════════════ */

.stm-filters,
.stm-reply-filters {
	padding: 16px;
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: 10px;
	margin-bottom: 24px;
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: flex-end;
}

.stm-filter-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.stm-filters label,
.stm-reply-filters label {
	font-weight: 600;
	font-size: 0.85rem;
	color: var(--stm-text);
	display: block;
}

.stm-filter-select,
.stm-filter-input {
	min-width: 160px;
	padding: 10px 12px;
	border: 1.5px solid var(--stm-border);
	border-radius: 8px;
	font-size: 0.9rem;
	font-family: inherit;
	background: var(--stm-bg);
	color: var(--stm-text);
	transition: border-color 200ms ease, box-shadow 200ms ease;
}

.stm-filter-select:focus,
.stm-filter-input:focus {
	outline: none;
	border-color: var(--stm-primary);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
	background: #fff;
}

.stm-results-count {
	color: var(--stm-text-muted);
	font-size: 0.95rem;
	font-weight: 600;
	margin-bottom: 18px;
	padding: 12px 16px;
	border-radius: 12px;
	background: #f8fafc;
	border: 1px solid #e5e7eb;
}

.stm-filters,
.stm-reply-filters {
	padding: 20px;
	background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 100%);
	border: 1px solid rgba(229,231,235,0.95);
	box-shadow: 0 12px 30px rgba(15,23,42,0.05);
	border-radius: 18px;
	margin-bottom: 26px;
	display: flex;
	flex-wrap: wrap;
	gap: 18px;
	align-items: flex-end;
}

.stm-filter-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
}

.stm-filter-group {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 220px;
}

.stm-filter-search {
	flex: 1 1 320px;
}

.stm-filter-search input {
	width: 100%;
}

.stm-filters label,
.stm-reply-filters label {
	font-weight: 700;
	font-size: 0.9rem;
	color: var(--stm-text);
}

.stm-filter-select,
.stm-filter-input,
.stm-reply-filters select {
	min-width: 220px;
	padding: 14px 16px;
	border: 1px solid rgba(229,231,235,0.95);
	border-radius: 14px;
	font-size: 0.95rem;
	background: #fff;
	color: var(--stm-text);
}

.stm-filter-select:focus,
.stm-filter-input:focus,
.stm-reply-filters select:focus {
	outline: none;
	border-color: rgba(79,70,229,0.5);
	box-shadow: 0 0 0 4px rgba(79,70,229,0.08);
}

.stm-filters button,
.stm-reply-filters button,
.stm-filter-actions .button {
	min-height: 46px;
	padding: 0 24px;
	border-radius: 14px;
}

/* ════════════════════════════════════════════════════════════════
   ALL TICKETS TABLE
   ════════════════════════════════════════════════════════════════ */

.stm-table {
	margin-top: 0;
	border-radius: 18px;
	overflow: hidden;
	border: 1px solid rgba(229,231,235,0.95);
}

.stm-table thead {
	background: linear-gradient(180deg, #f9fafb 0%, #eff2ff 100%);
}

.stm-table thead th {
	padding: 18px 20px;
	font-size: 0.85rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #374151;
	border-bottom: 1px solid rgba(229,231,235,0.95);
}

.stm-table tbody tr {
	background: #fff;
	transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.stm-table tbody tr:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 24px rgba(15,23,42,0.08);
	background: #f8fbff;
}

.stm-table tbody td {
	padding: 18px 20px;
	border-bottom: 1px solid rgba(229,231,235,0.95);
}

.stm-table tbody tr:last-child td {
	border-bottom: none;
}

.stm-table-row strong {
	color: var(--stm-primary);
}

.stm-ticket-summary {
	display: grid;
	gap: 6px;
}

.stm-ticket-title {
	font-size: 0.96rem;
	font-weight: 700;
	color: var(--stm-text);
}

.stm-ticket-snippet {
	font-size: 0.85rem;
	color: var(--stm-text-muted);
}

.stm-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.stm-actions .button {
	padding: 10px 16px;
	border-radius: 12px;
	font-size: 0.9rem;
	font-weight: 700;
}

.stm-actions .button-primary {
	background: linear-gradient(135deg, var(--stm-primary), var(--stm-primary-dark));
	color: #fff;
}

.stm-actions .button-secondary {
	background: #fff;
	border: 1px solid rgba(148,163,184,0.4);
	color: #334155;
}

.stm-actions .button-secondary:hover {
	background: #f8fafc;
}

.stm-empty-inline {
	padding: 24px;
	border-radius: 16px;
	background: #f8fafc;
	text-align: center;
}

.stm-empty-inline .stm-empty-icon {
	font-size: 2rem;
	margin-bottom: 12px;
}

/* ════════════════════════════════════════════════════════════════
   REPLY CARD (ADMIN)
   ════════════════════════════════════════════════════════════════ */

.stm-reply-list {
	display: flex;
	flex-direction: column;
	gap: 20px;
	margin: 20px 0;
}

.stm-reply-card {
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: 12px;
	padding: 24px;
	transition: var(--stm-transition);
	overflow: hidden;
	position: relative;
}

.stm-reply-card::before {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	width: 4px;
	height: 100%;
	background: var(--stm-border);
	transition: var(--stm-transition);
}

.stm-reply-card.stm-cat-financial::before { background: #059669; }
.stm-reply-card.stm-cat-warranty::before { background: #dc2626; }
.stm-reply-card.stm-cat-support::before { background: #2563eb; }
.stm-reply-card.stm-cat-exchange::before { background: #7c3aed; }
.stm-reply-card.stm-cat-services::before { background: #d97706; }

.stm-reply-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--stm-shadow-lg);
	border-color: rgba(79, 70, 229, 0.12);
}

.stm-reply-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 16px;
	gap: 12px;
	flex-wrap: wrap;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--stm-border);
}

.stm-reply-title h3 {
	margin: 0 0 6px;
	font-size: 1.1rem;
	color: var(--stm-text);
	font-weight: 700;
}

.stm-reply-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	font-size: 0.85rem;
	color: var(--stm-text-muted);
	margin-bottom: 16px;
	padding-bottom: 12px;
	border-bottom: 1px solid #f1f1f1;
}

.stm-ticket-message,
.stm-admin-reply-preview {
	margin-bottom: 16px;
	padding-bottom: 12px;
	border-bottom: 1px solid #f1f1f1;
}

.stm-ticket-message:last-child,
.stm-admin-reply-preview:last-child {
	margin-bottom: 0;
	border-bottom: none;
	padding-bottom: 0;
}

.stm-ticket-message h4,
.stm-admin-reply-preview h4 {
	margin: 0 0 10px;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--stm-text);
	text-transform: uppercase;
	letter-spacing: 0.3px;
}

.stm-message-content {
	background: var(--stm-bg);
	padding: 12px 14px;
	border-radius: 8px;
	line-height: 1.7;
	font-size: 0.9rem;
	color: var(--stm-text);
}

.stm-message-content p {
	margin: 0 0 8px;
}

.stm-message-content p:last-child {
	margin-bottom: 0;
}

.stm-reply-date {
	display: block;
	margin-top: 8px;
	font-size: 0.8rem;
	color: var(--stm-text-muted);
}

.stm-form-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 18px;
}

.stm-form-actions .button {
	min-width: 160px;
	padding: 12px 18px;
	border-radius: 12px;
}

.stm-single-reply {
	display: grid;
	gap: 26px;
}

.stm-single-reply .stm-reply-card {
	padding: 28px;
}

@media (max-width: 860px) {
	.stm-filters,
	.stm-reply-filters {
		flex-direction: column;
		align-items: stretch;
	}

	.stm-filter-group,
	.stm-filter-actions {
		width: 100%;
	}

	.stm-table thead {
		display: none;
	}

	.stm-table,
	.stm-table tbody,
	.stm-table tr,
	.stm-table td {
		display: block;
		width: 100%;
	}

	.stm-table td {
		padding: 16px 14px;
		border-bottom: 1px solid rgba(229,231,235,0.95);
	}

	.stm-table td:nth-child(1):before { content: 'شناسه:'; }
	.stm-table td:nth-child(2):before { content: 'کاربر:'; }
	.stm-table td:nth-child(3):before { content: 'موضوع:'; }
	.stm-table td:nth-child(4):before { content: 'دسته:'; }
	.stm-table td:nth-child(5):before { content: 'وضعیت:'; }
	.stm-table td:nth-child(6):before { content: 'تاریخ:'; }
	.stm-table td:nth-child(7):before { content: 'اقدامات:'; }

	.stm-table td:before {
		display: block;
		font-weight: 700;
		margin-bottom: 6px;
		color: var(--stm-text);
	}
}

/* ════════════════════════════════════════════════════════════════
   REPLY FORM
   ════════════════════════════════════════════════════════════════ */

.stm-reply-form {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1.5px solid var(--stm-border);
}

.stm-field {
	margin-bottom: 18px;
}

.stm-field label {
	display: block;
	margin-bottom: 8px;
	font-weight: 600;
	font-size: 0.85rem;
	color: var(--stm-text);
	text-transform: uppercase;
	letter-spacing: 0.2px;
}

.stm-field .required {
	color: var(--stm-error);
	margin-right: 4px;
}

.stm-field input,
.stm-field select,
.stm-field textarea,
.stm-reply-form input,
.stm-reply-form select,
.stm-reply-form textarea {
	width: 100%;
	padding: 11px 13px;
	border: 1.5px solid var(--stm-border);
	border-radius: 8px;
	font-size: 0.9rem;
	font-family: inherit;
	background: var(--stm-bg);
	color: var(--stm-text);
	transition: var(--stm-transition);
	line-height: 1.5;
}

.stm-field input:focus,
.stm-field select:focus,
.stm-field textarea:focus,
.stm-reply-form input:focus,
.stm-reply-form select:focus,
.stm-reply-form textarea:focus {
	outline: none;
	border-color: var(--stm-primary);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.stm-field.stm-field-error input,
.stm-field.stm-field-error select,
.stm-field.stm-field-error textarea {
	border-color: var(--stm-error);
	background: rgba(220, 38, 38, 0.04);
}

.stm-field-error-msg {
	display: block;
	margin-top: 5px;
	font-size: 0.75rem;
	color: var(--stm-error);
	font-weight: 600;
}

/* ════════════════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap .button,
.wrap.stm-wrap .button-primary,
.wrap.stm-wrap .stm-btn {
	border-radius: 8px;
	font-weight: 700;
	padding: 10px 16px;
	font-size: 0.85rem;
	border: none;
	cursor: pointer;
	transition: var(--stm-transition);
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.wrap.stm-wrap .button-primary,
.wrap.stm-wrap .stm-btn-primary {
	background: var(--stm-primary);
	color: #fff;
	box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.wrap.stm-wrap .button-primary:hover,
.wrap.stm-wrap .stm-btn-primary:hover {
	background: var(--stm-primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.wrap.stm-wrap .button-secondary {
	background: var(--stm-card);
	color: var(--stm-text);
	border: 1.5px solid var(--stm-border);
}

.wrap.stm-wrap .button-secondary:hover {
	background: var(--stm-bg);
	border-color: var(--stm-primary);
	color: var(--stm-primary);
}

.stm-button-large {
	padding: 12px 20px;
	font-size: 0.9rem;
}

/* ════════════════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap .stm-pagination {
	margin-top: 28px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 16px;
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: 10px;
	justify-content: center;
}

.wrap.stm-wrap .stm-pagination a,
.wrap.stm-wrap .stm-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 8px;
	text-align: center;
	border-radius: 6px;
	background: #fff;
	border: 1.5px solid var(--stm-border);
	color: var(--stm-text);
	font-weight: 600;
	font-size: 0.85rem;
	transition: var(--stm-transition);
	text-decoration: none;
}

.wrap.stm-wrap .stm-pagination a:hover,
.wrap.stm-wrap .stm-pagination a:focus {
	background: var(--stm-primary-light);
	border-color: var(--stm-primary);
	color: var(--stm-primary);
	transform: translateY(-2px);
}

.wrap.stm-wrap .stm-pagination .current {
	background: var(--stm-primary);
	color: #fff;
	border-color: var(--stm-primary);
	cursor: default;
}

/* ════════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════════ */

.stm-empty-state {
	text-align: center;
	padding: 50px 30px;
	color: var(--stm-text-muted);
	background: var(--stm-bg);
	border-radius: 12px;
	border: 2px dashed var(--stm-border);
	margin: 20px 0;
}

.stm-empty-icon {
	font-size: 3rem;
	margin-bottom: 16px;
	display: block;
	opacity: 0.6;
}

.stm-empty-state p {
	margin: 0 0 8px;
	font-weight: 600;
	color: var(--stm-text);
	font-size: 1rem;
}

.stm-empty-state span {
	font-size: 0.85rem;
	color: var(--stm-text-muted);
}

/* ════════════════════════════════════════════════════════════════
   ADMIN NOTICES
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap .notice,
.stm-notice {
	margin: 16px 0 20px;
	padding: 14px 16px;
	border-left: 4px solid transparent;
	border-radius: 8px;
	font-size: 0.9rem;
	line-height: 1.6;
	animation: slideIn 300ms ease-out;
}

@keyframes slideIn {
	from {
		opacity: 0;
		transform: translateX(-20px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

.wrap.stm-wrap .notice-success,
.stm-notice-success {
	background: #ecfdf5;
	border-left-color: var(--stm-success);
	color: #065f46;
}

.wrap.stm-wrap .notice-error,
.stm-notice-error {
	background: #fef2f2;
	border-left-color: var(--stm-error);
	color: #991b1b;
}

.wrap.stm-wrap .notice-warning,
.stm-notice-warning {
	background: #fffbeb;
	border-left-color: var(--stm-warning);
	color: #92400e;
}

/* ════════════════════════════════════════════════════════════════
   DASHBOARD RECENT
   ════════════════════════════════════════════════════════════════ */

.stm-dashboard-recent-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
	gap: 12px;
	flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════════════
   SINGLE REPLY VIEW
   ════════════════════════════════════════════════════════════════ */

.stm-single-reply {
	background: transparent;
}

.stm-form-actions {
	display: flex;
	gap: 12px;
	margin-top: 24px;
	flex-wrap: wrap;
}

.stm-form-actions .button {
	flex: 1;
	min-width: 180px;
	justify-content: center;
	padding: 12px 20px;
}

/* ════════════════════════════════════════════════════════════════
   FRONTEND STYLES
   ════════════════════════════════════════════════════════════════ */

.stm-portal {
	direction: rtl;
	text-align: right;
	font-family: var(--stm-font);
	max-width: 1200px;
	margin: 0 auto 48px;
	padding: 0 16px;
}

.stm-portal * {
	box-sizing: border-box;
}

.stm-portal-header {
	background: linear-gradient(135deg, var(--stm-primary) 0%, #7c3aed 100%);
	border-radius: var(--stm-radius);
	padding: 32px;
	margin-bottom: 28px;
	color: #fff;
	box-shadow: var(--stm-shadow-lg);
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 28px;
}

.stm-portal-header-content {
	display: flex;
	align-items: center;
	gap: 18px;
	flex: 1;
	min-width: 240px;
}

.stm-portal-icon {
	width: 52px;
	height: 52px;
	background: rgba(255, 255, 255, 0.18);
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 1.8rem;
}

.stm-portal-title {
	margin: 0 0 4px;
	font-size: 1.5rem;
	font-weight: 800;
	color: #fff;
}

.stm-portal-subtitle {
	margin: 0;
	font-size: 0.9rem;
	opacity: 0.9;
	line-height: 1.6;
}

.stm-portal-stats {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.stm-portal-stat {
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 10px;
	padding: 12px 18px;
	text-align: center;
	min-width: 100px;
	transition: var(--stm-transition);
}

.stm-portal-stat:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: translateY(-2px);
}

.stm-portal-stat-num {
	display: block;
	font-size: 1.8rem;
	font-weight: 800;
	line-height: 1;
}

.stm-portal-stat-label {
	display: block;
	font-size: 0.75rem;
	opacity: 0.85;
	margin-top: 6px;
}

.stm-portal-grid {
	display: grid;
	grid-template-columns: 1fr 1.2fr;
	gap: 28px;
	align-items: start;
}

.stm-panel {
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: var(--stm-radius);
	box-shadow: var(--stm-shadow);
	overflow: hidden;
	transition: var(--stm-transition);
}

.stm-panel:hover {
	box-shadow: var(--stm-shadow-lg);
	border-color: rgba(79, 70, 229, 0.12);
}

.stm-panel-head {
	padding: 24px;
	border-bottom: 1.5px solid var(--stm-border);
	background: linear-gradient(180deg, #fafafa 0%, #fff 100%);
}

.stm-panel-title {
	margin: 0 0 6px;
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--stm-text);
}

.stm-panel-desc {
	margin: 0;
	font-size: 0.85rem;
	color: var(--stm-text-muted);
	line-height: 1.5;
}

.stm-panel-form .stm-form,
.stm-panel-history .stm-ticket-list {
	padding: 0 24px 24px;
}

.stm-form {
	display: flex;
	flex-direction: column;
	gap: 0;
}

.stm-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 13px 28px;
	border: none;
	border-radius: 10px;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	font-family: inherit;
	transition: var(--stm-transition);
	text-decoration: none;
}

.stm-btn-primary {
	background: var(--stm-primary);
	color: #fff;
	box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.stm-btn-primary:hover {
	background: var(--stm-primary-dark);
	transform: translateY(-2px);
	box-shadow: 0 6px 24px rgba(79, 70, 229, 0.4);
}

.stm-btn-block {
	width: 100%;
}

.stm-btn.is-loading {
	opacity: 0.7;
	pointer-events: none;
	cursor: wait;
}

.stm-guest-card {
	background: var(--stm-card);
	border: 1.5px solid var(--stm-border);
	border-radius: var(--stm-radius);
	box-shadow: var(--stm-shadow);
	padding: 48px 32px;
	text-align: center;
	max-width: 420px;
	margin: 0 auto;
}

.stm-guest-icon {
	font-size: 3rem;
	margin-bottom: 16px;
}

.stm-guest-card h2 {
	margin: 0 0 12px;
	font-size: 1.4rem;
	color: var(--stm-text);
}

.stm-guest-card p {
	color: var(--stm-text-muted);
	margin: 0 0 24px;
	line-height: 1.6;
	font-size: 0.95rem;
}

.stm-ticket-list {
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-height: none;
	overflow-y: visible;
	padding: 24px;
}

.stm-ticket-card {
	border: 1.5px solid var(--stm-border);
	border-radius: 12px;
	overflow: hidden;
	background: var(--stm-bg);
	transition: var(--stm-transition);
}

.stm-ticket-card:hover {
	box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
	border-color: var(--stm-primary-light);
	transform: translateY(-2px);
}

.stm-ticket-card-head {
	padding: 16px;
	background: var(--stm-card);
	border-bottom: 1.5px solid var(--stm-border);
}

.stm-ticket-card-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.stm-ticket-id {
	font-weight: 800;
	font-size: 0.9rem;
	color: var(--stm-primary);
}

.stm-ticket-subject {
	margin: 0 0 10px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--stm-text);
	line-height: 1.4;
}

.stm-ticket-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	font-size: 0.78rem;
	color: var(--stm-text-muted);
}

.stm-ticket-cat {
	background: var(--stm-primary-light);
	color: var(--stm-primary);
	padding: 3px 10px;
	border-radius: 6px;
	font-weight: 600;
}

.stm-ticket-card-body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.stm-chat-bubble {
	border-radius: 10px;
	padding: 13px 15px;
	font-size: 0.875rem;
	line-height: 1.7;
}

.stm-chat-label {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	margin-bottom: 8px;
	opacity: 0.7;
}

.stm-chat-text {
	margin: 0;
}

.stm-chat-text p {
	margin: 0 0 6px;
}

.stm-chat-text p:last-child {
	margin-bottom: 0;
}

.stm-chat-user {
	background: #f1f5f9;
	border-right: 3px solid #94a3b8;
}

.stm-chat-admin {
	background: var(--stm-primary-light);
	border-right: 3px solid var(--stm-primary);
}

.stm-pending-badge {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 0.82rem;
	color: var(--stm-warning);
	font-weight: 600;
	padding: 10px 14px;
	background: #fffbeb;
	border-radius: 8px;
	border: 1px solid #fde68a;
}

.stm-pulse {
	width: 8px;
	height: 8px;
	background: var(--stm-warning);
	border-radius: 50%;
	animation: pulse 1.5s infinite;
}

@keyframes pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.5; transform: scale(0.85); }
}

/* ════════════════════════════════════════════════════════════════
   ACCESSIBILITY & FOCUS STYLES
   ════════════════════════════════════════════════════════════════ */

.wrap.stm-wrap a:focus,
.wrap.stm-wrap button:focus,
.wrap.stm-wrap .button:focus,
.wrap.stm-wrap input:focus,
.wrap.stm-wrap select:focus,
.wrap.stm-wrap textarea:focus,
.stm-portal a:focus {
	outline: 3px solid rgba(79, 70, 229, 0.2);
	outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
	.stm-portal-grid {
		grid-template-columns: 1fr;
	}

	.stm-stats-grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	}
}

@media (max-width: 768px) {
	.wrap.stm-wrap {
		padding: 16px;
	}

	.stm-portal-header {
		padding: 24px;
		flex-direction: column;
		text-align: center;
	}

	.stm-portal-header-content {
		flex-direction: column;
		justify-content: center;
	}

	.stm-portal-stats {
		justify-content: center;
		width: 100%;
	}

	.stm-stats-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 12px;
	}

	.stm-category-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.stm-filters {
		flex-direction: column;
	}

	.stm-filter-select,
	.stm-filter-input {
		width: 100%;
	}

	.stm-dashboard-recent-header {
		flex-direction: column;
		align-items: stretch;
	}

	.stm-dashboard-recent-header .button {
		width: 100%;
	}

	.wrap.stm-wrap table {
		font-size: 0.8rem;
	}

	.wrap.stm-wrap table th,
	.wrap.stm-wrap table td {
		padding: 10px 12px;
	}
}

@media (max-width: 480px) {
	.wrap.stm-wrap h1 {
		font-size: 1.6rem;
	}

	.stm-portal-header {
		padding: 16px;
	}

	.stm-portal-title {
		font-size: 1.2rem;
	}

	.stm-portal-subtitle {
		font-size: 0.8rem;
	}

	.stm-stat-number {
		font-size: 1.8rem;
	}

	.stm-stats-grid,
	.stm-category-grid {
		grid-template-columns: 1fr;
		gap: 10px;
	}

	.stm-panel-head,
	.stm-panel-form .stm-form,
	.stm-panel-history .stm-ticket-list {
		padding: 16px;
	}

	.stm-filters {
		padding: 12px;
	}

	.stm-btn,
	.button {
		width: 100%;
		justify-content: center;
	}

	.stm-form-actions {
		flex-direction: column;
	}

	.stm-form-actions .button {
		width: 100%;
		min-width: unset;
	}

	.wrap.stm-wrap table {
		display: block;
		overflow-x: auto;
	}
}

/* ════════════════════════════════════════════════════════════════
   PRINT STYLES & ACCESSIBILITY
   ════════════════════════════════════════════════════════════════ */

/* Screen reader only text */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

@media print {
	.wrap.stm-wrap .button,
	.stm-btn,
	.stm-filters {
		display: none;
	}

	.stm-portal-header {
		box-shadow: none;
		border: 1px solid #ddd;
	}
}
