/* Theme Overrides: Modern, clean, elegant dashboard styles */

/* Typography */
:root {
	--font-sans: "Inter", "Tajawal", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
	--color-bg: #0b0f1a; /* deep blue-gray for app chrome */
	--color-surface: #0f1525; /* surface for cards/sidebar */
	--color-surface-2: #12192b; /* hover/raised */
	--color-text: #e7ecf3; /* primary text */
	--color-text-muted: #a7b1c2; /* secondary text */
	--color-primary: #7c5cff; /* accent similar to Linear */
	--color-primary-600: #6a47ff;
	--color-primary-700: #5a38ff;
	--color-success: #22c55e;
	--color-warning: #f59e0b;
	--color-danger: #ef4444;
	--shadow-sm: 0 6px 16px rgba(0,0,0,0.24), 0 1px 2px rgba(0,0,0,0.4);
	--shadow-md: 0 12px 24px rgba(0,0,0,0.28), 0 2px 6px rgba(0,0,0,0.5);
	--radius-sm: 10px;
	--radius-md: 14px;
	--radius-lg: 18px;
}

html, body {
	font-family: var(--font-sans);
	background: linear-gradient(180deg, #0b0f1a 0%, #0c1324 100%) fixed;
	color: var(--color-text);
}

/* Layout Shell */
.layout-wrapper.layout-content-navbar {
	background: transparent;
}

.layout-menu.menu-vertical.menu.bg-menu-theme {
	background: linear-gradient(180deg, var(--color-surface) 0%, #0e1424 100%);
	border-right: 1px solid rgba(255,255,255,0.06);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.app-brand .app-brand-text {
	color: var(--color-text);
	letter-spacing: 0.2px;
}

.menu-inner .menu-item > .menu-link {
	color: var(--color-text-muted);
	border-radius: var(--radius-sm);
	margin: 4px 10px;
	padding: 10px 12px;
	transition: background 0.2s ease, color 0.2s ease, transform 0.06s ease;
}
.menu-inner .menu-item.active > .menu-link,
.menu-inner .menu-item > .menu-link:hover {
	background: linear-gradient(180deg, rgba(124,92,255,0.14) 0%, rgba(124,92,255,0.06) 100%);
	color: #ffffff;
}
.menu-inner .menu-icon {
	color: var(--color-text-muted);
}

/* Navbar */
.navbar.bg-navbar-theme, .layout-navbar {
	background: rgba(18, 25, 43, 0.75) !important;
	backdrop-filter: blur(10px);
	border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Content container */
.container-xxl.container-p-y {
	padding-top: 24px;
	padding-bottom: 24px;
}

/* Cards */
.card, .shadow-card {
	background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-2) 100%);
	border: 1px solid rgba(255,255,255,0.06);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	color: var(--color-text);
}
.card.glassy {
	background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.03) 100%);
	backdrop-filter: blur(8px);
	border-color: rgba(255,255,255,0.08);
}
.card .card-header, .card-header {
	background: transparent;
	border-bottom: 1px solid rgba(255,255,255,0.06);
	color: var(--color-text);
}

/* Buttons */
.btn, .custom-button {
	border-radius: 10px;
	border: 1px solid transparent;
	transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:active, .custom-button:active {
	transform: translateY(1px);
}
.btn-primary, .custom-button {
	background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
	border-color: rgba(124,92,255,0.5);
	color: #fff;
	box-shadow: 0 8px 18px rgba(124,92,255,0.25);
}
.btn-primary:hover, .custom-button:hover {
	background: linear-gradient(180deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
	box-shadow: 0 10px 22px rgba(124,92,255,0.32);
}
.btn-outline-secondary {
	border-color: rgba(255,255,255,0.12);
	color: var(--color-text);
}

/* Forms */
.form-control, .form-select, input[type="text"], input[type="number"], input[type="file"], select, textarea {
	background: rgba(255,255,255,0.04);
	border: 1px solid rgba(255,255,255,0.12);
	color: var(--color-text);
	border-radius: 10px;
}
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
	border-color: rgba(124,92,255,0.6);
	box-shadow: 0 0 0 3px rgba(124,92,255,0.2);
	background: rgba(255,255,255,0.06);
	color: #fff;
}
label { color: var(--color-text-muted); }

/* Tables */
.table {
	--row-bg: rgba(255,255,255,0.02);
	--row-border: rgba(255,255,255,0.06);
	color: var(--color-text);
	border-color: var(--row-border);
}
.table thead th {
	color: var(--color-text);
	background: rgba(255,255,255,0.04);
	border-bottom: 1px solid var(--row-border);
}
.table tbody tr { background: var(--row-bg); }
.table tbody tr:hover { background: rgba(255,255,255,0.06); }
.table td, .table th { border-color: var(--row-border); }

/* Footer */
footer.bg-light {
	background: rgba(18, 25, 43, 0.75) !important;
	border-top: 1px solid rgba(255,255,255,0.06);
	color: var(--color-text-muted);
}

/* Utilities */
.text-muted { color: var(--color-text-muted) !important; }
.text-primary { color: var(--color-primary) !important; }
.bg-surface { background: var(--color-surface) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }

/* Sidebar collapse behavior - القائمة على اليمين */
/* قاعدة عامة: تطبيق RTL */
html, body {
	direction: rtl !important;
}

.layout-container {
	direction: rtl !important;
}

/* التأكد من RTL في جميع عناصر القائمة */
#layout-menu {
	direction: rtl !important;
}

