/* Anoar School — Phase 5 final product experience.
   Shared rhythm, calm reveal, richer empty states, and dashboard completion polish. */

:root {
  --ui5-page-gap: clamp(.82rem, 1.35vw, 1.12rem);
  --ui5-section-gap: clamp(.72rem, 1vw, .95rem);
  --ui5-card-pad: clamp(1rem, 1.55vw, 1.4rem);
  --ui5-card-radius: clamp(18px, 1.6vw, 23px);
  --ui5-soft-border: color-mix(in srgb, var(--primary) 11%, var(--line));
  --ui5-strong-border: color-mix(in srgb, var(--primary) 21%, var(--line));
  --ui5-soft-surface: color-mix(in srgb, var(--surface-strong) 96%, transparent);
  --ui5-muted-surface: color-mix(in srgb, var(--primary) 4%, var(--surface-strong));
  --ui5-reveal-distance: 12px;
}

/* One vertical rhythm for operational pages. */
body.ui5-enhanced .app-shell .main:not(.dashboard-main):not(.settings-main) {
  display: grid;
  align-content: start;
  gap: var(--ui5-page-gap);
}

body.ui5-enhanced .app-shell .main:not(.dashboard-main):not(.settings-main) > :is(
  .topbar,
  .alert,
  .subnav,
  .stats,
  .stats-grid,
  .panel,
  .dashboard-insights,
  .dashboard-balanced-row,
  .table-wrap,
  .pagination,
  .pagination-actions
) {
  margin-block: 0 !important;
}

body.ui5-enhanced .app-shell .main > .panel {
  border-radius: var(--ui5-card-radius);
}

/* Page headers share hierarchy without becoming oversized. */
body.ui5-enhanced .app-shell .topbar {
  isolation: isolate;
  min-height: 6rem;
  padding: clamp(1rem, 1.55vw, 1.35rem) clamp(1.05rem, 1.8vw, 1.55rem);
}

body.ui5-enhanced .app-shell .topbar::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset-inline-end: -4rem;
  inset-block-start: -5rem;
  width: 13rem;
  height: 13rem;
  border: 1.25rem solid color-mix(in srgb, var(--accent) 5%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

body.ui5-enhanced .app-shell .topbar h1 {
  margin: 0;
  text-wrap: balance;
}

body.ui5-enhanced .app-shell .topbar p {
  max-width: 68ch;
  margin: .38rem 0 0;
  text-wrap: pretty;
}

body.ui5-enhanced .topbar-actions {
  position: relative;
  z-index: 1;
}

/* Section cards read as deliberate work areas. */
body.ui5-enhanced .panel > :is(.section-title, h2:first-child, h3:first-child) {
  color: var(--theme-text-strong);
}

body.ui5-enhanced .panel > .section-title:first-child,
body.ui5-enhanced .panel > h2:first-child,
body.ui5-enhanced .panel > h3:first-child {
  margin-bottom: .85rem;
  padding-bottom: .72rem;
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 8%, var(--line));
}

body.ui5-enhanced .workflow-head,
body.ui5-enhanced .dashboard-section-head {
  align-items: center;
}

body.ui5-enhanced .workflow-head h2,
body.ui5-enhanced .dashboard-section-head h2 {
  text-wrap: balance;
}

body.ui5-enhanced .workflow-head p,
body.ui5-enhanced .dashboard-section-head p {
  text-wrap: pretty;
}

/* Statistics feel alive, while remaining calm during daily use. */
body.ui5-enhanced :is(.stats, .stats-grid) {
  gap: var(--ui5-section-gap);
}

body.ui5-enhanced .stat {
  position: relative;
  overflow: hidden;
  min-height: 7.3rem;
  align-content: center;
  padding: 1rem 1.05rem;
  border: 1px solid var(--ui5-soft-border);
  background:
    radial-gradient(12rem 8rem at 100% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    linear-gradient(180deg, var(--ui5-soft-surface), color-mix(in srgb, var(--surface) 94%, transparent));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary-deep) 5%, transparent);
}

body.ui5-enhanced .stat::after {
  content: "";
  position: absolute;
  inset-inline-end: .8rem;
  inset-block-start: .8rem;
  width: .46rem;
  height: .46rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 72%, var(--accent));
  opacity: .34;
}

