/* ═══════════════════════════════════════════════════════════════════════════
   PRODUCT CARD V3.2 ULTIMATE - "Ingredion Style" Overlap Logo
   TradeFlow Master Specification - APPROVED_FOR_PRODUCTION
   ═══════════════════════════════════════════════════════════════════════════ */

/* === CRITICAL DIMENSIONS (Updated for UI Improvements) === */
:root {
    /* Card Structure */
    --card-header-height: 96px;
    /* h-24 */
    --logo-size: 112px;
    /* [UPDATED] 2x width/height from 56px */
    --logo-top: 48px;
    /* [UPDATED] Adjusted for larger logo overlap */
    --logo-left: 20px;
    /* left-5 */
    --body-padding-top: 72px;
    /* [UPDATED] Clears larger logo */
    --card-radius: 16px;
    /* rounded-2xl */

    /* Badge Positions */
    --badge-inset: 12px;
    /* top-3, left-3, right-3 */

    /* Theme Colors (Primary) */
    --amber-accent: #D97706;
}

/* === CATEGORY THEME COLORS (From Ultimate Spec) === */
/* Products */
.theme-polymer {
    --theme-color: #2563eb;
}

/* Blue-600 */
.theme-chemicals {
    --theme-color: #14b8a6;
}

/* Teal-500 */
.theme-cosmetics {
    --theme-color: #fb7185;
}

/* Rose-400 */
.theme-paints {
    --theme-color: #c026d3;
}

/* Fuchsia-600 */
.theme-technical {
    --theme-color: #475569;
}

/* Slate-600 */
.theme-packaging {
    --theme-color: #b45309;
}

/* Amber-700 */
.theme-scrap {
    --theme-color: #047857;
}

/* Emerald-700 */

/* Machinery */
.theme-mach-primary {
    --theme-color: #ea580c;
}

/* Orange-600 */
.theme-mach-secondary {
    --theme-color: #4f46e5;
}

/* Indigo-600 */
.theme-mach-recycle {
    --theme-color: #16a34a;
}

/* Green-600 */
.theme-mach-molds {
    --theme-color: #71717a;
}

/* Zinc-500 */
.theme-mach-peripheral {
    --theme-color: #0891b2;
}

/* Cyan-600 */
.theme-mach-packing {
    --theme-color: #ca8a04;
}

/* Yellow-600 */
.theme-mach-test {
    --theme-color: #7c3aed;
}

/* Violet-600 */
.theme-mach-auto {
    --theme-color: #0ea5e9;
}

/* Sky-500 */

/* Services & Logistics */
.theme-services {
    --theme-color: #1e3a5f;
}

/* Navy-800 */
.theme-logistics {
    --theme-color: #92400e;
}

/* Amber-800 */

/* === CARD WRAPPER === */
.product-card-v3 {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card-v3:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* === HEADER ZONE (96px - AI Background) === */
.card-header-v3 {
    position: relative;
    height: var(--card-header-height);
    width: 100%;
    background: #f1f5f9;
    overflow: hidden;
}

.card-header-v3 .bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card-v3:hover .card-header-v3 .bg-image {
    transform: scale(1.1);
}

/* Readability Overlay - Gradient from bottom */
.card-header-v3 .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.2), transparent);
    opacity: 0.8;
}

/* Category Label (Top Left) */
.card-header-v3 .category-label {
    position: absolute;
    top: var(--badge-inset);
    left: var(--badge-inset);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--theme-color, #475569);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Status Badge (Top Right) - AKTİF */
.card-header-v3 .status-badge {
    position: absolute;
    top: var(--badge-inset);
    right: 48px;
    /* Moved left to make room for Fav button if needed, but Fav is absolute too */
    right: var(--badge-inset);
    /* Keep aligned */
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 99px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card-header-v3 .status-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

.card-header-v3 .status-badge .text {
    font-size: 10px;
    font-weight: 700;
    color: #047857;
}

/* [NEW] Header Flag (Under Status/Fav) */
.card-header-v3 .header-flag {
    position: absolute;
    top: 52px;
    /* Just under the status badge/fav button area */
    right: var(--badge-inset);
    width: 36px;
    height: 24px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    object-fit: cover;
    z-index: 20;
}

/* === DATE BADGES (YENİ / DOLMAK ÜZERE) === */
.card-header-v3 .date-badge {
    position: absolute;
    bottom: var(--badge-inset);
    right: var(--badge-inset);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: badge-glow 2s ease-in-out infinite;
}

/* YENİ Badge - Neon Green (<36h since creation) */
.card-header-v3 .badge-new {
    background: linear-gradient(135deg, #22C55E 0%, #16A34A 100%);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.5);
}

@keyframes badge-glow {

    0%,
    100% {
        box-shadow: 0 2px 12px rgba(34, 197, 94, 0.5);
    }

    50% {
        box-shadow: 0 2px 20px rgba(34, 197, 94, 0.8);
    }
}

/* DOLMAK ÜZERE Badge - Orange-Red (<36h until deadline) */
.card-header-v3 .badge-ending {
    background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(249, 115, 22, 0.5);
    animation: badge-glow-orange 2s ease-in-out infinite;
}

@keyframes badge-glow-orange {

    0%,
    100% {
        box-shadow: 0 2px 12px rgba(249, 115, 22, 0.5);
    }

    50% {
        box-shadow: 0 2px 20px rgba(249, 115, 22, 0.8);
    }
}

/* === LOGO ZONE (Golden Ratio Overlap) === */
.card-logo-v3 {
    position: absolute;
    top: var(--logo-top);
    left: var(--logo-left);
    z-index: 10;
    width: var(--logo-size);
    height: var(--logo-size);
    border-radius: 12px;
    background: #ffffff;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-logo-v3 img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Placeholder when no logo */
.card-logo-v3.placeholder {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #94a3b8;
    font-size: 1.25rem;
}

/* === CONTENT ZONE === */
.card-content-v3 {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: var(--body-padding-top) 20px 20px 20px;
}

.card-content-v3 .title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.product-card-v3:hover .card-content-v3 .title {
    color: var(--amber-accent);
}

.card-content-v3 .subtitle {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 4px;
}

/* Attributes Row */
.card-content-v3 .attributes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 16px;
}

.card-content-v3 .attr-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    font-size: 0.75rem;
    font-weight: 500;
    color: #475569;
}

.card-content-v3 .attr-badge i {
    margin-right: 4px;
    font-size: 0.65rem;
    color: #94a3b8;
}

/* Divider */
.card-content-v3 .divider {
    width: 100%;
    height: 1px;
    background: #f1f5f9;
    margin: auto 0;
}

/* Footer Row */
.card-footer-v3 {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 16px;
}

.card-footer-v3 .price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--amber-accent);
}