#layout-menu .menu-inner {
	direction: rtl !important;
}

#layout-menu .menu-link {
	direction: rtl !important;
	text-align: right !important;
}

@media (min-width: 1200px) {
	/* قلب الترتيب */
	.layout-container {
		flex-direction: row-reverse !important;
		direction: rtl !important;
	}
	
	/* القائمة على اليمين */
	#layout-menu {
		order: 2 !important;
		border-right: none !important;
		border-left: 1px solid rgba(255,255,255,0.06) !important;
		left: auto !important;
		right: 0 !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
	
	/* المحتوى مع padding من اليمين */
	.layout-page {
		order: 1 !important;
		padding-left: 0 !important;
		padding-right: 16.25rem !important;
		transition: padding-right 0.3s ease !important;
	}
	
	.sidebar-collapsed #layout-menu {
		transform: none !important;
		opacity: 1 !important;
		margin-left: 0 !important;
		margin-right: -16.25rem !important;
		transition: margin-right 0.3s ease;
		left: auto !important;
		right: -16.25rem !important;
	}

	.sidebar-collapsed .layout-page {
		margin-left: 0 !important;
		margin-right: 0 !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
		transition: padding-right 0.3s ease;
	}
}

/* التابلت: القائمة على اليمين */
@media (min-width: 768px) and (max-width: 1199.98px) {
	.layout-container {
		flex-direction: row-reverse !important;
		direction: rtl !important;
	}
	
	#layout-menu {
		order: 2 !important;
		border-right: none !important;
		border-left: 1px solid rgba(255,255,255,0.06) !important;
		left: auto !important;
		right: 0 !important;
	}
	
	.layout-page {
		order: 1 !important;
	}
	
	html:not(.layout-menu-collapsed) #layout-menu,
	body:not(.sidebar-collapsed) #layout-menu {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
	}
	
	html.layout-menu-collapsed #layout-menu,
	body.sidebar-collapsed #layout-menu {
		display: none !important;
		visibility: hidden !important;
		opacity: 0 !important;
	}
}

/* Ensure default spacing when visible */
#layout-menu {
	transition: margin-left 0.3s ease, margin-right 0.3s ease;
}

@media (max-width: 767.98px) {
	/* تطبيق RTL على container */
	.layout-container {
		direction: rtl !important;
	}
	
	#layout-menu {
		direction: rtl !important;
		position: fixed !important;
		right: -260px !important;
		left: auto !important;
	}
	
	/* عند فتح القائمة - تظهر من اليمين */
	#layout-menu.menu-show {
		transform: none !important;
		opacity: 1 !important;
		right: 0 !important;
		left: auto !important;
		position: fixed !important;
	}
	
	/* التأكد من أن القائمة مخفية عند تحميل الصفحة */
	#layout-menu:not(.menu-show) {
		right: -260px !important;
		left: auto !important;
		transform: none !important;
		position: fixed !important;
	}
	
	/* منع ظهور القائمة تلقائياً */
	html.layout-menu-expanded #layout-menu:not(.menu-show) {
		right: -260px !important;
		left: auto !important;
		transform: none !important;
	}
	
	body.sidebar-collapsed #layout-menu:not(.menu-show) {
		right: -260px !important;
		left: auto !important;
		transform: none !important;
	}
	
	/* في RTL: دفع المحتوى لليمين عند فتح القائمة */
	body.sidebar-open-mobile .layout-page {
		transform: translateX(260px) !important;
	}
	
	/* التأكد من RTL في عناصر القائمة */
	#layout-menu .menu-inner {
		direction: rtl !important;
	}
	
	#layout-menu .menu-link {
		direction: rtl !important;
		text-align: right !important;
	}
}