body.ui5-enhanced .stat .label {
  color: var(--muted);
  font-weight: var(--font-weight-semibold, 600);
}

body.ui5-enhanced .stat .value {
  color: var(--theme-text-strong);
  font-variant-numeric: tabular-nums;
}

@media (hover: hover) and (pointer: fine) {
  body.ui5-enhanced .stat {
    transition: transform var(--motion-hover), border-color var(--motion-hover), box-shadow var(--motion-hover);
  }
  body.ui5-enhanced .stat:hover {
    transform: translateY(-2px);
    border-color: var(--ui5-strong-border);
    box-shadow: var(--elevation-2);
  }
}

/* Empty states: every dead end becomes a guided next step. */
body.ui5-enhanced :is(.empty-state, .empty-hint) {
  width: 100%;
  min-height: 13rem;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .68rem;
  padding: clamp(1.45rem, 4vw, 2.4rem);
  border: 1px dashed color-mix(in srgb, var(--primary) 22%, var(--line));
  border-radius: var(--ui5-card-radius);
  background:
    radial-gradient(20rem 10rem at 50% -15%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%),
    linear-gradient(180deg, var(--ui5-soft-surface), color-mix(in srgb, var(--surface) 92%, transparent));
  text-align: center;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 40%, transparent);
}

body.ui5-enhanced .empty-hint {
  margin: 0;
}

body.ui5-enhanced :is(.empty-state, .empty-hint) > :is(h3, p) {
  margin: 0;
}

body.ui5-enhanced :is(.empty-state, .empty-hint) h3,
body.ui5-enhanced .empty-hint p:first-of-type strong {
  color: var(--theme-text-strong);
  font-size: var(--text-card-title);
  text-wrap: balance;
}

body.ui5-enhanced :is(.empty-state, .empty-hint) > p,
body.ui5-enhanced .empty-state-copy {
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.75;
  text-wrap: pretty;
}

body.ui5-enhanced .empty-visual {
  width: 4.2rem;
  height: 4.2rem;
  border-radius: 1.35rem;
  color: var(--primary);
  background:
    radial-gradient(circle at 32% 22%, color-mix(in srgb, #fff 72%, transparent), transparent 34%),
    linear-gradient(145deg, color-mix(in srgb, var(--primary) 12%, var(--surface)), color-mix(in srgb, var(--accent) 14%, var(--surface)));
  border-color: color-mix(in srgb, var(--primary) 18%, transparent);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--primary-deep) 10%, transparent);
  font-size: 1.45rem;
}

body.ui5-enhanced .empty-visual span {
  transform: translateY(-1px);
}

body.ui5-enhanced .empty-actions {
  margin-top: .35rem;
}

/* Table empty rows should not inherit normal row hover treatment. */
body.ui5-enhanced table tr:has(.empty-state),
body.ui5-enhanced table tr:has(.empty-hint) {
  background: transparent !important;
}

body.ui5-enhanced table td:has(> .empty-state),
body.ui5-enhanced table td:has(> .empty-hint) {
  padding: .8rem !important;
  border-bottom: 0 !important;
}

/* Dashboard: make the first decision obvious and completion satisfying. */
body.ui5-enhanced .dashboard-main {
  gap: clamp(.9rem, 1.35vw, 1.2rem);
}

body.ui5-enhanced .dashboard-main .dashboard-hero {
  position: relative;
  overflow: hidden;
}

body.ui5-enhanced .dashboard-main .dashboard-hero::after {
  content: "";
  position: absolute;
  inset-inline-end: 1.35rem;
  inset-block-end: 1rem;
  width: 4.4rem;
  height: 4.4rem;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(255,255,255,.035), 0 0 0 28px rgba(255,255,255,.022);
  pointer-events: none;
}

body.ui5-enhanced .dashboard-main .dashboard-insight strong,
body.ui5-enhanced .dashboard-main .setup-score,
body.ui5-enhanced .dashboard-main .stat .value {
  will-change: contents;
}

body.ui5-enhanced .dashboard-task-primary {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line)) !important;
  background:
    radial-gradient(18rem 8rem at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 68%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface-strong) 99%, transparent), color-mix(in srgb, var(--accent) 5%, var(--surface-strong))) !important;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 9%, transparent) !important;
}

