/* === databases.css === */
/* Reference pages: tables, search, filter chips, copy-to-clipboard */

/* ---- Index page: heading + search (аналог calc index) ---- */
.ref-index-heading {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
    margin: 0 0 28px;
}
.ref-index-search {
    max-width: 480px;
    margin: 0 auto 28px;
}
.ref-index-search .search-input-wrap .form-input--styled {
    width: 100%;
    border-radius: var(--radius);
    padding: 12px 44px 12px 16px;
    font-size: 1rem;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ref-index-search .search-input-wrap .form-input--styled:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
.ref-index-search .search-btn {
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}
.ref-index-no-results {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    display: none;
}

/* ---- Index cards grid (использует стиль calculator-card) ---- */
.ref-index-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    margin-bottom: 2rem;
}
.ref-index-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid var(--glass-border);
    text-decoration: none;
    color: inherit;
    display: block;
}
.ref-index-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.ref-index-card__title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}
.ref-index-card__desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.75rem;
}
.ref-index-card__count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}
[data-theme="dark"] .ref-index-card {
    background: rgba(15, 23, 42, 0.6);
}
[data-theme="dark"] .ref-index-card__title {
    color: var(--primary-bright);
}

/* ---- Reference page header ---- */
.ref-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.ref-header__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    flex-shrink: 0;
}
.ref-header__icon svg {
    width: 26px;
    height: 26px;
    stroke: var(--primary);
}
.ref-header__titles {
    flex: 1;
    min-width: 0;
}
.ref-header__title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px;
}
.ref-header__subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}
.ref-header__count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---- Search + filters bar ---- */
.ref-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.ref-search {
    position: relative;
    flex: 1;
    min-width: 220px;
}
.ref-search__input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    font-size: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: var(--text-main);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ref-search__input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
.ref-search__icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
    pointer-events: none;
}

/* ---- Filter chips ---- */
.ref-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.ref-chip:hover {
    border-color: var(--glass-border-hover);
    color: var(--text-main);
}
.ref-chip--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.ref-chip__count {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ---- Table ---- */
.ref-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}
.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.ref-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
.ref-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-surface);
    border-bottom: 2px solid var(--glass-border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}
.ref-table th:hover {
    color: var(--primary);
}
.ref-table th.ref-th-nosort {
    cursor: default;
}
.ref-table th.ref-th-nosort:hover {
    color: var(--text-muted);
}
.ref-table th .ref-sort-icon {
    display: inline-block;
    width: 14px;
    margin-left: 4px;
    opacity: 0.4;
    font-size: 0.75rem;
}
.ref-table th.ref-th-sorted .ref-sort-icon {
    opacity: 1;
    color: var(--primary);
}
.ref-table tbody tr {
    border-bottom: 1px solid var(--glass-border);
    transition: background var(--transition);
}
.ref-table tbody tr:hover {
    background: var(--bg-surface-hover);
}
.ref-table tbody tr:last-child {
    border-bottom: none;
}
.ref-table td {
    padding: 8px 14px;
    color: var(--text-main);
    white-space: nowrap;
}
.ref-table td.ref-td-flag {
    font-size: 1.3rem;
    text-align: center;
    width: 50px;
}
.ref-table td.ref-td-code {
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: color var(--transition);
}
.ref-table td.ref-td-code:hover {
    text-decoration: underline;
}
.ref-table td.ref-td-iso {
    font-family: 'Manrope', monospace;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.ref-table td.ref-td-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.ref-table td.ref-td-copy {
    cursor: pointer;
    transition: color var(--transition);
}
.ref-table td.ref-td-copy:hover {
    color: var(--primary);
}
.ref-table td.ref-td-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---- Population year hint in table header ---- */
.ref-th-pop {
    position: relative;
}
.ref-th-pop__hint {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 5px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    border-radius: 3px;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
}

/* ---- Table body scroll container ---- */
.ref-table-scroll {
    max-height: 620px;
    overflow-y: auto;
    overflow-x: auto;
}
.ref-table-scroll thead {
    position: sticky;
    top: 0;
}

/* ---- Empty state (no search results) ---- */
.ref-empty {
    display: none;
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.ref-empty--visible {
    display: block;
}
.ref-empty__icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}
.ref-empty__text {
    font-size: 1rem;
    margin: 0;
}

/* ---- Currency cards (currency-symbols page) ---- */
.ref-currency-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.ref-currency-card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    transition: box-shadow var(--transition), border-color var(--transition);
    position: relative;
}
.ref-currency-card:hover {
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-md);
}
.ref-currency-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.ref-currency-card__symbol {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    min-width: 50px;
    text-align: center;
}
.ref-currency-card__symbol--text {
    font-size: 1.3rem;
    font-weight: 600;
}
.ref-currency-card__names {
    flex: 1;
    min-width: 0;
}
.ref-currency-card__name-ru {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 2px;
}
.ref-currency-card__name-en {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}
.ref-currency-card__iso {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    background: transparent;
}
.ref-currency-card__body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}
.ref-currency-card__field {
    display: flex;
    flex-direction: column;
}
.ref-currency-card__label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}
.ref-currency-card__value {
    color: var(--text-main);
}
.ref-currency-card__countries {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    margin-top: 4px;
}
.ref-currency-card__copy-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
}
.ref-currency-card__copy-btn:hover {
    color: var(--primary);
    border-color: var(--glass-border-hover);
}

