/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   📜 ІСТОРІЯ СКАНУВАННЯ - СТИЛІ
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.main-content {
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 100px 24px 40px 24px; /* ⬅️ БУЛО 40px, СТАЛО 100px зверху */
}

.history-section {
    width: 100%;
    max-width: 800px;
}

/* ✅ ДОДАЙ ЦЕ! Компенсація для sidebar */
body.with-sidebar .history-section {
    transform: translateX(-25px);
}

/* ━━━ Заголовок ━━━ */
.history-header {
    text-align: center;
    margin-bottom: 40px;
}

.history-header h1 {
    font-size: 36px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 16px;
    color: #6b6b6b;
    line-height: 1.4;
}

/* ━━━ Список продуктів ━━━ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ━━━ Один продукт (товста посилання) ━━━ */
.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
}

.history-item:hover {
    border-color: #2d2d2d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ━━━ Мініатюра фото ━━━ */
.item-photo {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    flex-shrink: 0;
}

.item-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ━━━ Інформація про продукт ━━━ */
.item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-name {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.3;
}

.item-date {
    font-size: 14px;
    color: #6b6b6b;
}

/* ━━━ Кнопка видалення ━━━ */
.delete-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn span {
    font-size: 20px;
}

.delete-btn:hover {
    background: #fee2e2;
    transform: scale(1.1);
}

.delete-btn:active {
    transform: scale(0.95);
}

/* ━━━ Loader (підгрузка) ━━━ */
.history-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: #6b6b6b;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #2d2d2d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ━━━ Пуста історія ━━━ */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 18px;
    color: #6b6b6b;
    margin-bottom: 24px;
}

/* ━━━ Responsive ━━━ */
@media (max-width: 768px) {
    .history-header h1 {
        font-size: 28px;
    }

    .history-item {
        padding: 12px;
        gap: 12px;
    }

    .item-photo {
        width: 50px;
        height: 50px;
    }

    .item-name {
        font-size: 15px;
    }

    .item-date {
        font-size: 13px;
    }

    .delete-btn {
        width: 36px;
        height: 36px;
    }
}


/* ━━━ Необхідність авторизації ━━━ */
.auth-required {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 12px;
    padding: 32px;
    margin: 40px auto;
    text-align: center;
    max-width: 500px;
}

.auth-required-text {
    color: #1e40af;
    font-size: 16px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.auth-required-link {
    display: inline-block;
    padding: 12px 32px;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s;
}

.auth-required-link:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}


/* ━━━ Кнопки дій (видалення) ━━━ */
.item-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.delete-buttons {
    display: none;
    gap: 8px;
    animation: slideIn 0.2s ease;
}

.delete-buttons.show {
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.cancel-btn {
    background: #f3f4f6;
    color: #1a1a1a;
}

.cancel-btn:hover {
    background: #e5e7eb;
}

.confirm-btn {
    background: #ef4444;
    color: white;
}

.confirm-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ━━━ Заглушка "Нет фото" (как в Result) ━━━ */
.history-no-image {
    width: 100%;
    height: 100%;
    background: #9ca3af; /* Тот же серый цвет */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 30px; /* Размер вопроса под иконку 60px */
    font-weight: 500;
}

/* ==============================================
   МОБИЛЬНАЯ АДАПТАЦИЯ (HISTORY PAGE)
   ============================================== */
@media (max-width: 768px) {

    /* 1. КОНТЕЙНЕР И ОТСТУПЫ */
    .main-content {
        /* Сверху 80px (чтобы не прилипало), Снизу 100px (под нижнее меню) */
        padding: 80px 16px 100px 16px !important;
        justify-content: flex-start; /* Чтобы контент шел сверху, а не по центру */
    }

    /* 2. УБИРАЕМ СДВИГ БОКОВОГО МЕНЮ */
    body.with-sidebar .history-section {
        transform: none !important; /* ✅ Отменяем сдвиг, ставим ровно по центру */
        margin: 0 auto;
        width: 100%;
    }

    /* 3. ЗАГОЛОВКИ */
    .history-header {
        margin-bottom: 25px; /* Чуть меньше отступ */
    }

    .history-header h1 {
        font-size: 28px; /* Уменьшаем заголовок (было 36px) */
        line-height: 1.2;
    }

    .subtitle {
        font-size: 14px; /* Уменьшаем подзаголовок */
        padding: 0 10px;
    }

    /* 4. СПИСОК И ЭЛЕМЕНТЫ */
    .history-item {
        padding: 12px;
        gap: 12px;
        border-radius: 10px; /* Чуть аккуратнее углы */
    }

    .item-photo {
        width: 50px;       /* Картинка чуть меньше */
        height: 50px;
    }

    .history-no-image {
        font-size: 24px;   /* Знак вопроса подгоняем под размер 50px */
    }

    .item-name {
        font-size: 14px;   /* Название чуть компактнее */
        line-height: 1.3;
    }

    .item-date {
        font-size: 12px;
    }

    /* 5. КНОПКИ УДАЛЕНИЯ (Fixed) */
    .delete-btn {
        width: 36px;
        height: 36px;
    }

    .delete-buttons {
        /* ✅ Возвращаем В РЯД (было column) */
        flex-direction: row !important;
        align-items: center;
        gap: 6px; /* Небольшой зазор между кнопками */

        /* Позиционируем справа по центру карточки */
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%); /* Ровно по центру высоты */

        background: white; /* Белый фон перекроет текст под кнопками */
        padding: 4px 6px;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1); /* Аккуратная тень */
        z-index: 10;
        width: auto; /* Ширина по содержимому */
    }

    /* Уменьшаем текст и отступы кнопок, чтобы влезли */
    .action-btn {
        padding: 6px 10px !important;
        font-size: 11px !important; /* Шрифт чуть меньше */
        white-space: nowrap;        /* Текст не переносится */
        height: auto;
    }

    /* Если кнопки в столбик, то фон карточки не должен перекрывать их */
    .history-item {
        overflow: visible;
    }
}

