/* Farasync Date Picker (front-end rep panel copy, v1.0.0).
   Extracted from admin-command-center.css — keep the two in sync.
   v1.0.0 FIX: the v1.0.0 extraction stopped at the old @supports marker, so
   the calendar header (month/year buttons), the month/year views, the year
   list, the footer grid and the RTL/LTR rules never reached the front end and
   the store theme painted the bare buttons red. The file now carries the
   complete picker rules plus a !important theme-armor layer. */
.farasync-date-control {
    position: relative;
    width: min(100%, 410px);
}

/*
 * v1.0.0 FIX (user report): the "from date / to date + CSV" toolbar in the
 * Logs, Invoices and Sales tabs wrapped onto THREE rows because each date
 * control reserved min(100%, 410px) of the flex row. Inside the filter
 * toolbar the controls must stay compact so label + two dates + both
 * buttons fit on a single line.
 *
 * v1.0.0 (user request, item 2): HALVED — the از تاریخ / تا تاریخ
 * controls in the «گزارش فروش» and «فاکتورهای نمایندگان» toolbars were
 * still too wide; 200px → 100px (the Jalali value «۱۴۰۵/۰۶/۱۷» + the
 * calendar glyph still fit comfortably).
 */
.farasync-logs-filter .farasync-date-control {
    width: 100px;
    min-width: 84px;
    flex: 0 1 100px;
}

.farasync-logs-filter .farasync-date-trigger {
    min-height: 32px;
    padding: 4px 8px 4px 10px;
}

/* The nested GET/POST forms inside the toolbar must not break the line. */
.farasync-logs-filter form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    margin: 0;
}

.farasync-logs-filter .button,
.farasync-logs-filter label {
    white-space: nowrap;
}

.farasync-date-source {
    display: none !important;
}

.farasync-date-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 38px;
    padding: 7px 10px 7px 12px;
    color: #94a3b8;
    text-align: start;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #d7e0ec;
    border-radius: 7px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.farasync-date-trigger.has-value {
    color: #334155;
}

.farasync-date-trigger:hover,
.farasync-date-trigger[aria-expanded="true"] {
    border-color: #818cf8;
    background: #f8fbff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.farasync-date-trigger-value {
    font-size: 12.5px;
}

.farasync-date-trigger-icon {
    display: inline-flex;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: #6366f1;
}