/* ---- Copy toast ---- */
.ref-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 10px 20px;
    background: var(--toast-bg);
    color: var(--toast-text);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}
.ref-toast--visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ---- Info box ---- */
.ref-info {
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .ref-index-heading {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    .ref-header {
        flex-wrap: wrap;
    }
    .ref-header__count {
        order: 3;
    }
    .ref-toolbar {
        flex-direction: column;
    }
    .ref-search {
        min-width: 100%;
    }
    .ref-table {
        font-size: 0.82rem;
    }
    .ref-table th,
    .ref-table td {
        padding: 6px 10px;
    }
    .ref-table td.ref-td-flag {
        width: 36px;
        font-size: 1.1rem;
    }
    .ref-currency-grid {
        grid-template-columns: 1fr;
    }
    .ref-index-grid {
        grid-template-columns: 1fr;
    }
    .ref-table-scroll {
        max-height: 480px;
    }
}

/* ---- Sticky toolbar (generic) ---- */
.ref-toolbar--sticky {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg-main, var(--bg-surface));
    padding: 8px 0;
    margin-bottom: 12px;
}

/* ---- Quick codes (generic) ---- */
.ref-quick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.ref-quick__label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}
.ref-quick-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    color: var(--text-main);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.ref-quick-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(var(--accent-rgb, 90, 82, 224), 0.06);
}

/* ---- Search highlight (generic) ---- */
.ref-hl {
    background: rgba(var(--accent-rgb, 90, 82, 224), 0.15);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ---- Row flash (generic) ---- */
.ref-row--flash {
    animation: ref-flash 1.5s ease-out;
}
@keyframes ref-flash {
    0% { background: rgba(var(--accent-rgb, 90, 82, 224), 0.25); }
    100% { background: transparent; }
}

/* ---- Mode toggle (tree/list, generic) ---- */
.ref-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}
.ref-mode-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}
.ref-mode-btn:hover {
    color: var(--text-main);
}
.ref-mode-btn--active {
    background: var(--primary);
    color: #fff;
}

/* ---- Quick codes (mobile, generic) ---- */
@media (max-width: 768px) {
    .ref-quick {
        gap: 6px;
    }
    .ref-quick-chip {
        font-size: 0.78rem;
        padding: 4px 10px;
    }
    .ref-mode-toggle {
        width: 100%;
    }
    .ref-mode-btn {
        flex: 1;
        text-align: center;
    }
}
