/* Единые стили для карточек товаров */

/* Базовые стили карточки */
.product-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* Контейнер изображения */
.product-image-container {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f7fafc;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

/* Статус товара */
.product-status {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-new {
    background: #10b981;
    color: white;
}

.status-used {
    background: #f59e0b;
    color: white;
}

/* Favorite button: нежные бело-серые тона */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    border: 1px solid #e6eef3;
    box-shadow: 0 1px 6px rgba(15,23,42,0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
    z-index: 20;
}

.favorite-btn i {
    color: #94a3b8; /* soft slate */
    font-size: 1.05rem;
    transition: color 0.18s ease, transform 0.18s ease;
}

.favorite-btn:hover {
    transform: translateY(-1px);
    border-color: #dfe7ec;
}

.favorite-btn:hover i {
    color: #6b7280;
    transform: scale(1.05);
}

.favorite-btn.is-active i,
.favorite-btn.active i,
.favorite-btn i.active {
    color: #475569; /* darker gray-blue for active */
    transform: scale(1.06);
}

/* Accessibility */
.favorite-btn:focus {
    outline: 3px solid rgba(99,102,241,0.12);
    outline-offset: 2px;
}

/* Action buttons (edit/delete) moved from inline styles to classes */
.product-actions { position: absolute; top: 8px; right: 8px; z-index: 10; display: flex; gap: 8px; }
.action-btn { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border: none; background: transparent; color: inherit; transition: all 0.2s ease; }
.action-btn.edit-btn { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; color: #fff !important; box-shadow: 0 2px 8px rgba(102,126,234,0.25); }
.action-btn.bump-btn { background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important; color: #fff !important; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.action-btn.bump-btn:disabled { background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%) !important; cursor: not-allowed; opacity: 0.6; }
.action-btn.bump-btn.bumping { animation: pulse 1s ease-in-out; }
.action-btn.delete-btn { background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%) !important; color: #fff !important; box-shadow: 0 2px 8px rgba(255,107,107,0.25); }
.action-btn.edit-btn i, .action-btn.bump-btn i, .action-btn.delete-btn i { color: #fff; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}


/* Контент карточки */
.product-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title-link {
    text-decoration: none;
    color: inherit;
}

.product-title-link:hover .product-title {
    color: #dc2626;
}

.product-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 0.75rem;
}

/* Suspicious product warning near price */
.suspicious-price-warning {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    color: #7c2d12; /* slightly darker amber */
    background: rgba(255,250,205,0.95); /* pale amber */
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    line-height: 1;
    vertical-align: middle;
    cursor: default;
    border: 1px solid rgba(148, 105, 30, 0.12);
}

.suspicious-text{font-weight:600;font-size:0.85rem;color:#7c2d12}

.suspicious-warning {
    margin-top: 6px;
    background: #fff7ed; /* pale warning background */
    border-left: 4px solid #f59e0b; /* orange accent */
    color: #92400e;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.product-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Мета-информация */
.product-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.product-category,
.product-condition {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.product-category i,
.product-condition i {
    font-size: 0.625rem;
}

/* Информация о продавце */
.seller-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.seller-name {
    font-size: 0.875rem;
    color: #4b5563;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Ensure seller name is left-aligned and does not get centered by flex stretch */
.seller-info .seller-name {
    flex: 1 1 auto; /* take remaining space on the left */
    text-align: left;
    margin-left: 0; /* ensure no extra offset */
    min-width: 0; /* allow truncation if needed */
}

/* Keep reputation badge pinned to the right */
.seller-info .reputation-badge {
    margin-left: auto; /* push badge to the far right */
    white-space: nowrap;
}

.seller-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
}

.seller-name:hover {
    color: #dc2626;
}

.seller-name i {
    font-size: 0.75rem;
}

.seller-reputation {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.reputation-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.reputation-positive, .reputation-badge.good, .reputation-badge.excellent, .reputation-badge.normal {
    background: #dcfce7;
    color: #16a34a;
}

.reputation-negative, .reputation-badge.bad {
    background: #fee2e2;
    color: #dc2626;
}

.reputation-neutral, .reputation-badge.neutral, .reputation-badge.new, .reputation-badge.low {
    background: #f3f4f6;
    color: #6b7280;
}

/* Compact badge used for 'Новичок' and other reputation labels */
/* reputation-badge removed: rely on .seller-reputation and .reputation-neutral/positive/negative */

/* Дата */
.product-date {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

/* Блок с датами размещения и бампа (для профиля) */
.product-dates {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.date-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: #6b7280;
}

.date-item i {
    font-size: 0.7rem;
    color: #9ca3af;
    width: 12px;
    flex-shrink: 0;
}

.date-item.bump-date i {
    color: #10b981;
}

.date-label {
    font-weight: 500;
    color: #4b5563;
}

.date-value {
    color: #6b7280;
    margin-left: auto;
}

/* Сетка товаров */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}

/* Компактный вариант карточки */
.product-card-compact {
    max-width: 250px;
}

.product-card-compact .product-image-container {
    height: 150px;
}

.product-card-compact .product-content {
    padding: 0.75rem;
}

.product-card-compact .product-title {
    font-size: 0.875rem;
}

.product-card-compact .product-price {
    font-size: 1rem;
}

/* Специальные стили для профиля */
.product-card-profile {
    position: relative;
}

.product-actions-profile {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.profile-actions-row {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    text-decoration: none;
    color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.action-btn:hover {
    transform: scale(1.05);
    /* leave background handling to specific button classes */
}

.action-btn.delete-btn { /* keep color for icon if not using white icon */ color: inherit; }
.action-btn.delete-btn:hover { filter: brightness(0.92); }
.action-btn.edit-btn:hover { filter: brightness(0.92); }

/* Состояние "нет товаров" */
.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.no-products i {
    font-size: 3rem;
    color: #e5e7eb;
    margin-bottom: 1rem;
    display: block;
}

.no-products-title,
.no-products h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.no-products p {
    color: #9ca3af;
}

/* Адаптивность */
/* Для больших экранов (десктопы) - принудительно 5 товаров в ряду */
@media (min-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 1.5rem;
    }
}

/* Для средних экранов (планшеты и небольшие десктопы) */
@media (max-width: 1199px) and (min-width: 769px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.2rem;
    }
}

@media (max-width: 768px) {
    .products-grid {
        /* Force two items per row on mobile/tablet to ensure consistent 2-column layout */
        grid-template-columns: repeat(2, 1fr);
        gap: 0.35rem;
    }
    
    .product-card {
        margin-bottom: 0;
    }
    
    /* Slightly shorter images on mobile to reduce card height */
    .product-image-container {
        height: 140px;
    }
    
    .product-content {
        padding: 0.75rem;
    }
    
    .seller-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .products-grid {
        /* Small phones: wider cards using minmax to reduce side gutters */
        grid-template-columns: repeat(2, minmax(200px, 1fr));
        gap: 0.25rem;
        max-width: 100% !important;
        padding: 0 6px !important;
        margin: 0 auto !important;
    }
    
    /* уменьшили высоту на 20px (было 140 -> теперь 120 previously, now -20 => 100) */
    .product-image-container {
        height: 100px;
    }
    
    .product-content {
        padding: 0.45rem;
    }
    
    .product-title {
        font-size: 0.9rem;
        line-height: 1.3;
    }
    
    .product-price {
        font-size: 1rem;
    }
}

/* Admin actions: centered at the bottom of the image */
.product-actions-profile.admin-actions {
    top: auto;
    right: 50%;
    left: 50%;
    transform: translateX(-50%);
    bottom: 12px;
    position: absolute;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    background: transparent;
}

.product-actions-profile.admin-actions .profile-actions-row {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.product-actions-profile.admin-actions .action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}

.product-actions-profile.admin-actions .action-btn i {
    font-size: 16px;
}

/* Reduce prominence on mobile */
@media (max-width: 480px) {
    .product-actions-profile.admin-actions .action-btn { width: 36px; height: 36px; }
}

@media (max-width: 360px) {
    .products-grid {
        /* Very small devices: still two columns (user preference) */
        grid-template-columns: repeat(2, 1fr);
    gap: 0.18rem;
    }
    
    .container {
        padding: 0 10px;
    }
}

/* High-priority overrides to prevent layout from being stretched by other stylesheets */
.products-grid {
    max-width: 1400px !important;
    margin: 0 auto 2rem !important;
    padding: 0 20px !important;
    box-sizing: border-box !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 1.5rem !important;
}

@media (max-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
        gap: 1.2rem !important;
    }
}

@media (max-width: 768px) {
    .products-grid {
        /* High-priority override: enforce two columns on mobile */
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.8rem !important;
    }
}

/* Enforce consistent image container height so very wide images can't expand the card */
.product-image-container {
    height: 220px !important;
    overflow: hidden !important;
}

.product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
}

/* Анимации загрузки */
.loading-indicator {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.loading-indicator i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

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

/* Сообщения об ошибках */
.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #dc2626;
    background: #fee2e2;
    border-radius: 8px;
}

.error-message i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Пустое состояние */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 4rem;
    color: #e5e7eb;
    margin-bottom: 1rem;
    display: block;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #4a5568;
}

/* Статус товара - левый верхний угол */
.product-status {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 5;
}

/* Предупреждение о дубликатах - справа под избранным или вместо него */
.duplicate-warning {
    position: absolute;
    right: 8px;
    top: 48px; /* под кнопкой избранного */
    z-index: 15;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 193, 7, 0.9);
    color: #856404;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 14px;
}

/* Если нет избранного, предупреждение занимает его место */
.product-image-container:not(:has(.favorite-btn)) .duplicate-warning {
    top: 8px;
}

.duplicate-warning .hint {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
}

.duplicate-warning:hover .hint {
    display: block;
}

/* Ensure the products grid stays centered and doesn't stretch full page width */
.products-grid {
    width: 100%;
    max-width: 1400px; /* match main container */
    margin: 0 auto 2rem; /* center grid */
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.2rem;
}

@media (min-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 0.8rem;
    }
}

/* Ensure images don't push layout in wide horizontal cards */
.product-image {
    max-width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image.landscape-center {
    max-width: 60%;
    margin: 0 auto;
    display: block;
}

/* Suspicious badge styling kept in CSS to avoid inline layout influence */
.suspicious-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(231,76,60,0.9);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0.95;
    z-index: 6;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Стикер предупреждения рядом с ценой для подозрительных объявлений */
.suspicious-price-warning {
    display: inline-block;
    margin-left: 8px;
    color: #b45309; /* amber-700 */
    background: rgba(255,250,205,0.9); /* pale amber */
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.85rem;
    line-height: 1;
    vertical-align: middle;
    cursor: default;
    border: 1px solid rgba(148, 105, 30, 0.12);
}

.suspicious-price-warning[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    transform: translateY(-6px);
    z-index: 30;
}
