/**
 * Стили для архива промокодов
 * Тёплая палитра, согласованная с Kadence / promo-herb-coupons / promo-site-stats
 */

/* ========================================================================
   Основной контейнер и переменные
   ======================================================================== */

.hpa-archive {
    margin: 30px auto;
    padding: 0;
    box-sizing: border-box;
    max-width: 1200px;

    --hpa-accent: var(--global-palette-btn-bg, #f0b429);
    --hpa-accent-dark: #d49a1f;
    --hpa-text: var(--global-palette3, #222222);
    --hpa-text-muted: var(--global-palette5, #515151);
    --hpa-border: var(--global-palette7, #e3d8c7);
    --hpa-bg: var(--global-palette8, #F7F7F7);
    --hpa-card-bg: rgb(187 151 4 / 0.08);
    --hpa-white: var(--global-palette9, #ffffff);

}

.hpa-archive *,
.hpa-archive *::before,
.hpa-archive *::after {
    box-sizing: border-box;
}

/* ========================================================================
   Описание
   ======================================================================== */

.hpa-description {
    margin-bottom: 16px;
    color: var(--hpa-text-muted, #515151);
    font-size: 14px;
    line-height: 1.6;
    padding: 0;
    background: none;
    border: none;
}

/* ========================================================================
   Элементы управления
   ======================================================================== */

.hpa-controls {
    margin-bottom: 20px;
    padding: 16px;
    background: rgb(187 151 4 / 0.04);
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.hpa-search-wrapper {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--hpa-border, #e3d8c7);
}

.hpa-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    font-size: 14px;
    background: var(--hpa-white, #ffffff);
    color: var(--hpa-text, #222222);
}

.hpa-search-input:focus {
    outline: 2px solid var(--hpa-accent, #f0b429);
    outline-offset: -1px;
    border-color: var(--hpa-accent, #f0b429);
}

.hpa-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border: none;
    padding: 0;
    margin: 0;
}

.hpa-filters legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.hpa-filters > label:first-of-type {
    font-weight: 600;
    font-size: 12px;
    color: var(--hpa-text-muted, #515151);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hpa-filters label:not(:first-of-type) {
    font-weight: 500;
    font-size: 13px;
}

.hpa-date-range-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hpa-date-range-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.hpa-date-filter,
.hpa-date-input {
    padding: 8px 12px;
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    font-size: 13px;
    background: var(--hpa-white, #ffffff);
    color: var(--hpa-text, #222222);
    height: auto;
    line-height: 1.4;
}

.hpa-date-filter {
    min-width: 160px;
    max-width: 220px;
}

.hpa-date-input {
    width: 150px;
}

.hpa-date-filter:focus,
.hpa-date-input:focus {
    outline: 2px solid var(--hpa-accent, #f0b429);
    outline-offset: -1px;
    border-color: var(--hpa-accent, #f0b429);
}

.hpa-reset-btn {
    padding: 8px 16px;
    background: var(--hpa-white, #ffffff);
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--hpa-text-muted, #515151);
    font-family: inherit;
    height: auto;
    line-height: 1.4;
    margin-left: auto;
}

.hpa-reset-btn:hover {
    background: rgb(187 151 4 / 0.1);
    border-color: var(--hpa-accent, #f0b429);
    color: var(--hpa-text, #222222);
}

.hpa-reset-btn:active {
    transform: scale(0.97);
}

@media (min-width: 768px) {
    .hpa-controls {
        padding: 18px 22px;
        margin-bottom: 24px;
    }

    .hpa-search-input {
        font-size: 15px;
        padding: 11px 16px;
    }

    .hpa-date-filter,
    .hpa-date-input {
        font-size: 14px;
        padding: 9px 14px;
    }

    .hpa-reset-btn {
        font-size: 14px;
    }
}

/* ========================================================================
   Таблица — card-like rows
   ======================================================================== */

.hpa-table-wrapper {
    overflow-x: auto;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.hpa-table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.hpa-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.hpa-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--hpa-border, #e3d8c7);
    border-radius: 3px;
}

.hpa-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    min-width: 0;
    box-shadow: none;
}

/* Header — лёгкий, ненавязчивый */
.hpa-table thead {
    background: transparent;
    color: var(--hpa-text-muted, #515151);
    position: sticky;
    top: 0;
    z-index: 10;
}

.hpa-table th {
    padding: 0 16px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    white-space: nowrap;
    background: var(--hpa-bg, #F7F7F7);
}

.hpa-table th:last-child {
    text-align: right;
}

/* Строки — card-like */
.hpa-table tbody tr {
    background: var(--hpa-white, #ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 0.15s;
}

.hpa-table tbody tr:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hpa-table td {
    padding: 10px 14px;
    font-size: 14px;
    vertical-align: middle;
    color: var(--hpa-text, #222222);
    border-top: 1px solid var(--hpa-border, #e3d8c7);
    border-bottom: 1px solid var(--hpa-border, #e3d8c7);
    background: inherit;
}

.hpa-table td:first-child {
    border-left: 1px solid var(--hpa-border, #e3d8c7);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    border-right: none;
}

.hpa-table td:last-child {
    border-right: 1px solid var(--hpa-border, #e3d8c7);
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-left: none;
    text-align: right;
}

/* Код промокода */
.hpa-table .hpa-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    color: var(--hpa-text, #222);
    font-size: 15px;
    letter-spacing: 0.5px;
    word-break: break-all;
}

/* Дата */
.hpa-table .hpa-date {
    white-space: nowrap;
    color: var(--hpa-text-muted, #515151);
}

.hpa-table time {
    font-weight: 400;
    font-size: 13px;
    color: inherit;
}

/* Десктоп: grid-раскладка 2-3 колонки */
@media (min-width: 768px) {
    .hpa-table thead {
        display: none;
    }

    .hpa-table {
        border-spacing: 0;
    }

    .hpa-table tbody {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .hpa-table tbody tr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-radius: 8px;
    }

    .hpa-table td {
        padding: 10px 14px;
        border: none;
        border-radius: 0;
    }

    .hpa-table td:first-child {
        border: none;
        border-radius: 0;
    }

    .hpa-table td:last-child {
        border: none;
        border-radius: 0;
        margin-left: auto;
    }

    .hpa-table tbody tr {
        border: 1px solid var(--hpa-border, #e3d8c7);
        border-radius: 8px;
    }

    .hpa-table .hpa-code {
        font-size: 14px;
        letter-spacing: 0.5px;
    }

    .hpa-table time {
        font-size: 13px;
    }
}

@media (min-width: 1200px) {
    .hpa-table tbody {
        grid-template-columns: repeat(3, 1fr);
    }
}

.hpa-table .hpa-no-date {
    color: var(--hpa-text-muted, #515151);
    font-style: italic;
    opacity: 0.7;
}

/* ========================================================================
   Индикатор загрузки
   ======================================================================== */

.hpa-loading {
    text-align: center;
    padding: 24px;
    color: var(--hpa-text-muted, #515151);
    font-size: 14px;
}

.hpa-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--hpa-border, #e3d8c7);
    border-top-color: var(--hpa-accent, #f0b429);
    border-radius: 50%;
    animation: hpa-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes hpa-spin {
    to { transform: rotate(360deg); }
}

/* Нет результатов */
.hpa-no-results {
    text-align: center;
    padding: 48px 20px !important;
    color: var(--hpa-text-muted, #515151);
    font-style: italic;
    border-left: none !important;
}

.hpa-table tbody tr:only-child {
    grid-column: 1 / -1;
}

/* Плавный переход при загрузке */
#hpa-tbody {
    transition: opacity 0.2s ease;
}

/* ========================================================================
   Пагинация
   ======================================================================== */

.hpa-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 16px 20px;
    background: var(--hpa-white, #ffffff);
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 12px;
    gap: 12px;
}

.hpa-pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--hpa-text-muted, #515151);
}

.hpa-per-page {
    padding: 6px 10px;
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    font-size: 13px;
    background: var(--hpa-white, #ffffff);
    color: var(--hpa-text, #222222);
}

.hpa-per-page:focus {
    outline: 2px solid var(--hpa-accent, #f0b429);
    outline-offset: -1px;
    border-color: var(--hpa-accent, #f0b429);
}

.hpa-pages {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.hpa-archive .hpa-page-btn {
    padding: 8px 14px;
    background: var(--hpa-white, #ffffff);
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    min-width: 40px;
    transition: all 0.15s;
    color: var(--hpa-text, #222222);
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
    text-align: center;
}

.hpa-archive .hpa-page-btn:hover {
    background: var(--hpa-accent, #f0b429);
    border-color: var(--hpa-accent, #f0b429);
    color: #222;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(240, 180, 41, 0.3);
}

.hpa-archive .hpa-page-btn:active {
    transform: translateY(0);
}

.hpa-archive .hpa-page-current {
    padding: 8px 14px;
    background: var(--hpa-accent, #f0b429);
    color: #222;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    min-width: 40px;
    display: inline-block;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 2px 6px rgba(240, 180, 41, 0.3);
}

.hpa-archive .hpa-page-ellipsis {
    padding: 6px 4px;
    color: var(--hpa-text-muted, #515151);
    font-size: 13px;
}

.hpa-info {
    color: var(--hpa-text-muted, #515151);
    font-size: 13px;
}

@media (min-width: 768px) {
    .hpa-pagination {
        padding: 20px 24px;
    }

    .hpa-pages {
        gap: 6px;
    }

    .hpa-archive .hpa-page-btn,
    .hpa-archive .hpa-page-current {
        padding: 10px 16px;
        font-size: 14px;
        min-width: 44px;
    }

    .hpa-pagination-controls {
        font-size: 14px;
    }

    .hpa-per-page {
        font-size: 14px;
        padding: 8px 12px;
    }

    .hpa-info {
        font-size: 14px;
    }
}

/* ========================================================================
   Адаптивность
   ======================================================================== */

@media (max-width: 767px) {
    .hpa-archive {
        margin: 16px 0;
    }

    .hpa-description {
        font-size: 13px;
    }

    .hpa-controls {
        padding: 14px;
    }

    .hpa-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .hpa-filters > label:first-of-type {
        margin-bottom: -4px;
    }

    .hpa-date-filter {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .hpa-date-range-wrapper {
        width: 100%;
        gap: 8px;
    }

    .hpa-date-range-item {
        flex: 1;
        min-width: 0;
    }

    .hpa-date-range-item label {
        white-space: nowrap;
        flex-shrink: 0;
        font-weight: 500;
        font-size: 13px;
    }

    .hpa-date-input {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    .hpa-reset-btn {
        width: 100%;
        margin-left: 0;
        text-align: center;
    }

    /* Таблица */
    .hpa-table {
        border-spacing: 0 3px;
    }

    .hpa-table th {
        padding: 0 10px 6px;
        font-size: 10px;
    }

    .hpa-table td {
        padding: 9px 10px;
        font-size: 13px;
    }

    .hpa-table .hpa-code {
        font-size: 14px;
    }

    .hpa-table time {
        font-size: 12px;
    }

    /* Пагинация */
    .hpa-pagination {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        gap: 10px;
    }

    .hpa-pagination-controls {
        justify-content: space-between;
        width: 100%;
    }

    .hpa-pages {
        width: 100%;
        justify-content: center;
    }

    .hpa-info {
        width: 100%;
        text-align: center;
    }
}

/* ========================================================================
   Переключатель «Подробный вид»
   ======================================================================== */

.hpa-view-toggle {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.hpa-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--hpa-text-muted, #515151);
    padding: 6px 14px;
    border: 1px solid var(--hpa-border, #e3d8c7);
    border-radius: 8px;
    background: var(--hpa-white, #ffffff);
    transition: all 0.2s;
    user-select: none;
}

.hpa-toggle-label:hover {
    border-color: var(--hpa-accent, #f0b429);
    color: var(--hpa-text, #222);
}

.hpa-toggle-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    background: var(--hpa-border, #e3d8c7);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hpa-toggle-checkbox::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--hpa-white, #fff);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.hpa-toggle-checkbox:checked {
    background: var(--hpa-accent, #f0b429);
}

.hpa-toggle-checkbox:checked::after {
    transform: translateX(16px);
}

/* ========================================================================
   Скрытые detail-колонки (по умолчанию)
   ======================================================================== */

.hpa-col-detail {
    display: none;
}

/* Показываем при активации подробного вида */
.hpa-table--detailed .hpa-col-detail {
    display: table-cell;
}

/* В подробном режиме переключаемся на классическую табличную раскладку */
@media (min-width: 768px) {
    .hpa-table--detailed thead {
        display: table-header-group;
    }

    .hpa-table--detailed tbody {
        display: table-row-group;
    }

    .hpa-table--detailed tbody tr {
        display: table-row;
    }

    .hpa-table--detailed td,
    .hpa-table--detailed th {
        display: table-cell;
    }
}

/* Стили для detail-колонок */
.hpa-col-discount {
    font-weight: 600;
    white-space: nowrap;
    color: var(--hpa-accent-dark, #d49a1f);
}

.hpa-col-target {
    color: var(--hpa-text-muted, #515151);
    font-size: 13px;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hpa-col-countries {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    color: var(--hpa-text-muted, #515151);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* На мобильных подробный вид показывает детали под кодом */
@media (max-width: 767px) {
    .hpa-table--detailed .hpa-col-detail {
        display: none;
    }

    /* На мобильных показываем как data-атрибуты через ::after */
    .hpa-table--detailed .hpa-code::after {
        content: attr(data-detail);
        display: block;
        font-family: inherit;
        font-weight: 400;
        font-size: 12px;
        color: var(--hpa-text-muted, #515151);
        margin-top: 2px;
        letter-spacing: 0;
    }
}
