/*--------------------------------------------------------------
 * Elite Mobile Sidebar v2.0 — Premium Styles
 * Inspired by EgyChip tabs + Hostinger clean layout
 *--------------------------------------------------------------*/

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
	--ems-z-panel: 999999;
	--ems-z-overlay: 999998;
	--ems-z-toggle: 999997;
	--ems-speed: 380ms;
	--ems-ease: cubic-bezier(0.32, 0.72, 0, 1);
	--ems-radius: 0px;
	--ems-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--ems-color-primary: #2563eb;
	--ems-color-text: #1e293b;
	--ems-color-text-muted: #64748b;
	--ems-color-border: rgba(0, 0, 0, 0.06);
	--ems-color-bg: #ffffff;
	--ems-color-surface: #f8fafc;
}

/* ============================================================
   RESET
   ============================================================ */
.ems-wrap,
.ems-wrap * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.ems-wrap {
	font-family: var(--ems-font);
	line-height: 1.55;
	-webkit-text-size-adjust: 100%;
}

/* ============================================================
   TOGGLE BUTTON
   ============================================================ */
.ems-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	border: none;
	cursor: pointer;
	position: relative;
	z-index: var(--ems-z-toggle);
	outline: none;
	-webkit-tap-highlight-color: transparent;
	font-family: var(--ems-font);
	transition: transform 0.2s ease, opacity 0.2s ease;
	background: transparent;
	color: inherit;
}

.ems-toggle:active {
	transform: scale(0.92);
}

/* Icon-only */
.ems-toggle--icon {
	width: 44px;
	height: 44px;
	border-radius: 12px;
	background: var(--ems-color-primary);
	color: #fff;
}

/* Text / Icon+Text */
.ems-toggle--text,
.ems-toggle--icon-text {
	padding: 10px 20px;
	border-radius: 50px;
	font-weight: 600;
	font-size: 13px;
	letter-spacing: 0.5px;
	text-transform: uppercase;
}

.ems-toggle__label {
	font-size: inherit;
	font-weight: inherit;
}

/* Fixed position */
.ems-toggle--fixed {
	position: fixed !important;
	z-index: var(--ems-z-toggle);
}

.ems-toggle--top-left    { top: 16px; left: 16px; }
.ems-toggle--top-right   { top: 16px; right: 16px; }
.ems-toggle--bottom-left { bottom: 16px; left: 16px; }
.ems-toggle--bottom-right { bottom: 16px; right: 16px; }

/* Open / Close icon swap */
.ems-toggle__close {
	display: none;
}

.ems-wrap.ems-is-open .ems-toggle__open {
	display: none !important;
}

.ems-wrap.ems-is-open .ems-toggle__close {
	display: inline-flex !important;
}

.ems-toggle i,
.ems-toggle svg {
	width: 20px;
	height: 20px;
	font-size: 20px;
	transition: transform 0.2s ease;
}

/* ============================================================
   OVERLAY
   ============================================================ */
.ems-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--ems-z-overlay);
	background: rgba(0, 0, 0, 0.35);
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--ems-speed) var(--ems-ease),
				visibility 0s linear var(--ems-speed);
	-webkit-tap-highlight-color: transparent;
}

.ems-wrap.ems-is-open .ems-overlay {
	opacity: 1;
	visibility: visible;
	transition: opacity var(--ems-speed) var(--ems-ease),
				visibility 0s linear 0s;
}

/* ============================================================
   SIDEBAR PANEL
   ============================================================ */
.ems-panel {
	position: fixed;
	top: 0;
	height: 100%;
	height: 100dvh;
	z-index: var(--ems-z-panel);
	background: var(--ems-color-bg);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	visibility: hidden;
	will-change: transform;
	-webkit-overflow-scrolling: touch;
	border-radius: var(--ems-radius);
	box-shadow: -2px 0 24px rgba(0, 0, 0, 0.08);
}

/* Scrollbar */
.ems-panel::-webkit-scrollbar {
	width: 3px;
}
.ems-panel::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,0.12);
	border-radius: 3px;
}

/* Direction */
.ems-panel--left {
	left: 0;
	transform: translateX(-100%);
	box-shadow: 2px 0 24px rgba(0, 0, 0, 0.08);
}

.ems-panel--right {
	right: 0;
	transform: translateX(100%);
}

/* Open */
.ems-wrap.ems-is-open .ems-panel {
	visibility: visible;
	transform: translateX(0);
	transition: transform var(--ems-speed) var(--ems-ease),
				visibility 0s linear 0s;
}

/* Close */
.ems-panel {
	transition: transform var(--ems-speed) var(--ems-ease),
				visibility 0s linear var(--ems-speed);
}

