.eid-cards-wrap {
  direction: rtl;
  font-family: Tahoma, Arial, sans-serif;
}

.eid-cards-error {
  color: #b32d2e;
}

.eid-cards-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  justify-content: center;
}

.eid-cards-tab {
  padding: 10px 20px;
  border: 2px solid var(--eid-tab-color, #2d6a4f);
  background: #fff;
  color: var(--eid-tab-color, #2d6a4f);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.eid-cards-tab.is-active,
.eid-cards-tab:hover {
  background: var(--eid-tab-color, #2d6a4f);
  border-color: var(--eid-tab-color, #2d6a4f);
  color: #fff;
}

.eid-cards-grid {
  display: grid;
  grid-template-columns: repeat(var(--eid-cols-desktop, 3), 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .eid-cards-grid {
    grid-template-columns: repeat(var(--eid-cols-mobile, 2), 1fr);
    gap: 12px;
  }
}

.eid-card-item[hidden] {
  display: none !important;
}

.eid-card-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
}

.eid-card-thumb img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
}

/* Modal — فوق كل محتوى الموقع (يُنقل إلى body عبر JS) */
.eid-cards-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 !important;
  z-index: 2147483646 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  isolation: isolate;
}

/* يبدأ من تحت القائمة/الهيدر الثابت */
.eid-cards-modal.eid-modal-below-header {
  top: var(--eid-header-h, 0px) !important;
  height: calc(100vh - var(--eid-header-h, 0px)) !important;
  height: calc(100dvh - var(--eid-header-h, 0px)) !important;
  min-height: 0;
}

.eid-cards-modal[hidden] {
  display: none !important;
}

.eid-cards-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 0;
}

.eid-cards-modal-shell {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: calc(100vw - 32px);
  margin: 0 auto;
}

.eid-cards-modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  padding: 20px;
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

@media (max-width: 768px) {
  .eid-cards-modal {
    padding: 0;
    align-items: stretch;
  }

  .eid-cards-modal.eid-modal-below-header {
    padding: 0;
  }

  .eid-cards-modal-shell {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100vw;
    gap: 0;
  }

  .eid-cards-modal-dialog {
    border-radius: 0;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .eid-cards-modal-close {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 3;
  }
}

body.eid-cards-modal-open {
  overflow: hidden !important;
}

.eid-cards-modal-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-top: 8px;
  border: none;
  border-radius: 50%;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  position: absolute;
  top: 100px;
  left: 17px;
}

.eid-cards-modal-close:hover {
  background: #f1f5f9;
  transform: scale(1.05);
}

.eid-cards-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  direction: rtl;
  flex-shrink: 0;
}

.eid-cards-primary-actions {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
}

.eid-cards-name-input {
  flex: 1 0 100%;
  min-width: 100%;
  padding: 12px 16px;
  font-size: 18px;
  border: 2px solid #c3c4c7;
  border-radius: 8px;
  text-align: right;
}

.eid-cards-name-input:focus {
  border-color: #2d6a4f;
  outline: none;
}

.eid-btn {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.eid-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.eid-btn-download {
  background: #2d6a4f;
  color: #fff;
  white-space: nowrap;
}

.eid-btn-download:not(:disabled):hover {
  background: #1b4332;
}

.eid-btn-whatsapp {
  background: #22d265;
  color: #fff;
  white-space: nowrap;
}

.eid-btn-whatsapp:not(:disabled):hover {
  background: #1ebe57;
  color: #fff;
}

.eid-cards-success {
  color: #2d6a4f;
  font-weight: 600;
  margin: 0 0 12px;
  text-align: center;
  flex-shrink: 0;
}

.eid-cards-preview-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.eid-cards-preview-inner {
  position: relative;
  display: block;
  line-height: 0;
  max-width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
  overflow: hidden;
}

.eid-cards-preview-inner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.eid-cards-name-overlay {
  position: absolute;
  z-index: 2;
  font-weight: 700;
  font-feature-settings: inherit;
  line-height: 1.35;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  pointer-events: none;
  box-sizing: border-box;
  white-space: normal;
  transform: translateY(-50%);
}

.eid-cards-modal.is-busy .eid-btn-download {
  pointer-events: none;
}
