/*
 * Tomanify Admin Styles
 *
 * @since 1.0.0
 */

/* Layout */
.tomanify-wrap { background:#fff; padding:20px; border-radius:6px; }
.tomanify-form h2 { margin-top:25px; color:#23282d; border-bottom:1px solid #ddd; padding-bottom:6px; }
.tomanify-tab-content { margin-top:20px; }
.tomanify-about { line-height:1.7; max-width:720px; }

/* Cards & Containers */
.tomanify-admin-container { margin-top:12px; }
.tomanify-card { background:#fff; padding:12px 16px; border:1px solid #e2e2e2; border-radius:4px; margin:12px 0; }

/* Optional footer */
.tomanify-admin-footer { text-align:center; margin-top:40px; color:#888; }

/* Tables */
.tomanify-table--narrow { max-width:820px; }
.tomanify-table--medium { max-width:900px; }
.tomanify-table--wide   { max-width:1100px; }

.tomanify-col-img   { width:10%; }
.tomanify-col-title { width:30%; }
.tomanify-col-input { width:20%; }
.tomanify-col-final { width:20%; }

.tomanify-col-code     { width:16%; }
.tomanify-col-currency { width:34%; }
.tomanify-col-display  { width:25%; }

/* Inputs */
.tomanify-input { box-sizing:border-box; }
.tomanify-input-full { width:100%; }
.tomanify-w-90  { width:90px; }
.tomanify-w-140 { width:140px; }
.tomanify-maxw-700 { max-width:700px; }

/* Spacing Utilities */
.tomanify-mb-12 { margin-bottom:12px; }
.tomanify-mb-16 { margin-bottom:16px; }
.tomanify-mt-4  { margin-top:4px; }
.tomanify-mt-6  { margin-top:6px; }
.tomanify-mt-8  { margin-top:8px; }

.tomanify-mr-6  { margin-right:6px; }
.tomanify-mr-8  { margin-right:8px; }
.tomanify-mr-12 { margin-right:12px; }

.tomanify-ml-8 { margin-left:8px; }

/* Text Helpers */
.tomanify-text-muted { color:#666; }
.tomanify-fw-normal { font-weight:400; }
.tomanify-help { color:#666; margin:6px 0; }

/* Flex Helpers */
.tomanify-flex { display:flex; }
.tomanify-items-center { align-items:center; }
.tomanify-gap-8 { gap:8px; }

/* Thumbnails */
.tomanify-thumb {
  width:40px;
  height:40px;
  border-radius:4px;
  object-fit:cover;
  display:inline-block;
}
.tomanify-thumb--placeholder {
  background:#eee;
  border:1px solid #ccc;
}

/* Copy Feedback */
.tomanify-copy-done { display:none; color:green; margin-left:6px; }

/* Meta Box Layout */
.tomanify-meta { margin-top:4px; }
.tomanify-field { margin:8px 0; }
.tomanify-label { display:block; margin-bottom:4px; font-weight:600; }

/* ------------------------------
   RTL MODE
   ------------------------------ */

.tomanify-rtl { direction:rtl; text-align:right; }

.tomanify-rtl .tomanify-card,
.tomanify-rtl .tomanify-table--narrow,
.tomanify-rtl .tomanify-table--medium,
.tomanify-rtl .tomanify-table--wide {
  direction:rtl;
}

.tomanify-rtl .tomanify-input-full { text-align:right; }
.tomanify-rtl select { direction:rtl; }

/* Force font inherit for Persian/RTL */
.wrap.tomanify-rtl,
.wrap.tomanify-rtl * {
  font-family: inherit;
}

/* RTL Headings & Tabs */
.tomanify-rtl h1,
.tomanify-rtl h2,
.tomanify-rtl h3 { text-align:right; }

.tomanify-rtl .nav-tab-wrapper { direction:rtl; text-align:right; }
.tomanify-rtl .nav-tab {
  float:none;
  display:inline-block;
}

/* RTL Table headers */
.tomanify-rtl table.widefat thead th,
.tomanify-rtl .tomanify-table--narrow thead th,
.tomanify-rtl .tomanify-table--medium thead th,
.tomanify-rtl .tomanify-table--wide thead th {
  text-align:right;
}

/* RTL Labels & Help */
.tomanify-rtl .tomanify-label,
.tomanify-rtl .tomanify-help {
  text-align:right;
}

/* ------------------------------
   LTR MODE (when dashboard is RTL)
   ------------------------------ */

.tomanify-ltr { direction:ltr; text-align:left; }

.tomanify-ltr .tomanify-card,
.tomanify-ltr .tomanify-table--narrow,
.tomanify-ltr .tomanify-table--medium,
.tomanify-ltr .tomanify-table--wide {
  direction:ltr;
}

.tomanify-ltr h1,
.tomanify-ltr h2,
.tomanify-ltr h3 { text-align:left; }

.tomanify-ltr .tomanify-input-full { text-align:left; }
.tomanify-ltr select { direction:ltr; }

.tomanify-ltr .nav-tab-wrapper { direction:ltr; text-align:left; }
.tomanify-ltr .nav-tab {
  float:none;
  display:inline-block;
}

/* Backup tab */
.tomanify-backup-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.tomanify-backup-col { padding:4px; }

.tomanify-warning {
  background:#fff8e5;
  border:1px solid #f0c36d;
  color:#6b5200;
  padding:10px 12px;
  border-radius:4px;
  margin-bottom:12px;
}

@media (max-width:900px) {
  .tomanify-backup-grid { grid-template-columns:1fr; }
}

.tomanify-card input[type="file"] {
  display:block;
  margin-top:8px;
}

/* Fix WooCommerce metabox heading font inheritance */
.tomanify-rtl .postbox h2.hndle,
.tomanify-ltr .postbox h2.hndle,
.postbox.tomanify-meta h2.hndle {
    font-family: inherit;
}

/* License & Credits modal */
.tomanify-license-overlay {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.45);
	z-index: 100000;
}

.tomanify-license-overlay.is-open {
	display: flex;
}

.tomanify-license-modal {
	background: #fff;
	max-width: 720px;
	width: 100%;
	max-height: 80vh;
	overflow: auto;
	padding: 24px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	border-radius: 8px;
}

/* Close button */
.tomanify-license-close {
	border: 0;
	background: transparent;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	float: right;
}

.tomanify-license-modal h2 {
	margin-top: 0;
	margin-bottom: 16px;
}

.tomanify-license-modal h3 {
	margin-top: 24px;
	margin-bottom: 8px;
}

.tomanify-license-modal p {
	margin-bottom: 12px;
}

.tomanify-license-list {
	list-style: disc;
	padding-left: 20px;
	margin: 0 0 12px;
}

/* Respect plugin RTL/LTR helpers */
.tomanify-rtl .tomanify-license-modal {
	direction: rtl;
	text-align: right;
}

.tomanify-ltr .tomanify-license-modal {
	direction: ltr;
	text-align: left;
}

.tomanify-rtl .tomanify-license-list {
	padding-right: 20px;
	padding-left: 0;
}


/* ------------------------------
   Shared Admin UI System
   Keeps settings cards, form fields, buttons, and choices consistent across
   desktop, tablet, and mobile without leaking styles outside Tomanify.
   ------------------------------ */

.tomanify-wrap,
.tomanify-wrap *,
.postbox.tomanify-meta,
.postbox.tomanify-meta * {
  box-sizing: border-box;
}

.tomanify-wrap .nav-tab-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px;
  padding-top: 0;
}

.tomanify-wrap .nav-tab {
  float: none;
  margin-left: 0;
  margin-bottom: -1px;
  white-space: normal;
  line-height: 1.35;
}

.tomanify-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.tomanify-align-right { text-align: right; }
.tomanify-center { text-align: center; }

.tomanify-wrap table.widefat th.tomanify-col-display,
.tomanify-wrap table.widefat td.tomanify-col-display,
.tomanify-wrap table.widefat th.tomanify-col-final,
.tomanify-wrap table.widefat td.tomanify-col-final {
  text-align: right;
}

.tomanify-wrap input[type="text"],
.tomanify-wrap input[type="url"],
.tomanify-wrap input[type="number"],
.tomanify-wrap input[type="file"],
.tomanify-wrap select,
.tomanify-wrap textarea,
.postbox.tomanify-meta input[type="text"],
.postbox.tomanify-meta input[type="number"],
.postbox.tomanify-meta select,
.postbox.tomanify-meta textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.tomanify-wrap .regular-text,
.tomanify-wrap .large-text,
.tomanify-wrap .tomanify-maxw-700,
.tomanify-wrap .tomanify-input-full,
.postbox.tomanify-meta .tomanify-input-full {
  max-width: 100%;
}

.tomanify-wrap .button,
.postbox.tomanify-meta .button {
  max-width: 100%;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 14px;
  line-height: 1.3;
  white-space: normal;
  text-align: center;
  vertical-align: middle;
}

.tomanify-wrap p > .button,
.tomanify-card p > .button,
.tomanify-form > p > .button {
  margin-top: 2px;
  margin-bottom: 2px;
}

.tomanify-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tomanify-source-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.tomanify-source-field input[type="url"] {
  flex: 1 1 360px;
  min-width: 220px;
}

.tomanify-source-guide-link {
  flex: 0 0 auto;
}

.tomanify-form-inline label,
.tomanify-form-inline input,
.tomanify-form-inline select,
.tomanify-form-inline .button {
  margin-top: 0;
  margin-bottom: 0;
}

.tomanify-card label {
  max-width: 100%;
  line-height: 1.5;
}

.tomanify-card form,
.tomanify-card p,
.tomanify-card .tomanify-form-inline,
.tomanify-card .tomanify-source-field,
.tomanify-card .tomanify-warning {
  max-width: 100%;
}

.tomanify-choice {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 12px 4px 0;
  vertical-align: top;
}

.tomanify-rtl .tomanify-choice {
  margin-right: 0;
  margin-left: 12px;
}

.tomanify-choice > input[type="checkbox"],
.tomanify-choice > input[type="radio"] {
  flex: 0 0 auto;
  margin: 3px 0 0;
}

.tomanify-flex {
  flex-wrap: wrap;
}

.tomanify-card code {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.tomanify-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: 4px;
}

.tomanify-table-scroll > table.widefat,
.tomanify-card > table.widefat {
  width: 100%;
  max-width: none;
  margin: 0;
  table-layout: auto;
}

/* Tablet/mobile admin layout fixes. */
@media (max-width: 782px) {
  .wrap.tomanify-ltr,
  .wrap.tomanify-rtl {
    margin-right: 10px;
    margin-left: 10px;
  }

  .tomanify-wrap {
    padding: 14px;
    overflow: hidden;
  }

  .tomanify-admin-container {
    margin-top: 14px;
  }

  .tomanify-wrap .nav-tab-wrapper {
    gap: 6px;
    border-bottom: 0;
  }

  .tomanify-wrap .nav-tab {
    flex: 1 1 calc(50% - 6px);
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 6px;
    text-align: center;
    background: #f6f7f7;
  }

  .tomanify-wrap .nav-tab-active {
    background: #fff;
    border-bottom-color: #c3c4c7;
  }

  .tomanify-card {
    padding: 14px;
    min-width: 0;
    overflow: visible;
  }

  .tomanify-card input[type="text"],
  .tomanify-card input[type="url"],
  .tomanify-card input[type="number"],
  .tomanify-card input[type="file"],
  .tomanify-card select,
  .tomanify-card textarea,
  .tomanify-wrap .regular-text,
  .tomanify-wrap .large-text,
  .tomanify-wrap .tomanify-maxw-700,
  .tomanify-wrap .tomanify-maxw-250,
  .tomanify-wrap .tomanify-w-90,
  .tomanify-wrap .tomanify-w-140,
  .tomanify-wrap .tomanify-input-full,
  .postbox.tomanify-meta input[type="text"],
  .postbox.tomanify-meta input[type="number"],
  .postbox.tomanify-meta select,
  .postbox.tomanify-meta textarea {
    width: 100% !important;
    min-width: 0;
    max-width: 100% !important;
    font-size: 16px;
  }

  .tomanify-form-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .tomanify-form-inline label,
  .tomanify-form-inline input,
  .tomanify-form-inline select,
  .tomanify-form-inline .button {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
  }


  .tomanify-source-field {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tomanify-source-field input[type="url"],
  .tomanify-source-field .button {
    width: 100%;
    min-width: 0;
  }

  /* Keep URL inputs compact after the mobile source field stacks vertically. */
  .tomanify-source-field input[type="url"] {
    flex: 0 1 auto;
    min-height: 34px;
    height: auto;
  }

  .tomanify-source-field .button {
    flex: 0 1 auto;
  }
  #tomanify-form-update-rates {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #tomanify-last-update-line {
    margin-left: 0;
    margin-right: 0;
    overflow-wrap: anywhere;
  }

  .tomanify-choice {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 6px 0;
    padding: 8px 10px;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    background: #f6f7f7;
  }

  .tomanify-card > .tomanify-choice,
  .tomanify-card p > .tomanify-choice {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
  }

  .tomanify-card > form,
  .tomanify-card > p,
  .tomanify-card > .tomanify-form-inline,
  .tomanify-card > .tomanify-source-field,
  .tomanify-card .tomanify-warning {
    max-width: 100%;
    min-width: 0;
  }

  .tomanify-card > p {
    overflow-wrap: anywhere;
  }

  .tomanify-table-scroll {
    margin-right: -2px;
    margin-left: -2px;
    padding-right: 2px;
    padding-left: 2px;
  }

  .tomanify-table-scroll > table.widefat,
  .tomanify-card > table.widefat {
    width: auto;
    min-width: 100%;
  }

  .tomanify-table--narrow,
  .tomanify-table--medium,
  .tomanify-table--wide,
  #tomanify-table-cbi,
  #tomanify-table-manual {
    min-width: 640px;
  }

  #tomanify-products-table {
    min-width: 820px;
  }

  .tomanify-card .button,
  .tomanify-form > p > .button,
  .tomanify-card p > .button,
  .tomanify-card a.button {
    width: 100%;
    margin: 4px 0;
  }

  #tomanify-card-shortcode .tomanify-flex {
    flex-direction: column;
    align-items: stretch;
  }

  #tomanify-shortcode-text {
    display: block;
    width: 100%;
    padding: 8px 10px;
    overflow-wrap: anywhere;
  }

  .tomanify-license-modal {
    width: calc(100% - 24px);
    max-height: 86vh;
    padding: 18px;
  }
}