/* Entry reveal animations */
@keyframes fadeSlideUp {
	0% { opacity: 0; transform: translateY(12px) scale(.98); }
	100% { opacity: 1; transform: translateY(0) scale(1); }
}
.reveal-once { opacity: 0; }
.reveal-once.is-visible { opacity: 1; animation: fadeSlideUp 520ms cubic-bezier(.2,.6,.4,1) forwards; }

/* Home tiles */
.tile-grid {
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	gap: 18px;
	align-items: stretch;
}

@media (max-width: 575.98px) {
	.tile-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 576px) and (max-width: 991.98px) {
	.tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 992px) and (max-width: 1399.98px) {
	.tile-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1400px) {
	.tile-grid { grid-template-columns: repeat(6, 1fr); }
}

.tile-card {
	grid-column: span 2;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	min-height: 140px;
	padding: 18px;
	background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-2) 100%);
	border: 1px solid rgba(255,255,255,0.06);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm);
	color: var(--color-text);
	text-decoration: none;
	position: relative;
	overflow: hidden;
	transition: transform .18s ease, box-shadow .25s ease, border-color .25s ease, filter .25s ease;
}

.tile-card .tile-icon {
	font-size: 36px;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 14px;
	margin-bottom: 12px;
	background: rgba(255,255,255,0.06);
	border: 1px solid rgba(255,255,255,0.08);
}

.tile-card .tile-label {
	font-weight: 600;
	letter-spacing: .2px;
}

.tile-card::after {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(120px 120px at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,.08), transparent 60%);
	opacity: 0;
	transition: opacity .25s ease;
}

.tile-card:hover {
	transform: translateY(-2px) scale(1.01);
	box-shadow: var(--shadow-md);
	border-color: rgba(124,92,255,0.35);
}
.tile-card:hover::after { opacity: 1; }
.tile-card:active { transform: translateY(0) scale(.995); filter: brightness(1.02); }

/* Soft, modern color assignments that work on dark/light */
.tile-chat .tile-icon { background: rgba(124,92,255,0.18); border-color: rgba(124,92,255,0.35); color: #b9a7ff; }
.tile-categories .tile-icon { background: rgba(56,189,248,0.18); border-color: rgba(56,189,248,0.35); color: #7dd3fc; }
.tile-subcategories .tile-icon { background: rgba(99,102,241,0.18); border-color: rgba(99,102,241,0.35); color: #a5b4fc; }
.tile-products .tile-icon { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.35); color: #86efac; }
.tile-slider .tile-icon { background: rgba(250,204,21,0.18); border-color: rgba(250,204,21,0.35); color: #fde68a; }
.tile-discount .tile-icon { background: rgba(244,63,94,0.18); border-color: rgba(244,63,94,0.35); color: #fca5a5; }
.tile-users .tile-icon { background: rgba(236,72,153,0.18); border-color: rgba(236,72,153,0.35); color: #f9a8d4; }
.tile-orders .tile-icon { background: rgba(147,197,253,0.18); border-color: rgba(147,197,253,0.35); color: #bfdbfe; }
.tile-delivery .tile-icon { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.35); color: #6ee7b7; }

/* Light theme adjustments when body not dark */
body:not(.theme-dark) .tile-card {
	background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
	border-color: rgba(17,24,39,0.08);
	color: #0f172a;
}
body:not(.theme-dark) .tile-card .tile-icon { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.08); }
body:not(.theme-dark) .tile-card:hover { border-color: rgba(124,92,255,0.45); }

/* Pointer glow follows mouse */
.tile-card{
	--mx: 50%;
	--my: 0%;
}

/* Search input in navbar */
#layout-navbar .input-group .form-control {
	background: rgba(255,255,255,0.04) !important;
	border: 1px solid rgba(255,255,255,0.12) !important;
	color: var(--color-text) !important;
}
#layout-navbar .input-group-text { background: transparent; color: var(--color-text-muted); border: none; }

/* Menu header text */
.menu-header-text { color: var(--color-text-muted) !important; letter-spacing: .3px; font-weight: 600; }

/* Scrollbar (WebKit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* Chat specific (non-functional styling only) */
.chat-container, .chat-panel {
	background: var(--color-surface);
	border: 1px solid rgba(255,255,255,0.06);
	border-radius: var(--radius-md);
}

/* Auth pages */
.page-auth .card { backdrop-filter: blur(8px); }