body.ui5-enhanced .dashboard-task-priority {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  margin-inline-start: auto;
  padding: .22rem .58rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--accent) 68%, var(--theme-text-strong));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  font-size: .72rem;
  font-weight: var(--font-weight-bold, 700);
  white-space: nowrap;
}

body.ui5-enhanced .copilot-main-advice-primary {
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line)) !important;
  box-shadow: var(--elevation-1) !important;
}

body.ui5-enhanced .setup-meter span,
body.ui5-enhanced [role="progressbar"] > span,
body.ui5-enhanced [role="progressbar"] > i {
  transform-origin: right center;
}

/* Calm reveal choreography, applied only after JavaScript marks a node. */
body.ui5-enhanced.ui5-motion-ready .ui5-reveal {
  opacity: 0;
  transform: translateY(var(--ui5-reveal-distance));
  transition:
    opacity var(--motion-rise) var(--ease-emphasized),
    transform var(--motion-rise) var(--ease-emphasized);
  transition-delay: var(--ui5-delay, 0ms);
}

body.ui5-enhanced .ui5-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

body.ui5-enhanced .ui5-value-pop {
  animation: ui5ValueSettle .55s var(--ease-emphasized) both;
}

@keyframes ui5ValueSettle {
  0% { opacity: .15; transform: translateY(5px) scale(.97); }
  65% { opacity: 1; transform: translateY(-1px) scale(1.018); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

body.ui5-enhanced .ui5-progress-enter {
  animation: ui5ProgressEnter .75s var(--ease-emphasized) both;
}

@keyframes ui5ProgressEnter {
  from { transform: scaleX(.04); opacity: .3; }
  to { transform: scaleX(1); opacity: 1; }
}

/* Dark mode preserves depth without bright translucent patches. */
html[data-theme="dark"] body.ui5-enhanced .stat,
html[data-theme="dark"] body.ui5-enhanced :is(.empty-state, .empty-hint),
html[data-theme="dark"] body.ui5-enhanced .dashboard-task-primary {
  background:
    radial-gradient(18rem 9rem at 100% 0%, color-mix(in srgb, var(--brand-accent) 6%, transparent), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 98%, transparent), color-mix(in srgb, var(--paper-2) 90%, var(--surface-strong)));
  border-color: color-mix(in srgb, var(--brand-primary) 22%, var(--line));
  box-shadow: none;
}

html[data-theme="dark"] body.ui5-enhanced .empty-visual {
  color: color-mix(in srgb, var(--brand-primary) 74%, #fff);
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand-primary) 18%, #132238), color-mix(in srgb, var(--brand-accent) 10%, #132238));
  box-shadow: none;
}

html[data-theme="dark"] body.ui5-enhanced .dashboard-task-priority {
  color: color-mix(in srgb, var(--brand-accent) 76%, #fff);
  background: color-mix(in srgb, var(--brand-accent) 10%, var(--surface-strong));
}

@media (max-width: 960px) {
  body.ui5-enhanced .app-shell .topbar {
    min-height: 0;
  }

  body.ui5-enhanced .app-shell .topbar::after {
    width: 9rem;
    height: 9rem;
    inset-inline-end: -3rem;
    inset-block-start: -4rem;
  }

  body.ui5-enhanced .stat {
    min-height: 6.6rem;
  }

  body.ui5-enhanced .dashboard-task-primary {
    align-items: flex-start;
  }

  body.ui5-enhanced .dashboard-task-priority {
    margin-inline-start: 0;
  }
}

@media (max-width: 520px) {
  :root {
    --ui5-page-gap: .72rem;
    --ui5-reveal-distance: 7px;
  }

  body.ui5-enhanced .app-shell .topbar,
  body.ui5-enhanced .panel {
    border-radius: 18px;
  }

  body.ui5-enhanced :is(.empty-state, .empty-hint) {
    min-height: 11rem;
    padding: 1.25rem .9rem;
  }

  body.ui5-enhanced .empty-visual {
    width: 3.65rem;
    height: 3.65rem;
    border-radius: 1.15rem;
  }

  body.ui5-enhanced .empty-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  body.ui5-enhanced .empty-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.ui5-enhanced .ui5-reveal,
  body.ui5-enhanced .ui5-reveal.is-visible,
  body.ui5-enhanced .ui5-value-pop,
  body.ui5-enhanced .ui5-progress-enter,
  body.ui5-enhanced .stat {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}