/* Fade animation */
.ems-wrap[data-ems-animation="fade"] .ems-panel {
	transform: none;
	opacity: 0;
	transition: opacity var(--ems-speed) var(--ems-ease),
				visibility 0s linear var(--ems-speed);
}

.ems-wrap[data-ems-animation="fade"].ems-is-open .ems-panel {
	opacity: 1;
	transition: opacity var(--ems-speed) var(--ems-ease),
				visibility 0s linear 0s;
}

/* Scale animation */
.ems-wrap[data-ems-animation="scale"] .ems-panel--left {
	transform: translateX(-100%) scale(0.92);
}
.ems-wrap[data-ems-animation="scale"] .ems-panel--right {
	transform: translateX(100%) scale(0.92);
}
.ems-wrap[data-ems-animation="scale"].ems-is-open .ems-panel {
	transform: translateX(0) scale(1);
}

/* Glassmorphism */
.ems-panel.ems-glass {
	background: rgba(255, 255, 255, 0.82);
	backdrop-filter: blur(24px) saturate(180%);
	-webkit-backdrop-filter: blur(24px) saturate(180%);
	border-inline-start: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============================================================
   PANEL HEADER (close button, logo)
   ============================================================ */
.ems-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	flex-shrink: 0;
	border-bottom: 1px solid var(--ems-color-border);
	min-height: 60px;
}

.ems-close {
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: var(--ems-color-surface);
	border-radius: 50%;
	cursor: pointer;
	color: var(--ems-color-text);
	transition: all 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	flex-shrink: 0;
}

.ems-close:hover {
	background: #e2e8f0;
	transform: rotate(90deg);
}

.ems-close svg {
	width: 18px;
	height: 18px;
}

/* Logo */
.ems-logo {
	display: flex;
	align-items: center;
}

