/*
  Hamrahino UI Polish Layer
  - Non-invasive improvements for existing Tailwind-based templates
  - RTL-friendly
  - Accessibility/focus states
  - Toasts, skeletons, responsive tables, soft interactions
*/

:root {
  --hm-navy: #070d30;
  --hm-mist: #f1f5fd;
  --hm-snow: #f9fbfe;
  --hm-azure: #0060ff;
  --hm-sky: #0086ff;
  --hm-pink: #fa297c;
  --hm-orange: #fd6b25;
  --hm-amber: #fea100;
  --hm-cloud: #d3dcf1;
  --hm-steel: #7e90b7;
  --hm-dusk: #576896;
  --hm-success: #10b981;
  --hm-danger: #ef4444;
  --hm-radius: 1.25rem;
  --hm-shadow: 0 18px 50px rgba(7, 13, 48, .10);
}

html {
  scroll-behavior: smooth;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(0, 96, 255, .16);
  color: var(--hm-navy);
}

img,
svg,
video {
  max-width: 100%;
}

a,
button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

.skip-link {
  position: fixed;
  top: .75rem;
  right: .75rem;
  z-index: 9999;
  transform: translateY(-140%);
  background: var(--hm-navy);
  color: #fff;
  padding: .75rem 1rem;
  border-radius: 999px;
  box-shadow: var(--hm-shadow);
  transition: transform .2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Better card interaction without requiring template rewrites */
.card,
.hm-card {
  transition:
    transform .25s ease,
    box-shadow .25s ease,
    border-color .25s ease,
    background-color .25s ease;
}

.card:hover,
.hm-card:hover {
  box-shadow: var(--hm-shadow);
}

/* Common image treatment */
.hm-img-soft {
  background: linear-gradient(135deg, #f8fbff, #edf4ff);
}

/* Better native form fields */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea,
select {
  transition:
    border-color .2s ease,
    box-shadow .2s ease,
    background-color .2s ease;
}

input:disabled,
textarea:disabled,
select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .65;
}

/* Long Persian text readability */
.hm-prose,
article {
  line-height: 2;
}

.hm-prose p,
article p {
  margin-bottom: 1rem;
}

.hm-prose h2,
article h2 {
  font-weight: 800;
  color: var(--hm-navy);
  margin: 2rem 0 1rem;
  font-size: 1.35rem;
}

.hm-prose h3,
article h3 {
  font-weight: 800;
  color: var(--hm-navy);
  margin: 1.5rem 0 .75rem;
  font-size: 1.1rem;
}

/* Toasts */
#toastContainer {
  pointer-events: none;
}

.ham-toast {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  width: min(26rem, calc(100vw - 2rem));
  border: 1px solid rgba(211, 220, 241, .95);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-radius: 1.25rem;
  box-shadow: 0 18px 60px rgba(7, 13, 48, .16);
  padding: .9rem .95rem .85rem;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  color: var(--hm-navy);
  animation: hmToastIn .26s ease both;
}

.ham-toast + .ham-toast {
  margin-top: .75rem;
}

.ham-toast[data-closing="true"] {
  animation: hmToastOut .22s ease both;
}

.ham-toast__icon {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
}

.ham-toast__body {
  min-width: 0;
  flex: 1;
}

.ham-toast__title {
  font-size: .86rem;
  font-weight: 800;
  margin-bottom: .15rem;
}

.ham-toast__message {
  font-size: .78rem;
  line-height: 1.75;
  color: var(--hm-dusk);
  overflow-wrap: anywhere;
}

.ham-toast__close {
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--hm-steel);
  transition: background-color .2s ease, color .2s ease;
}

.ham-toast__close:hover {
  background: var(--hm-mist);
  color: var(--hm-navy);
}

.ham-toast__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: right center;
  animation: hmToastProgress linear forwards;
  animation-duration: var(--toast-timeout, 5200ms);
}

.toast-success .ham-toast__icon,
.toast-success .ham-toast__progress {
  background: var(--hm-success);
}

.toast-error .ham-toast__icon,
.toast-danger .ham-toast__icon,
.toast-error .ham-toast__progress,
.toast-danger .ham-toast__progress {
  background: var(--hm-pink);
}

.toast-warning .ham-toast__icon,
.toast-warning .ham-toast__progress {
  background: var(--hm-amber);
}

.toast-info .ham-toast__icon,
.toast-info .ham-toast__progress,
.toast-debug .ham-toast__icon,
.toast-debug .ham-toast__progress {
  background: var(--hm-sky);
}

@keyframes hmToastIn {
  from {
    opacity: 0;
    transform: translateY(-.75rem) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes hmToastOut {
  to {
    opacity: 0;
    transform: translateY(-.5rem) scale(.98);
  }
}

@keyframes hmToastProgress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* Back to top */
.hm-back-to-top {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 60;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--hm-navy);
  color: #fff;
  box-shadow: 0 16px 40px rgba(7, 13, 48, .22);
  transform: translateY(1rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, background-color .2s ease;
}

.hm-back-to-top:hover {
  background: var(--hm-azure);
}

.hm-back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Loading state */
.hm-is-loading {
  position: relative;
  pointer-events: none;
  opacity: .75;
}

.hm-is-loading::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  margin-inline-start: .5rem;
  vertical-align: -2px;
  animation: hmSpin .7s linear infinite;
}

@keyframes hmSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Skeleton */
.hm-skeleton {
  position: relative;
  overflow: hidden;
  background: #edf3fb;
  border-radius: .85rem;
}

.hm-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  animation: hmShimmer 1.4s infinite;
}

@keyframes hmShimmer {
  100% {
    transform: translateX(-100%);
  }
}

/* Responsive table helper */
.hm-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hm-table-wrap table {
  min-width: 42rem;
}

/* Empty state */
.hm-empty {
  border: 1px dashed var(--hm-cloud);
  background:
    radial-gradient(circle at top right, rgba(0, 96, 255, .07), transparent 32%),
    #fff;
  border-radius: 1.5rem;
}

/* Improve mobile spacing */
@media (max-width: 640px) {
  .ham-toast {
    width: calc(100vw - 1.5rem);
  }

  .hm-back-to-top {
    left: .75rem;
    bottom: .75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