@media (max-width: 480px) {
  .wrap.tomanify-ltr,
  .wrap.tomanify-rtl {
    margin-right: 8px;
    margin-left: 8px;
  }

  .tomanify-wrap {
    padding: 12px;
  }

  .tomanify-card {
    padding: 12px;
  }

  .tomanify-wrap .nav-tab {
    flex-basis: 100%;
  }

  .tomanify-table--narrow,
  .tomanify-table--medium,
  .tomanify-table--wide,
  #tomanify-table-cbi,
  #tomanify-table-manual {
    min-width: 560px;
  }

  #tomanify-products-table {
    min-width: 760px;
  }
}

/* Respect user/system reduced-motion preferences (WordPress 7 admin compatibility). */
@media (prefers-reduced-motion: reduce) {
  .tomanify-wrap,
  .tomanify-wrap *,
  .postbox.tomanify-meta,
  .postbox.tomanify-meta * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


/* Final mobile containment and table alignment fixes. */
.tomanify-table th.tomanify-col-display,
.tomanify-table td.tomanify-col-display,
.tomanify-table th.tomanify-col-final,
.tomanify-table td.tomanify-col-final,
.tomanify-table th.tomanify-align-right,
.tomanify-table td.tomanify-align-right {
  text-align: right;
}

.wrap.tomanify-ltr,
.wrap.tomanify-rtl,
.wrap.tomanify-ltr *,
.wrap.tomanify-rtl * {
  box-sizing: border-box;
}

@media (max-width: 782px) {
  .wrap.tomanify-ltr,
  .wrap.tomanify-rtl {
    max-width: 100%;
    overflow-x: hidden;
  }

  .wrap.tomanify-ltr .tomanify-admin-container,
  .wrap.tomanify-rtl .tomanify-admin-container,
  .wrap.tomanify-ltr .tomanify-form,
  .wrap.tomanify-rtl .tomanify-form,
  .wrap.tomanify-ltr .tomanify-card,
  .wrap.tomanify-rtl .tomanify-card,
  .wrap.tomanify-ltr .tomanify-choice,
  .wrap.tomanify-rtl .tomanify-choice {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .wrap.tomanify-ltr .tomanify-card,
  .wrap.tomanify-rtl .tomanify-card {
    overflow: visible;
  }

  .wrap.tomanify-ltr .tomanify-card > *:not(.tomanify-table-scroll),
  .wrap.tomanify-rtl .tomanify-card > *:not(.tomanify-table-scroll),
  .wrap.tomanify-ltr .tomanify-card p,
  .wrap.tomanify-rtl .tomanify-card p,
  .wrap.tomanify-ltr .tomanify-card fieldset,
  .wrap.tomanify-rtl .tomanify-card fieldset,
  .wrap.tomanify-ltr .tomanify-card label,
  .wrap.tomanify-rtl .tomanify-card label,
  .wrap.tomanify-ltr .tomanify-card .tomanify-source-field,
  .wrap.tomanify-rtl .tomanify-card .tomanify-source-field,
  .wrap.tomanify-ltr .tomanify-card .tomanify-warning,
  .wrap.tomanify-rtl .tomanify-card .tomanify-warning {
    max-width: 100%;
  }

  .wrap.tomanify-ltr .tomanify-choice,
  .wrap.tomanify-rtl .tomanify-choice {
    display: flex;
    width: auto;
    margin-right: 0;
    margin-left: 0;
  }

  .wrap.tomanify-ltr .tomanify-source-field input[type="url"],
  .wrap.tomanify-rtl .tomanify-source-field input[type="url"] {
    flex: 0 1 auto;
    min-height: 34px;
    height: auto;
  }

  .wrap.tomanify-ltr .tomanify-table-scroll,
  .wrap.tomanify-rtl .tomanify-table-scroll {
    overflow-x: auto;
    overflow-y: hidden;
  }
}
