
/* Ensure the visible dropzone contents do not block clicks.
   The real clickable element is the invisible file input that
   sits on top of the dropzone. */
.a4m-file-dropzone-inner,
.a4m-file-dropzone-inner * {
    pointer-events: none;
}
/* =========================================================
   FINAL FIX — Prevent ANY flash of hidden fields on load
   ========================================================= */
.a4m-tally-form:not(.a4m-init-complete) .a4m-tally-field {
    opacity: 0 !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    transition: none !important;
}

/* =========================================================
   Normal Tally Style Animation (after init-complete)
   ========================================================= */

/* These were already in your CSS — we keep them */
.a4m-tally-form .a4m-tally-field {
    opacity: 1;
    transition: opacity 0.25s ease;
}

/* When JS finishes logic evaluation */
.a4m-tally-form.a4m-ready .a4m-tally-field {
    opacity: 1;
}

/* =========================================================
   MAIN FORM LAYOUT
   ========================================================= */

.a4m-tally-form-wrapper {
  max-width: 720px;
  margin: 0 auto 32px;
}

.a4m-tally-form {
  background: #ffffff;
  border-radius: 18px;
  padding: 24px 24px 20px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.a4m-tally-form:hover {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.10);
  transform: translateY(-2px);
}

.a4m-tally-description {
  margin-bottom: 18px;
  color: #4b5563;
  font-size: 14px;
}

/* =========================================================
   FIELDS
   ========================================================= */

.a4m-tally-field {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #f3f4f6;
  background: linear-gradient(180deg, #f9fafb, #f3f4f6);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.a4m-tally-field:hover {
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.a4m-tally-field.a4m-tally-hidden {
  display: none;
}

.a4m-tally-label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: #111827;
}

.a4m-required {
  color: #ef4444;
  margin-left: 4px;
}

/* =========================================================
   INPUTS
   ========================================================= */

.a4m-tally-input-wrap input[type="text"],
.a4m-tally-input-wrap input[type="email"],
.a4m-tally-input-wrap input[type="number"],
.a4m-tally-input-wrap textarea,
.a4m-tally-input-wrap select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.a4m-tally-input-wrap input:focus,
.a4m-tally-input-wrap textarea:focus,
.a4m-tally-input-wrap select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px #4f46e5;
  outline: none;
}

/* =========================================================
   OPTIONS (RADIO / CHECKBOX / BUTTONS)
   ========================================================= */