.farasync-date-trigger-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.farasync-date-picker {
    position: fixed;
    z-index: 100004;
    display: none;
    width: min(320px, calc(100vw - 18px));
    padding: 10px;
    color: #334155;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #dce5f0;
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2), 0 2px 6px rgba(15, 23, 42, 0.06);
    direction: inherit;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.farasync-date-picker.is-open {
    display: block;
    animation: farasync-date-picker-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes farasync-date-picker-in {
    from {
        opacity: 0;
        transform: translate3d(0, -5px, 0) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

.farasync-date-picker-header {
    display: grid;
    grid-template-columns: 32px 1fr 32px;
    align-items: center;
    gap: 6px;
    padding: 2px 1px 9px;
    border-bottom: 1px solid #e8eef6;
}

.farasync-date-picker-title {
    color: #1e293b;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
}

.farasync-date-picker-title strong {
    color: #4f46e5;
    font-weight: 700;
}

.farasync-date-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    padding: 0;
    color: #475569;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.farasync-date-nav:hover {
    color: #4338ca;
    background: #eef2ff;
    border-color: #c7d2fe;
}

.farasync-date-nav:disabled,
.farasync-date-picker-footer button:disabled {
    color: #cbd5e1 !important;
    cursor: not-allowed !important;
    background: #f8fafc !important;
    border-color: #edf2f7 !important;
    box-shadow: none !important;
    opacity: 0.7;
}

.farasync-date-nav svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.farasync-date-weekdays,
.farasync-date-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
}

.farasync-date-weekdays {
    padding: 9px 2px 4px;
    color: #94a3b8;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
}

.farasync-date-day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    color: #475569;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 11.5px;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

button.farasync-date-day:hover {
    color: #3730a3;
    background: #eef2ff;
    border-color: #c7d2fe;
    transform: translate3d(0, -1px, 0);
}

.farasync-date-day.is-today {
    color: #4f46e5;
    border-color: #a5b4fc;
    font-weight: 700;
}

.farasync-date-day.is-selected {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-color: #4f46e5;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.22);
}

.farasync-date-day.is-empty {
    cursor: default;
}

.farasync-date-picker-footer {
    display: flex;
    justify-content: space-between;
    gap: 7px;
    margin-top: 9px;
    padding: 9px 1px 1px;
    border-top: 1px solid #e8eef6;
}

.farasync-date-picker-footer button {
    min-height: 30px;
    padding: 5px 9px;
    color: #475569;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #dce5f0;
    border-radius: 6px;
    font-size: 11px;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.farasync-date-picker-footer button:hover {
    color: #3730a3;
    background: #f8faff;
    border-color: #a5b4fc;
}

.farasync-date-picker-footer button.is-primary {
    color: #ffffff;
    background: #4f46e5;
    border-color: #4f46e5;
}

/* ==========================================================================
   Calendar header, month/year views, year list, footer grid and direction
   v1.0.0 FIX: this section existed only in admin-command-center.css — the
   front-end extraction used to stop at the @supports marker below it, so the
   rep-panel calendar rendered its bare month/year buttons through the store
   theme (red) and the header collapsed. Values stay identical to
   admin-command-center.css — keep the two in sync.
   ========================================================================== */
.farasync-date-picker[dir="rtl"] {
    direction: rtl;
}

.farasync-date-picker[dir="ltr"] {
    direction: ltr;
}

.farasync-date-picker-title {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.farasync-date-month-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.farasync-date-month-name {
    min-width: 0;
    max-width: 150px;
    padding: 4px 6px !important;
    color: #3730a3 !important;
    cursor: pointer;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    font: inherit !important;
    font-weight: 700 !important;
}

.farasync-date-month-name:hover {
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
}

.farasync-date-year-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 72px;
    min-height: 30px;
    padding: 4px 7px;
    color: #3730a3;
    cursor: pointer;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.farasync-date-year-trigger:hover,
.farasync-date-year-trigger.is-active {
    color: #312e81;
    background: #e0e7ff;
    border-color: #a5b4fc;
    transform: translate3d(0, -1px, 0);
}

.farasync-date-year-trigger svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.farasync-date-view-hint {
    padding: 10px 4px 4px;
    color: #64748b;
    text-align: center;
    font-size: 11px;
}

.farasync-date-month-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 2px 4px;
}

.farasync-date-month {
    min-height: 38px;
    padding: 6px 5px;
    color: #475569;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid #dce5f0;
    border-radius: 7px;
    font-size: 11px;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.farasync-date-month:hover:not(:disabled) {
    color: #3730a3;
    background: #eef2ff;
    border-color: #a5b4fc;
    transform: translate3d(0, -1px, 0);
}

.farasync-date-month.is-selected {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-color: #4f46e5;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.18);
}

.farasync-date-back-to-days {
    width: 100%;
    min-height: 30px;
    margin-top: 4px;
    padding: 5px 8px;
    color: #4338ca;
    cursor: pointer;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 11px;
}

.farasync-date-back-to-days:hover {
    background: #e0e7ff;
}

.farasync-date-year-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    /*
     * Six initial years are rendered in two columns. Keep the viewport just
     * shorter than those three rows so touch/trackpad scrolling also has a
     * real scroll boundary that can trigger the next batch.
     */
    max-height: 122px;
    margin: 2px 1px 0;
    padding: 8px 4px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    overscroll-behavior: contain;
    scrollbar-color: #c7d2fe transparent;
    scrollbar-width: thin;
}

.farasync-date-year {
    min-height: 34px;
    padding: 5px 6px;
    color: #475569;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #dce5f0;
    border-radius: 7px;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.farasync-date-year:hover:not(:disabled) {
    color: #3730a3;
    background: #eef2ff;
    border-color: #a5b4fc;
    transform: translate3d(0, -1px, 0);
}

.farasync-date-year.is-selected {
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-color: #4f46e5;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.18);
}

.farasync-date-year-scroll-hint {
    padding: 5px 4px 1px;
    color: #94a3b8;
    text-align: center;
    font-size: 10px;
}

.farasync-date-year-scroll-hint.is-complete {
    opacity: 0.45;
}

.farasync-date-day.is-disabled,
.farasync-date-month.is-disabled,
.farasync-date-year.is-disabled,
.farasync-date-day:disabled,
.farasync-date-month:disabled,
.farasync-date-year:disabled {
    color: #cbd5e1 !important;
    cursor: not-allowed !important;
    background: #f8fafc !important;
    border-color: #edf2f7 !important;
    box-shadow: none !important;
    opacity: 0.75;
    transform: none !important;
}

button.farasync-date-day:disabled,
button.farasync-date-month:disabled,
button.farasync-date-year:disabled {
    pointer-events: none;
}

.farasync-date-picker-footer {
    display: grid !important;
    grid-template-columns: 1fr auto;
    align-items: center;
}

.farasync-date-primary-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ==========================================================================
   v1.0.0 — THEME ARMOR (both copies; decisive on the front-end rep panel)
   Store themes style bare <button> elements (the Digikala-style theme paints
   them red). The rules above already win on specificity, but themes often use
   classed selectors such as ".sidebar button". This layer re-asserts the
   exact palette with !important. Every base rule carries :not(:disabled) /
   :not(:hover) guards so the gray disabled states above keep winning.
   Keep the VALUES identical to the sections above when the palette changes.
   ========================================================================== */
.farasync-date-picker,
.farasync-date-picker *,
.farasync-date-control,
.farasync-date-control * {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif !important;
}

.farasync-date-picker button {
    appearance: none !important;
    -webkit-appearance: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
    line-height: 1.35 !important;
}

.farasync-date-picker,
.farasync-date-picker *,
.farasync-date-control,
.farasync-date-control * {
    box-sizing: border-box;
}

.farasync-date-picker button.farasync-date-nav:not(:disabled) {
    padding: 0 !important;
    color: #475569 !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
}

.farasync-date-picker button.farasync-date-nav:hover:not(:disabled) {
    color: #4338ca !important;
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
}

.farasync-date-picker button.farasync-date-day:not(:disabled) {
    padding: 0 !important;
    color: #475569 !important;
    background: transparent !important;
    border-color: transparent !important;
    border-radius: 6px !important;
    font-size: 11.5px !important;
}

.farasync-date-picker button.farasync-date-day:hover:not(:disabled) {
    color: #3730a3 !important;
    background: #eef2ff !important;
    border-color: #c7d2fe !important;
}

.farasync-date-picker button.farasync-date-day.is-today:not(:disabled) {
    color: #4f46e5 !important;
    border-color: #a5b4fc !important;
    font-weight: 700 !important;
}

.farasync-date-picker button.farasync-date-day.is-selected:not(:disabled) {
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.22) !important;
}

.farasync-date-picker button.farasync-date-month:not(:disabled) {
    padding: 6px 5px !important;
    color: #475569 !important;
    background: #f8fafc !important;
    border-color: #dce5f0 !important;
    border-radius: 7px !important;
    font-size: 11px !important;
}

.farasync-date-picker button.farasync-date-month:hover:not(:disabled) {
    color: #3730a3 !important;
    background: #eef2ff !important;
    border-color: #a5b4fc !important;
}

.farasync-date-picker button.farasync-date-month.is-selected:not(:disabled) {
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.18) !important;
}

.farasync-date-picker button.farasync-date-year:not(:disabled) {
    padding: 5px 6px !important;
    color: #475569 !important;
    background: #ffffff !important;
    border-color: #dce5f0 !important;
    border-radius: 7px !important;
    font-size: 11px !important;
}

.farasync-date-picker button.farasync-date-year:hover:not(:disabled) {
    color: #3730a3 !important;
    background: #eef2ff !important;
    border-color: #a5b4fc !important;
}

.farasync-date-picker button.farasync-date-year.is-selected:not(:disabled) {
    color: #ffffff !important;
    background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 5px 10px rgba(79, 70, 229, 0.18) !important;
}

.farasync-date-picker button.farasync-date-year-trigger {
    color: #3730a3 !important;
    background: #eef2ff !important;
    border: 1px solid #c7d2fe !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
}

.farasync-date-picker button.farasync-date-year-trigger:hover,
.farasync-date-picker button.farasync-date-year-trigger.is-active {
    color: #312e81 !important;
    background: #e0e7ff !important;
    border-color: #a5b4fc !important;
}

.farasync-date-picker button.farasync-date-back-to-days {
    color: #4338ca !important;
    background: #eef2ff !important;
    border: 1px solid #c7d2fe !important;
    border-radius: 6px !important;
    font-size: 11px !important;
}

.farasync-date-picker .farasync-date-picker-footer button:not(:disabled) {
    color: #475569 !important;
    background: #ffffff !important;
    border-color: #dce5f0 !important;
    border-radius: 6px !important;
    font-size: 11px !important;
}

.farasync-date-picker .farasync-date-picker-footer button:hover:not(:disabled) {
    color: #3730a3 !important;
    background: #f8faff !important;
    border-color: #a5b4fc !important;
}

.farasync-date-picker .farasync-date-picker-footer button.is-primary:not(:disabled) {
    color: #ffffff !important;
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
}

@media screen and (max-width: 782px) {
    .farasync-date-picker-footer {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .farasync-date-primary-actions {
        justify-content: space-between;
    }
}

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

/* ----------------------------------------------------------------------
   v1.0.0 — «از امروز به مدت [X] ماه» quick-set dropdown. Rendered by
   PHP next to any از/تا date pair (reports filters + the campaign form);
   options are filled by admin-date-picker.js. Lives here so EVERY tab
   that loads the date picker gets the same styling.
   ---------------------------------------------------------------------- */
.farasync-range-month-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.farasync-range-month-label {
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}
.farasync-range-month-wrap select.farasync-range-month {
    min-width: 130px;
    border-radius: 6px;
    border-color: #cdd5e0;
    padding: 3px 26px 3px 10px;
    height: auto;
    max-width: 46vw;
}
.farasync-range-month-unit {
    color: #64748b;
    font-size: 12px;
}
@media (max-width: 782px) {
    .farasync-range-row {
        width: 100%;
    }
    .farasync-range-month-wrap select.farasync-range-month {
        flex: 1 1 auto;
    }
}