.ems-logo img {
	max-width: 100%;
	height: auto;
	display: block;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.ems-search {
	padding: 0 20px;
	flex-shrink: 0;
}

.ems-search__form {
	display: flex;
	position: relative;
}

.ems-search__input {
	width: 100%;
	padding: 11px 42px 11px 16px;
	border: 1px solid var(--ems-color-border);
	border-radius: 12px;
	font-size: 14px;
	font-family: var(--ems-font);
	background: var(--ems-color-surface);
	color: var(--ems-color-text);
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ems-search__input:focus {
	border-color: var(--ems-color-primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.ems-search__input::placeholder {
	color: var(--ems-color-text-muted);
}

[dir="rtl"] .ems-search__input {
	padding: 11px 16px 11px 42px;
}

.ems-search__submit {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	cursor: pointer;
	color: var(--ems-color-text-muted);
	padding: 4px;
	display: flex;
	transition: color 0.2s ease;
}

[dir="rtl"] .ems-search__submit {
	right: auto;
	left: 12px;
}

.ems-search__submit:hover {
	color: var(--ems-color-primary);
}

/* ============================================================
   TABS SYSTEM (EgyChip-style)
   ============================================================ */
.ems-tabs {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.ems-tabs__nav {
	display: flex;
	flex-shrink: 0;
	margin: 0 20px;
	border-bottom: 2px solid var(--ems-color-border);
	gap: 0;
}

.ems-tabs__btn {
	flex: 1;
	padding: 12px 16px;
	border: none;
	background: transparent;
	cursor: pointer;
	font-weight: 600;
	font-size: 14px;
	font-family: var(--ems-font);
	color: var(--ems-color-text-muted);
	position: relative;
	transition: color 0.25s ease;
	-webkit-tap-highlight-color: transparent;
	outline: none;
}

.ems-tabs__btn::after {
	content: '';
	position: absolute;
	bottom: -2px;
	left: 0;
	right: 0;
	height: 2px;
	background: var(--ems-color-primary);
	border-radius: 2px 2px 0 0;
	transform: scaleX(0);
	transition: transform 0.3s var(--ems-ease);
}

.ems-tabs__btn.ems-active {
	color: var(--ems-color-primary);
}

.ems-tabs__btn.ems-active::after {
	transform: scaleX(1);
}

/* Pill variant */
.ems-tabs--pill .ems-tabs__nav {
	border-bottom: none;
	background: var(--ems-color-surface);
	border-radius: 12px;
	padding: 4px;
	gap: 4px;
}

.ems-tabs--pill .ems-tabs__btn {
	border-radius: 8px;
	padding: 8px 16px;
	font-size: 13px;
}

.ems-tabs--pill .ems-tabs__btn::after {
	display: none;
}

.ems-tabs--pill .ems-tabs__btn.ems-active {
	background: #fff;
	color: var(--ems-color-text);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Tab content */
.ems-tabs__panel {
	display: none;
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	min-height: 0;
	-webkit-overflow-scrolling: touch;
}

.ems-tabs__panel.ems-active {
	display: block;
	animation: emsFadeUp 0.28s ease forwards;
}

@keyframes emsFadeUp {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PANEL BODY (scrollable area)
   ============================================================ */
.ems-panel__body {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: rgba(0,0,0,0.1) transparent;
}

.ems-panel__body::-webkit-scrollbar {
	width: 3px;
}
.ems-panel__body::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,0.1);
	border-radius: 3px;
}

/* ============================================================
   MENU LIST
   ============================================================ */
.ems-menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.ems-menu-item {
	list-style: none;
}

/* Item row */
.ems-item-row {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 0 20px;
	transition: background 0.15s ease;
}

.ems-item-row:hover {
	background: rgba(37, 99, 235, 0.03);
}

/* Link */
.ems-link {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: var(--ems-color-text);
	font-weight: 500;
	font-size: 15px;
	padding: 14px 0;
	min-height: 48px;
	transition: color 0.15s ease;
}

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

.ems-current .ems-link {
	color: var(--ems-color-primary);
	font-weight: 600;
}

.ems-item-text {
	flex: 1;
}

/* Item icon */
.ems-item-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	border-radius: 6px;
	overflow: hidden;
}

.ems-item-icon img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.ems-item-icon i,
.ems-item-icon svg {
	font-size: 16px;
	width: 16px;
	height: 16px;
	color: var(--ems-color-primary);
}

/* Dividers */
.ems-dividers .ems-menu-item {
	border-bottom: 1px solid var(--ems-color-border);
}

.ems-dividers .ems-menu-item:last-child {
	border-bottom: none;
}

/* ============================================================
   SUBMENU / ACCORDION
   ============================================================ */
.ems-submenu {
	list-style: none;
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	transition: max-height 0.35s var(--ems-ease),
				opacity 0.25s ease,
				padding 0.35s var(--ems-ease);
	background: var(--ems-color-surface);
	margin: 0 12px;
	border-radius: 10px;
	padding-top: 0;
	padding-bottom: 0;
}

.ems-submenu.ems-sub-open {
	opacity: 1;
	padding-top: 4px;
	padding-bottom: 4px;
}

.ems-submenu .ems-item-row {
	padding: 0 16px;
}

.ems-submenu .ems-link {
	font-size: 14px;
	font-weight: 400;
	color: var(--ems-color-text-muted);
	min-height: 40px;
	padding: 10px 0;
}

.ems-submenu .ems-link:hover {
	color: var(--ems-color-primary);
}

/* Arrow button */
.ems-arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	flex-shrink: 0;
	background: var(--ems-color-surface);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	color: var(--ems-color-text-muted);
	transition: all 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.ems-arrow:hover {
	background: #e2e8f0;
	color: var(--ems-color-text);
}

.ems-arrow svg {
	transition: transform 0.3s var(--ems-ease);
}

.ems-arrow[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

.ems-arrow[aria-expanded="true"] {
	background: rgba(37, 99, 235, 0.08);
	color: var(--ems-color-primary);
}

/* ============================================================
   STAGGER ANIMATION
   ============================================================ */
.ems-wrap[data-ems-stagger="true"] .ems-menu > .ems-menu-item,
.ems-wrap[data-ems-stagger="true"] .ems-logo,
.ems-wrap[data-ems-stagger="true"] .ems-search,
.ems-wrap[data-ems-stagger="true"] .ems-tabs__nav,
.ems-wrap[data-ems-stagger="true"] .ems-social,
.ems-wrap[data-ems-stagger="true"] .ems-footer {
	opacity: 0;
	transform: translateY(12px);
	transition: opacity 0.4s var(--ems-ease), transform 0.4s var(--ems-ease);
}

.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-menu > .ems-menu-item,
.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-logo,
.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-search,
.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-tabs__nav,
.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-social,
.ems-wrap[data-ems-stagger="true"].ems-is-open .ems-footer {
	opacity: 1;
	transform: translateY(0);
}

/* ============================================================
   SOCIAL MEDIA
   ============================================================ */
.ems-social {
	padding: 16px 20px;
	border-top: 1px solid var(--ems-color-border);
	flex-shrink: 0;
}

.ems-social__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.ems-social__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	text-decoration: none;
	color: var(--ems-color-text-muted);
	background: var(--ems-color-surface);
	transition: all 0.25s ease;
	-webkit-tap-highlight-color: transparent;
}

.ems-social__link:hover {
	color: #fff;
	background: var(--ems-color-primary);
	transform: translateY(-2px);
}

/* Shapes */
.ems-shape-circle .ems-social__link   { border-radius: 50%; }
.ems-shape-square .ems-social__link   { border-radius: 0; }
.ems-shape-rounded .ems-social__link  { border-radius: 10px; }

/* Hover animations */
.ems-hover-scale .ems-social__link:hover  { transform: scale(1.12); }
.ems-hover-rotate .ems-social__link:hover { transform: rotate(10deg) scale(1.08); }
.ems-hover-bounce .ems-social__link:hover { animation: emsBounce 0.4s ease; }

@keyframes emsBounce {
	0%, 100% { transform: translateY(0); }
	40%  { transform: translateY(-5px); }
	60%  { transform: translateY(-2px); }
}

.ems-social__label {
	font-size: 11px;
	margin-inline-start: 6px;
	font-weight: 500;
}

.ems-social__link i,
.ems-social__link svg {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

/* ============================================================
   MIDDLE SECTION
   ============================================================ */
.ems-middle {
	padding: 12px 20px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.ems-footer {
	padding: 12px 20px;
	border-top: 1px solid var(--ems-color-border);
	flex-shrink: 0;
}

.ems-footer__text {
	font-size: 12px;
	color: var(--ems-color-text-muted);
	text-align: center;
	margin: 0;
}

/* ============================================================
   NO MENU NOTICE
   ============================================================ */
.ems-empty {
	padding: 32px 20px;
	text-align: center;
	color: var(--ems-color-text-muted);
	font-size: 14px;
}

/* ============================================================
   BODY SCROLL LOCK
   ============================================================ */
html.ems-no-scroll,
html.ems-no-scroll body {
	overflow: hidden !important;
	touch-action: none;
	position: relative;
}

/* ============================================================
   DARK MODE
   ============================================================ */
.ems-dark .ems-panel {
	--ems-color-bg: #0f172a;
	--ems-color-surface: #1e293b;
	--ems-color-text: #e2e8f0;
	--ems-color-text-muted: #94a3b8;
	--ems-color-border: rgba(255, 255, 255, 0.06);
	color: #e2e8f0;
}

.ems-dark .ems-close {
	background: rgba(255, 255, 255, 0.08);
	color: #e2e8f0;
}
.ems-dark .ems-close:hover {
	background: rgba(255, 255, 255, 0.15);
}

.ems-dark .ems-arrow {
	background: rgba(255, 255, 255, 0.06);
	color: #94a3b8;
}
.ems-dark .ems-arrow:hover {
	background: rgba(255, 255, 255, 0.12);
}

.ems-dark .ems-panel.ems-glass {
	background: rgba(15, 23, 42, 0.85);
	border-color: rgba(255, 255, 255, 0.05);
}

/* Auto dark mode */
@media (prefers-color-scheme: dark) {
	.ems-auto .ems-panel {
		--ems-color-bg: #0f172a;
		--ems-color-surface: #1e293b;
		--ems-color-text: #e2e8f0;
		--ems-color-text-muted: #94a3b8;
		--ems-color-border: rgba(255, 255, 255, 0.06);
		color: #e2e8f0;
	}
	.ems-auto .ems-close {
		background: rgba(255, 255, 255, 0.08);
		color: #e2e8f0;
	}
	.ems-auto .ems-arrow {
		background: rgba(255, 255, 255, 0.06);
		color: #94a3b8;
	}
}

/* ============================================================
   RTL
   ============================================================ */
[dir="rtl"] .ems-item-row {
	flex-direction: row-reverse;
}

[dir="rtl"] .ems-link {
	flex-direction: row-reverse;
	text-align: right;
}

[dir="rtl"] .ems-social__list {
	direction: rtl;
}

/* ============================================================
   ELEMENTOR EDITOR
   ============================================================ */
.elementor-editor-active .ems-panel,
.elementor-editor-active .ems-toggle--fixed {
	z-index: 999 !important;
}

.elementor-editor-active .ems-overlay {
	z-index: 998 !important;
}

/* Ensure the toggle handles clicks properly without interfering with drag */
.elementor-editor-active .ems-toggle {
	pointer-events: auto;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 767px) {
	.ems-panel {
		width: 85vw !important;
		max-width: 100vw !important;
	}
}

@media (min-width: 768px) and (max-width: 1024px) {
	.ems-panel {
		max-width: 420px;
	}
}

@media print {
	.ems-wrap { display: none !important; }
}