.a4m-tally-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.a4m-tally-options-list label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.a4m-tally-options-list label:hover {
  border-color: #4f46e5;
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.a4m-tally-options-list input[type="radio"],
.a4m-tally-options-list input[type="checkbox"] {
  accent-color: #4f46e5;
}

/* =========================================================
   SUBMIT BUTTON
   ========================================================= */

.a4m-tally-form button[type="submit"] {
  padding: 10px 24px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: #111827;
  color: #ffffff;
  font-size: 14px;
  margin-top: 10px;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.a4m-tally-form button[type="submit"]:hover {
  background: #0f172a;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
  transform: translateY(-1px);
}

/* =========================================================
   LOGIC STATES
   ========================================================= */

.a4m-tally-disabled {
  opacity: 0.6;
}

.a4m-tally-readonly {
  position: relative;
}

.a4m-tally-readonly::after {
  content: "readonly";
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 10px;
  text-transform: uppercase;
  color: #9ca3af;
}

/* Thick border used by hide-box */
.a4m-tally-hide-box {
  border: 3px solid #f97373;
  background: #fef2f2;
}

.a4m-tally-anim-show {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

.a4m-tally-anim-hide {
  opacity: 0;
  transform: translateY(-4px);
}

/* =========================================================
   VALIDATION
   ========================================================= */

.a4m-error-field {
  border-radius: 14px;
  box-shadow: 0 0 0 1px #fca5a5;
}

.a4m-error-field .a4m-tally-input-wrap input,
.a4m-error-field .a4m-tally-input-wrap textarea,
.a4m-error-field .a4m-tally-input-wrap select {
  border-color: #fca5a5;
}

.a4m-error-msg {
  margin-top: 6px;
  font-size: 12px;
  color: #b91c1c;
}


/* Static content card */
.a4m-tally-field-static .a4m-static-content {
  padding: 18px 22px;
  border-radius: 14px;
  background: #ffffff;
  font-size: 16px;
  line-height: 1.5;
}

.a4m-tally-field-static .a4m-static-content p {
  margin: 0 0 8px;
}


/* =========================================================
   FILE UPLOAD PROGRESS - v2.7.0 compact UI
   ========================================================= */
/* Upload progress bar */
.a4m-upload-progress {
  display: block;
  width: 100%;
  max-width: 450px;
  height: 14px;
  border-radius: 7px;
  background: #e5e7eb;
  position: relative;
  overflow: hidden;
  margin-top: 10px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.a4m-upload-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
  transition: width 0.2s linear;
}

.a4m-upload-percent {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  z-index: 10;
  pointer-events: none;
}


/* === Fancy file upload UI (Tally-style) === */
.a4m-file-upload-ui {
  position: relative;
}

.a4m-file-dropzone {
  position: relative;
  border: 2px dashed rgba(148, 163, 184, 0.9);
  border-radius: 18px;
  padding: 18px 18px 16px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.a4m-file-drop-inner {
  text-align: center;
  color: #111827;
  font-size: 14px;
  line-height: 1.4;
}

.a4m-file-arrow {
  font-size: 26px;
  margin-bottom: 8px;
}

.a4m-file-text {
  font-weight: 500;
}

.a4m-file-preview-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.a4m-file-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: 22px;
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.12),
    0 4px 10px rgba(15, 23, 42, 0.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.a4m-file-thumb {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background-size: cover;
  background-position: center;
  background-color: #f3f4f6;
  overflow: hidden;
  flex-shrink: 0;
}

.a4m-file-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.a4m-file-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  word-break: break-all;
}

.a4m-file-remove {
  border: 1px solid #f97373;
  background: #fef2f2;
  color: #b91c1c;
  min-width: 70px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  padding: 0 10px;
  cursor: pointer;
}

.a4m-file-remove:focus {
  outline: 2px solid rgba(248, 113, 113, 0.6);
  outline-offset: 2px;
}

/* Invisible real file input over the whole dropzone */
.a4m-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* After a file is selected, let clicks reach the preview + remove button */
.a4m-file-input.a4m-has-file {
  pointer-events: none;
}

/* Slightly smaller on very small screens */
@media (max-width: 480px) {
  .a4m-file-card {
    max-width: 100%;
    padding: 12px 14px;
  }
  .a4m-file-thumb {
    width: 64px;
    height: 64px;
  }
  .a4m-file-name {
    font-size: 14px;
  }
}

/* Submit Button Frontend Defaults */
.a4m-tally-submit-btn{transition:all .2s ease;}


/* Inline file upload rules */
.a4m-file-hint {
  margin-top: 6px;
  font-size: 13px;
  color: #6b7280;
}

.a4m-file-hint-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.a4m-file-hint-item {
  white-space: nowrap;
}


/* Force file rules to always stay on ONE line */
.a4m-file-hint-inline {
  display: flex;
  flex-wrap: nowrap !important;
  gap: 14px;
  white-space: nowrap;
  overflow-x: auto;
}

.a4m-file-hint-item {
  white-space: nowrap;
  flex-shrink: 0;
}


/* Screenshot-style file rules bar */
.a4m-file-hint-inline {
  display: flex;
  flex-wrap: nowrap !important;
  gap: 22px;
  white-space: nowrap;
  overflow-x: auto;
  padding: 12px 16px;
  background: #f3f4f6;
  border-radius: 12px;
  font-size: 14px;
  color: #6b7280;
}

.a4m-file-hint-item {
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}


/* Compact one-line file rules bar */
.a4m-file-hint-inline {
  display: flex;
  flex-wrap: nowrap !important;
  gap: 12px;
  white-space: nowrap;
  overflow-x: auto;
  padding: 6px 10px;
  background: #f5f6f8;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.2;
  color: #7a7f87;
}

.a4m-file-hint-item {
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}


/* Ultra-compact one-line file rules bar */
.a4m-file-hint-inline {
  display: flex;
  flex-wrap: nowrap !important;
  gap: 8px;
  white-space: nowrap;
  overflow-x: auto;
  padding: 4px 8px;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.1;
  color: #7a8088;
}

.a4m-file-hint-item {
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 500;
}


/* Frontend form status + password lock */
.a4m-form-status-bar--frontend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
}

.a4m-form-status-text--protected {
  font-weight: 600;
}

.a4m-form-status-lock {
  font-size: 14px;
}

.a4m-tally-form-wrapper--locked .a4m-tally-form-locked {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.a4m-tally-lock-message {
  margin-bottom: 10px;
}

.a4m-tally-password-input {
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
}

.a4m-tally-password-button {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.a4m-tally-lock-error {
  color: #b91c1c;
  margin-top: 6px;
}


/* --- Professional Password Lock UI --- */
.a4m-tally-lock-card {
  max-width: 420px;
  margin: 60px auto;
  padding: 30px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.12);
  text-align: center;
}

.a4m-tally-lock-card .a4m-tally-lock-message {
  font-size: 16px;
  margin-bottom: 18px;
  color: #222;
}

.a4m-tally-password-input--modern {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #d0d5dd;
  font-size: 15px;
  outline: none;
}

.a4m-tally-password-input--modern:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.a4m-tally-password-button--modern {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #111827, #2563eb);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.a4m-tally-password-button--modern:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.2);
}

.a4m-tally-lock-error {
  margin-top: 12px;
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

/* === Button Select frontend styling === */
.a4m-tally-field[data-a4m-type="buttons"] .a4m-tally-options-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.a4m-tally-field[data-a4m-type="buttons"] .a4m-tally-options-list label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  min-height: 32px;
}

.a4m-tally-field[data-a4m-type="buttons"] .a4m-tally-options-list input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.a4m-tally-field[data-a4m-type="buttons"] .a4m-tally-options-list label span {
  display: inline-block;
  line-height: 1.2;
}

.a4m-tally-field[data-a4m-type="buttons"] .a4m-tally-options-list label.a4m-btn-active {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}

/* === Fallback Button Size & Shape Frontend Fix === */
.a4m-btn-sm { font-size:13px; padding:4px 10px; }
.a4m-btn-md { font-size:15px; padding:7px 16px; }
.a4m-btn-lg { font-size:17px; padding:10px 20px; }

.a4m-btn-square { border-radius:4px; }
.a4m-btn-rounded { border-radius:12px; }
.a4m-btn-pill { border-radius:999px; }


.a4m-btn-size-sm span {
  font-size: 13px;
  padding: 6px 12px;
}
.a4m-btn-size-md span {
  font-size: 15px;
  padding: 10px 18px;
}
.a4m-btn-size-lg span {
  font-size: 18px;
  padding: 14px 24px;
}

.a4m-btn-shape-square span {
  border-radius: 4px;
}
.a4m-btn-shape-rounded span {
  border-radius: 12px;
}
.a4m-btn-shape-pill span {
  border-radius: 999px;
}

/* === Button Select Shape (FORCED FIX) === */
.a4m-tally-options-list label.a4m-btn-shape-square,
.a4m-tally-options-list label.a4m-btn-shape-square span {
  border-radius: 4px !important;
}

.a4m-tally-options-list label.a4m-btn-shape-rounded,
.a4m-tally-options-list label.a4m-btn-shape-rounded span {
  border-radius: 12px !important;
}

.a4m-tally-options-list label.a4m-btn-shape-pill,
.a4m-tally-options-list label.a4m-btn-shape-pill span {
  border-radius: 999px !important;
}
/* === Button Select Size (REMAPPED SCALE) === */
.a4m-btn-size-sm span {   /* Extra Small */
  font-size: 11px !important;
  padding: 4px 8px !important;
}

.a4m-btn-size-md span {   /* Small */
  font-size: 13px !important;
  padding: 6px 12px !important;
}

.a4m-btn-size-lg span {   /* Medium */
  font-size: 15px !important;
  padding: 10px 18px !important;
}

.a4m-btn-size-xl span {  /* Large */
  font-size: 18px !important;
  padding: 14px 24px !important;
}

/* TinyMCE image alignment fixes */
.a4m-static-content img.alignleft{float:left;margin-right:15px;}
.a4m-static-content img.alignright{float:right;margin-left:15px;}
.a4m-static-content img.aligncenter{display:block;margin-left:auto;margin-right:auto;}
.a4m-static-content img{max-width:100%;height:auto;}


/* =========================================================
   PUBLIC FORM WRAPPER & STATIC CONTENT ALIGNMENT
   ========================================================= */

/* Center the public slug form nicely in the theme content area */
.a4m-tally-public-form-wrapper {
  max-width: 720px;
  margin: 0 auto 40px;
}

/* Make the injected form title look neat & centred */
.a4m-tally-form-title {
  margin: 0 0 16px;
  font-size: 1.8rem;
  font-weight: 600;
  text-align: center;
}

/* Ensure static content fields render consistently on slug & posts */
.a4m-tally-field-static .a4m-static-content {
  text-align: center;
}

.a4m-tally-field-static .a4m-static-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
