/* ============================================================
   Уникализация изображений — дизайн-слой поверх Bootstrap 5.3
   Токены → переопределение Bootstrap → компоненты
   ============================================================ */

:root {
    /* Нейтральная база (zinc, только светлая тема) */
    --bg:         #fafafa;
    --surface:    #ffffff;
    --surface-2:  #f4f4f5;
    --border:     #e4e4e7;
    --border-strong: #d4d4d8;
    --text:       #18181b;
    --text-muted: #71717a;

    /* Акцент: электрик-синий */
    --accent:        #2563eb;
    --accent-hover:  #1d4ed8;
    --accent-soft:   #eff6ff;
    --accent-border: #bfdbfe;

    /* Семантика */
    --ok:       #16a34a;
    --ok-soft:  #f0fdf4;
    --danger:   #dc2626;
    --danger-soft: #fef2f2;
    --warn:     #d97706;
    --warn-soft:   #fffbeb;

    /* Радиусы: единый скейл */
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;

    /* Тени с тонировкой (не чёрные) */
    --shadow-sm: 0 1px 2px rgb(24 24 27 / 0.05);
    --shadow:    0 1px 3px rgb(24 24 27 / 0.07), 0 1px 2px rgb(24 24 27 / 0.05);
    --shadow-lg: 0 10px 30px rgb(24 24 27 / 0.10), 0 2px 8px rgb(24 24 27 / 0.05);

    /* Тёмная альтернатива для бейджей на изображениях */
    --scrim: rgb(24 24 27 / 0.55);

    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: var(--accent);
    --bs-link-hover-color: var(--accent-hover);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius);
}

/* ---- Базовая типографика ------------------------------------ */

* { box-sizing: border-box; outline: none; font-family: "Fira Sans", sans-serif; }

h1 {
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    font-weight: 700;
}

.page-subtitle { color: var(--text-muted); }

.tabular-nums, .size-info, .stats-percents, .cost-figure { font-variant-numeric: tabular-nums; }

/* ---- Карточки и секции --------------------------------------- */

.card-surface {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.section-card .field-label {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
}

.field-hint {
    color: var(--text-muted);
    font-weight: 300;
    font-size: 0.92em;
}

/* ---- Формы ---------------------------------------------------- */

.form-control, .form-select, textarea, input[type="text"], select {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus, textarea:focus, input[type="text"]:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.18);
}

textarea { resize: vertical; line-height: 1.5; }

/* ---- Кнопки ---------------------------------------------------- */

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover);
    --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: var(--accent-hover);
    --bs-btn-active-border-color: var(--accent-hover);
    border-radius: var(--radius);
}

.btn { transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease; }
.btn:active { transform: scale(0.98); }

.btn-soft {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
}

.btn-soft:hover { background: var(--surface-2); }

/* ---- Статусные бейджи ------------------------------------------ */

.badge-soft {
    display: inline-block;
    font-weight: 500;
    font-size: 0.78em;
    padding: 0.25em 0.6em;
    border-radius: 999px;
    line-height: 1.4;
}

.badge-soft.ok     { background: var(--ok-soft);     color: var(--ok); }
.badge-soft.warn   { background: var(--warn-soft);   color: var(--warn); }
.badge-soft.danger { background: var(--danger-soft); color: var(--danger); }
.badge-soft.info   { background: var(--accent-soft); color: var(--accent); }

/* ---- Прогресс --------------------------------------------------- */

.progress {
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
}

.progress .progress-bar {
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Skeleton-лоадер --------------------------------------------- */

.skeleton-line {
    display: block;
    height: 0.9em;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2) 25%, #e9e9ec 45%, var(--surface-2) 65%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.mid   { width: 70%; }

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton-line { animation: none; }
}

/* ---- Сводка (карточка с моделью/ценой/балансом) ------------------ */

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.summary-card .summary-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.3rem 0;
    font-size: 0.95em;
}

.summary-card .summary-row + .summary-row { border-top: 1px solid var(--border); }

.summary-card .summary-value { font-weight: 500; }

/* ---- Разметка результатов: сегментированный контроль ------------- */

.segmented {
    display: table;
    width: 100%;
    table-layout: fixed;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.segmented .seg-item {
    display: table-cell;
    padding: 0.7rem 0.5rem;
    text-align: center;
    font-size: 0.9em;
    cursor: pointer;
    border-left: 1px solid var(--border);
    transition: background 0.15s ease;
    user-select: none;
}

.segmented .seg-item:first-child { border-left: none; }
.segmented .seg-item:hover { background: var(--surface-2); }

.segmented .active-tab {
    background: var(--accent);
    color: #fff;
}

/* ---- Элементы разметки (task result items) ------------------------ */

.item-wrapper {
    background: var(--surface);
    border-radius: var(--radius-lg);
    transition: box-shadow 0.2s ease;
}

.item-wrapper:hover { box-shadow: var(--shadow); }

.item-wrapper tr[data-status="approved"] .approve { background: var(--ok) !important; border-color: #fff !important; }
.item-wrapper tr[data-status="rejected"] .reject  { background: var(--danger) !important; }

.status-btn {
    transition: transform 0.1s ease, filter 0.15s ease;
}

.status-btn:hover { filter: brightness(0.95); }
.status-btn:active { transform: scale(0.94); }

/* ---- Модалки ------------------------------------------------------ */

.modal-backdrop-custom {
    background: rgb(24 24 27 / 0.45);
    backdrop-filter: blur(2px);
}

.modal-surface {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* ---- Таблицы (history) --------------------------------------------- */

.table-rows tr { border-bottom: 1px solid var(--border); }
.table-rows tbody tr:last-child { border-bottom: none; }
.table-rows tbody tr:hover { background: var(--surface-2); }

.domain-header {
    background: var(--text);
    color: #fff;
    font-size: 0.9em;
}

/* ---- Превью-список (preview.php) ------------------------------------ */

.link-line:hover { background: var(--accent-soft); }

.preview-img {
    height: 90px;
    width: auto;
    max-width: 150px;
    border-radius: var(--radius-sm);
}

/* ---- Бейдж схожести на изображении (share) -------------------------- */

.similarity-badge {
    background: var(--scrim);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.82em;
    text-align: center;
}

/* ---- Прочее --------------------------------------------------------- */

.text-muted-soft { color: var(--text-muted); }

.arrow-chain {
    color: #c4c4c8;
    font-family: monospace;
    font-weight: 300;
}

.empty-state {
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}