.card-footer-v3 .price .currency {
    font-size: 0.9rem;
    font-weight: 600;
}

.card-footer-v3 .price .unit {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: 2px;
}

/* Dates Display */
.card-footer-v3 .dates {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.card-footer-v3 .date-text {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 500;
}

.card-footer-v3 .date-text.deadline {
    color: #f97316;
}

/* Seller Info */
.card-footer-v3 .seller-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #64748b;
}

.card-footer-v3 .seller-info .verified {
    color: #3b82f6;
}

/* === RESPONSIVE ADJUSTMENTS === */
@media (max-width: 768px) {
    :root {
        --card-header-height: 80px;
        --logo-size: 48px;
        --logo-top: 52px;
        --body-padding-top: 32px;
    }

    .product-card-v3 {
        border-radius: 12px;
    }

    .card-content-v3 {
        padding: var(--body-padding-top) 16px 16px 16px;
    }

    .card-content-v3 .title {
        font-size: 1rem;
    }

    .card-footer-v3 .price {
        font-size: 1.1rem;
    }
}

/* === GRID LAYOUT === */
.product-grid-v3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

@media (max-width: 768px) {
    .product-grid-v3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Two-column grid mode */
.product-grid-v3.grid-view {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.product-grid-v3.grid-view .product-card-v3 {
    --card-header-height: 70px;
    --logo-size: 44px;
    --logo-top: 46px;
    --logo-left: 12px;
    --body-padding-top: 28px;
}

.product-grid-v3.grid-view .card-content-v3 {
    padding: var(--body-padding-top) 12px 12px 12px;
}

.product-grid-v3.grid-view .card-content-v3 .title {
    font-size: 0.9rem;
}

.product-grid-v3.grid-view .card-footer-v3 .price {
    font-size: 1rem;
}

.product-grid-v3.grid-view .card-content-v3 .attributes {
    display: none;
}

.product-grid-v3.grid-view .card-footer-v3 .dates {
    display: none;
}

/* [NEW] Desktop Optimizations for Icons */
@media (min-width: 1024px) {
    .tf-info-box {
        max-width: 80% !important;
        /* Shrink width by ~20-30% on large screens */
        margin: 0 auto;
        /* Center alignment */
    }

    .tf-location-customs-row {
        justify-content: center;
        /* Center the icons */
    }
}

/* === CARD SECTION ALIGNMENT (Side-by-side consistency) === */
/* Title: fixed 2-line height so subtitle always starts at same Y */
.product-card-v3 .card-content-v3 .title {
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Subtitle: allow up to 2 lines, truncate with ... if exceeds */
.product-card-v3 .card-content-v3 .subtitle {
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Firm/seller info row: fixed height */
.product-card-v3 .card-content-v3 .firm-info-row {
   /* min-height: 52px; */
}

/* Upper tags row (stock, packaging, machine year): fixed height */
.product-card-v3 .card-content-v3 > div:has(> .attr-badge):not(.tf-location-customs-row):not(.content-badges) {
    min-height: 34px;
    align-items: center;
}

/* Location/customs row: fixed height */
.product-card-v3 .tf-location-customs-row {
    min-height: 34px;
    display: flex;
    align-items: center;
}

/* Dates row: push to card bottom (above divider) */
.product-card-v3 .card-content-v3 .tf-dates-row {
    margin-top: auto;
    min-height: 22px;
}

/* Divider before footer */
.product-card-v3 .card-content-v3 > .divider {
    margin-top: 0;
}

/* Footer: always at card bottom with consistent height */
.product-card-v3 .card-footer-v3 {
    min-height: 44px;
}

/* === GRID VIEW CONSISTENCY OVERRIDES === */
/* Added to ensure cards maintain consistent heights across different content lengths in grid view */
.feed-grid.grid-view .product-card-v3 .card-content-v3 .title {
    min-height: 48px;
}

.feed-grid.grid-view .product-card-v3 .card-content-v3 .subtitle {
    min-height: 44px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ensure attributes are visible and consistent in grid view */
.feed-grid.grid-view .product-card-v3 .card-content-v3 .attributes {
    display: flex !important;
    min-height: 32px;
    align-items: center;
}

/* Ensure location/customs row has consistent height */
.feed-grid.grid-view .product-card-v3 .tf-location-customs-row {
    min-height: 32px;
}

/* Ensure dates are visible and consistent in grid view */
.feed-grid.grid-view .product-card-v3 .card-footer-v3 .dates {
    display: flex !important;
    flex-direction: column;
    min-height: 20px;
    justify-content: flex-end;
}