/* إدارة التشغيل — Seren launcher (visual refresh) */

body.hub {
  display: block;
  min-height: 100vh;
  background-color: #f3efe6;
  background-image:
    radial-gradient(ellipse 90% 55% at 15% -5%, rgba(79, 88, 41, 0.14), transparent 55%),
    radial-gradient(ellipse 70% 45% at 95% 5%, rgba(184, 148, 102, 0.16), transparent 50%),
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(3, 105, 161, 0.08), transparent 55%),
    linear-gradient(168deg, #ebe4f3 0%, #f6f1e6 38%, #eef2e8 100%);
  background-attachment: fixed;
}

.hub-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.hub-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(circle at 1px 1px, rgba(79, 88, 41, 0.07) 1px, transparent 0);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 85%);
}

/* ── Header ── */

.hub-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 32px);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(79, 88, 41, 0.08);
  box-shadow: 0 4px 24px rgba(28, 28, 28, 0.04);
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hub-brand img {
  height: 40px;
  width: auto;
  background: linear-gradient(145deg, #faf6e8, #f0ead8);
  padding: 5px 10px;
  border-radius: 12px;
  border: 1px solid rgba(79, 88, 41, 0.08);
  box-shadow: 0 2px 8px rgba(79, 88, 41, 0.06);
}

.hub-brand strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.hub-brand span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
  margin-top: 2px;
}

.hub-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hub-user__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: rgba(79, 88, 41, 0.06);
  border: 1px solid rgba(79, 88, 41, 0.1);
}

.hub-user__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  flex-shrink: 0;
}

.hub-user .email {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary-700);
  direction: ltr;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.hub-btn:hover {
  background: var(--color-primary-50);
  box-shadow: 0 2px 8px rgba(79, 88, 41, 0.08);
}

.hub-btn:active {
  transform: scale(0.98);
}

.hub-btn--danger {
  color: var(--color-error);
  border-color: rgba(179, 38, 30, 0.2);
  background: #fffafa;
}

.hub-btn--danger:hover {
  background: #fde9e7;
  border-color: rgba(179, 38, 30, 0.35);
}

/* ── Main ── */

.hub-main {
  flex: 1;
  padding: clamp(24px, 5vw, 40px) clamp(16px, 4vw, 32px) 56px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hub-intro {
  text-align: center;
  margin-bottom: clamp(24px, 4vw, 36px);
}

.hub-intro__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(79, 88, 41, 0.12);
  box-shadow: 0 2px 12px rgba(79, 88, 41, 0.05);
}

.hub-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 900;
  color: var(--color-primary);
  letter-spacing: -0.03em;
}

.hub-intro p {
  margin: 0 auto;
  max-width: 420px;
  color: var(--color-muted);
  font-size: 15px;
  line-height: 1.65;
}

/* ── App grid ── */

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (min-width: 640px) {
  .app-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (min-width: 900px) {
  .app-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
}

.app-tile {
  --app-color: #4f5829;
  position: relative;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 1px 2px rgba(28, 28, 28, 0.04),
    0 8px 24px rgba(28, 28, 28, 0.05);
  transition:
    transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1),
    box-shadow 0.2s ease,
    border-color 0.2s ease;
  overflow: hidden;
}

.app-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(79, 88, 41, 0.08));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.6;
}

.app-tile::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--app-color);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.app-tile:hover {
  transform: translateY(-4px);
  box-shadow:
    0 4px 8px rgba(28, 28, 28, 0.04),
    0 16px 40px rgba(28, 28, 28, 0.1);
  border-color: color-mix(in srgb, var(--app-color) 25%, white);
}

.app-tile:hover::after {
  opacity: 1;
}

.app-tile:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--app-color) 40%, white);
  outline-offset: 3px;
}

.app-tile__icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(
    145deg,
    color-mix(in srgb, var(--app-color) 92%, white),
    var(--app-color)
  );
  box-shadow:
    0 8px 20px color-mix(in srgb, var(--app-color) 35%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease;
}

.app-tile:hover .app-tile__icon {
  transform: scale(1.05);
}

.app-tile__icon svg {
  width: 30px;
  height: 30px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-tile__name {
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  color: #1f1f1f;
  line-height: 1.35;
}

.app-tile__desc {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.5;
  max-width: 100%;
}

.app-tile__arrow {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--color-muted);
  background: rgba(79, 88, 41, 0.05);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-tile:hover .app-tile__arrow {
  opacity: 1;
  transform: translate(0, 0);
}

/* ── Footer note ── */

.hub-note {
  margin-top: clamp(28px, 5vw, 40px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: right;
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-primary-700);
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  border: 1px solid rgba(79, 88, 41, 0.1);
  box-shadow: 0 4px 16px rgba(79, 88, 41, 0.04);
}

.hub-note__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: var(--color-primary-50);
}

.hub-note strong {
  color: var(--color-primary);
  font-weight: 800;
  direction: ltr;
  display: inline-block;
}

.hub-footer {
  text-align: center;
  padding: 0 16px 20px;
  font-size: 11px;
  color: rgba(107, 107, 107, 0.8);
  position: relative;
  z-index: 1;
}

/* ── Login page (hub) ── */

body.hub-login {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(79, 88, 41, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(184, 148, 102, 0.12), transparent),
    linear-gradient(165deg, #ebe4f3 0%, #f4efe0 45%, #eef2e8 100%);
  background-attachment: fixed;
}

body.hub-login .card.login-card {
  border: 1px solid rgba(79, 88, 41, 0.08);
  box-shadow:
    0 4px 6px rgba(28, 28, 28, 0.02),
    0 20px 50px rgba(28, 28, 28, 0.08);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.5;
}

.alert--error {
  background: #fde9e7;
  color: var(--color-error);
  border: 1px solid #f1b9b5;
}

.login-card .field input[type="email"],
.login-card .field input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-alt);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card .field input[type="email"] {
  direction: ltr;
}

.login-card .field input[type="email"]:focus,
.login-card .field input[type="password"]:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 88, 41, 0.1);
}

.login-card .field input[readonly] {
  background: #f0ece2;
  color: var(--color-muted);
  cursor: default;
}

@media (max-width: 480px) {
  .hub-user .email {
    max-width: 140px;
  }

  .app-tile {
    padding: 16px 10px 14px;
  }

  .app-tile__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
  }

  .app-tile__icon svg {
    width: 26px;
    height: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-tile,
  .app-tile__icon,
  .hub-btn {
    transition: none !important;
  }
}
