/* Aria Mersad Download Trees — frontend v1.0.1 */
.amdt-wrap {
  --amdt-teal: #159b82;
  --amdt-teal-dark: #0f7a66;
  --amdt-ink: #1a1a1a;
  --amdt-muted: #6b7280;
  --amdt-line: #e5e7eb;
  --amdt-bg: #f7faf9;
  --amdt-card: #ffffff;
  --amdt-radius: 14px;
  --amdt-shadow: 0 8px 28px rgba(15, 61, 52, 0.08);
  --amdt-card-w: 220px;
  --amdt-card-h: 150px;
  font-family: IranSans, IRANSans, Tahoma, sans-serif;
  color: var(--amdt-ink);
  margin: 8px 0 28px;
  direction: rtl;
}

.amdt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.amdt-head__title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--amdt-ink);
}

.amdt-head__sub {
  margin: 0;
  color: var(--amdt-muted);
  font-size: 14px;
}

.amdt-head__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--amdt-muted);
}

.amdt-expand-all,
.amdt-collapse-all {
  border: 1px solid var(--amdt-line);
  background: #fff;
  color: var(--amdt-ink);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: border-color .2s, color .2s, background .2s;
}

.amdt-expand-all:hover,
.amdt-collapse-all:hover {
  border-color: var(--amdt-teal);
  color: var(--amdt-teal-dark);
  background: #f0faf7;
}

.amdt-chart {
  overflow: visible;
  padding: 16px;
  background:
    radial-gradient(circle at 10% 0%, rgba(21, 155, 130, 0.08), transparent 45%),
    linear-gradient(180deg, #fbfefd, var(--amdt-bg));
  border: 1px solid var(--amdt-line);
  border-radius: 18px;
}

.amdt-empty {
  margin: 24px;
  color: var(--amdt-muted);
}

.amdt-level {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Root: stacked categories */
.amdt-level--0 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.amdt-level--0 > .amdt-node--folder {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(21, 155, 130, 0.12);
  border-radius: 16px;
  padding: 10px;
}

.amdt-level--0 > .amdt-node--folder > .amdt-card {
  width: 100%;
  max-width: none;
  min-width: 0;
  min-height: 0;
  height: auto;
}

/* Children: compact multi-column grid */
.amdt-branch {
  position: relative;
  margin: 12px 0 4px;
  padding: 12px;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border: 1px dashed rgba(21, 155, 130, 0.28);
  border-radius: 14px;
}

.amdt-branch::before {
  display: none;
}

.amdt-node.is-open > .amdt-branch {
  animation: amdt-fade-in .2s ease;
}

@keyframes amdt-fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.amdt-branch .amdt-level {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  align-items: stretch;
}

.amdt-branch .amdt-node {
  display: flex;
  min-width: 0;
  height: 100%;
}

.amdt-branch .amdt-card {
  width: 100%;
  min-width: 0;
  max-width: none;
  height: 100%;
  min-height: var(--amdt-card-h);
}

.amdt-card {
  position: relative;
  z-index: 1;
  background: var(--amdt-card);
  border: 1px solid var(--amdt-line);
  border-radius: var(--amdt-radius);
  box-shadow: var(--amdt-shadow);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.amdt-node--folder > .amdt-card {
  border-right: 4px solid var(--amdt-teal);
}

.amdt-node--file > .amdt-card {
  border-right: 4px solid #94a3b8;
}

.amdt-node--pdf > .amdt-card {
  border-right-color: #dc2626;
}

.amdt-card:hover {
  transform: translateY(-2px);
  border-color: rgba(21, 155, 130, 0.45);
  box-shadow: 0 12px 32px rgba(15, 61, 52, 0.12);
}

.amdt-toggle {
  width: 44px;
  border: 0;
  background: #eef8f5;
  color: var(--amdt-teal-dark);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
}

.amdt-toggle__icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .2s ease;
  margin-top: -2px;
}

.amdt-node.is-open > .amdt-card .amdt-toggle__icon {
  transform: rotate(-45deg);
  margin-top: 2px;
}

.amdt-card__body,
.amdt-folder-hit,
.amdt-download {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  text-align: right;
  background: transparent;
  border: 0;
  font: inherit;
  color: inherit;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}

.amdt-folder-hit,
.amdt-download {
  cursor: pointer;
  width: 100%;
}

.amdt-card__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  margin-bottom: 4px;
  flex: 0 0 auto;
  background: #eef8f5 center/16px no-repeat;
}

.amdt-card__icon--folder {
  background-color: #e7f6f2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23159b82'%3E%3Cpath d='M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/%3E%3C/svg%3E");
}

.amdt-card__icon--file {
  background-color: #eef2ff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%234f46e5'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z'/%3E%3C/svg%3E");
}

.amdt-card__icon--pdf {
  background-color: #fef2f2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23dc2626'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm-1 7V3.5L18.5 9H13zM8 13h8v2H8v-2zm0 4h8v2H8v-2z'/%3E%3C/svg%3E");
}

.amdt-card__title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.9em;
}

.amdt-card__meta {
  font-size: 12px;
  color: var(--amdt-muted);
  margin-top: auto;
}

.amdt-card__action {
  margin-top: 8px;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--amdt-teal);
  border-radius: 999px;
  padding: 5px 12px;
}

.amdt-download:hover .amdt-card__action {
  background: var(--amdt-teal-dark);
}

.amdt-download.is-busy {
  opacity: .7;
  pointer-events: none;
}

/* Uniform file cards: width locked to widest measured card */
.amdt-branch.is-sized .amdt-level {
  grid-template-columns: repeat(4, var(--amdt-card-w));
  justify-content: start;
}

.amdt-branch.is-sized .amdt-card {
  width: 100%;
  max-width: none;
}

/* Modal */
.amdt-modal[hidden] { display: none !important; }

.amdt-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.amdt-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 18, 0.55);
  backdrop-filter: blur(3px);
}

.amdt-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  padding: 28px 24px 24px;
  animation: amdt-pop .22s ease;
}

@keyframes amdt-pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.amdt-modal__close {
  position: absolute;
  top: 10px;
  left: 12px;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}

.amdt-modal__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}

.amdt-modal__lead {
  margin: 0 0 18px;
  color: var(--amdt-muted);
  font-size: 13px;
}

.amdt-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.amdt-tab {
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: #64748b;
}

.amdt-tab.is-active {
  background: #fff;
  color: var(--amdt-teal-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.amdt-form {
  display: grid;
  gap: 12px;
}

.amdt-form[hidden] { display: none !important; }

.amdt-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.amdt-form input[type="text"],
.amdt-form input[type="email"],
.amdt-form input[type="tel"],
.amdt-form input[type="password"] {
  width: 100%;
  border: 1px solid var(--amdt-line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  box-sizing: border-box;
}

.amdt-form input:focus {
  outline: 2px solid rgba(21, 155, 130, 0.25);
  border-color: var(--amdt-teal);
}

.amdt-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.amdt-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
}

.amdt-form__msg {
  margin: 0;
  font-size: 13px;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 8px;
  padding: 8px 10px;
}

.amdt-form__msg.is-ok {
  color: #065f46;
  background: #ecfdf5;
}

.amdt-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.amdt-btn--primary {
  background: var(--amdt-teal);
  color: #fff;
}

.amdt-btn--primary:hover {
  background: var(--amdt-teal-dark);
}

.amdt-btn:disabled {
  opacity: .65;
  cursor: wait;
}

@media (max-width: 1100px) {
  .amdt-branch .amdt-level,
  .amdt-branch.is-sized .amdt-level {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .amdt-branch.is-sized .amdt-level {
    grid-template-columns: repeat(3, var(--amdt-card-w));
  }
}

@media (max-width: 767px) {
  .amdt-branch .amdt-level,
  .amdt-branch.is-sized .amdt-level {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .amdt-branch.is-sized .amdt-level {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .amdt-form__row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .amdt-branch .amdt-level,
  .amdt-branch.is-sized .amdt-level {
    grid-template-columns: 1fr;
  }
}
