/**
 * DayZ Item Components - Shared Styling
 * Reusable CSS for item cards, badges, and displays across the website
 *
 * Include this file in any page that displays item data
 */

/* ============================================
   ITEM CARD - Clean iZurvive-inspired design
   ============================================ */

.item-card {
    background: rgba(22, 24, 32, 0.95);
    border: 1px solid rgba(55, 65, 81, 0.4);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.item-card-clickable {
    cursor: pointer;
}

.item-card-clickable:hover {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.item-card-clickable:active {
    transform: scale(0.98);
}

.item-card-image {
    position: relative;
    aspect-ratio: 4/3;
    background: linear-gradient(180deg, rgba(30, 32, 42, 0.8) 0%, rgba(20, 22, 30, 0.9) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid rgba(55, 65, 81, 0.3);
}

.item-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    transition: transform 0.2s ease;
}

.item-card-clickable:hover .item-card-image img {
    transform: scale(1.03);
}

/* Legacy slot badge - still used in search results */
.item-card-slot-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
}

/* ============================================
   SLOT SIZE DISPLAY (Grid + Text)
   iZurvive-style inventory visualization
   ============================================ */

/* ============================================
   SLOT SIZE DISPLAY - Clean grid visualization
   ============================================ */

.item-card-slots {
    background: rgba(17, 19, 25, 0.95);
    padding: 8px 12px;
    border-top: 1px solid rgba(55, 65, 81, 0.2);
}

.item-slot-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Mini grid visualization */
.slot-mini-grid {
    display: grid;
    gap: 2px;
    flex-shrink: 0;
    padding: 3px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.slot-grid-cell {
    width: 7px;
    height: 7px;
    background: rgba(99, 102, 241, 0.6);
    border: 1px solid rgba(99, 102, 241, 0.8);
    border-radius: 1px;
}

/* Text label next to grid */
.slot-size-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.slot-dimensions {
    font-family: 'SF Mono', 'Roboto Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e5e7eb;
    letter-spacing: 0.3px;
}

.slot-count {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .item-card-slots {
        padding: 6px 10px;
    }

    .slot-mini-grid {
        gap: 1px;
        padding: 2px;
    }

    .slot-grid-cell {
        width: 6px;
        height: 6px;
    }

    .slot-dimensions {
        font-size: 0.8rem;
    }

    .slot-count {
        font-size: 0.65rem;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .item-slot-display {
        gap: 8px;
    }

    .slot-grid-cell {
        width: 5px;
        height: 5px;
    }
}

.item-card-info {
    padding: 10px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(17, 19, 25, 0.6);
}

.item-card-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: #f3f4f6;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.item-card-category {
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Item Card Sizes */
.item-card-sm .item-card-info {
    padding: 8px;
}

.item-card-sm .item-card-name {
    font-size: 0.8rem;
}

.item-card-lg .item-card-info {
    padding: 16px;
}

.item-card-lg .item-card-name {
    font-size: 1rem;
}

/* ============================================
   SLOT SIZE BADGE
   ============================================ */

.slot-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background: rgba(147, 51, 234, 0.3);
    border: 1px solid rgba(147, 51, 234, 0.5);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #a855f7;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.slot-badge-sm {
    padding: 2px 6px;
    font-size: 0.65rem;
}

.slot-badge-lg {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ============================================
   SLOT GRID VISUALIZATION
   ============================================ */

.slot-grid {
    display: inline-grid;
    gap: 2px;
}

.slot-cell {
    background: rgba(147, 51, 234, 0.2);
    border: 1px solid rgba(147, 51, 234, 0.4);
    border-radius: 2px;
}

.slot-cell-filled {
    background: rgba(147, 51, 234, 0.5);
}

.slot-grid-label {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 4px;
    text-align: center;
}

/* ============================================
   CATEGORY PILLS
   ============================================ */

.category-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: rgba(55, 65, 81, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 20px;
    color: #d1d5db;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-pill:hover {
    background: rgba(147, 51, 234, 0.2);
    border-color: rgba(147, 51, 234, 0.4);
    color: #fff;
}

.category-pill-active {
    background: rgba(147, 51, 234, 0.3);
    border-color: rgba(147, 51, 234, 0.6);
    color: #a855f7;
}

.category-pill-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

/* ============================================
   USAGE BADGES
   ============================================ */

.usage-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    color: #60a5fa;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Usage-specific colors */
.usage-badge[data-usage="military"] {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.usage-badge[data-usage="police"] {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.usage-badge[data-usage="hunting"] {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.3);
    color: #facc15;
}

.usage-badge[data-usage="farm"],
.usage-badge[data-usage="village"] {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}

.usage-badge[data-usage="medic"],
.usage-badge[data-usage="firefighter"] {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ============================================
   TIER BADGES
   ============================================ */

.tier-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: rgba(107, 114, 128, 0.3);
    border: 1px solid rgba(107, 114, 128, 0.4);
    border-radius: 12px;
    color: #d1d5db;
    font-size: 0.75rem;
    font-weight: 600;
}

.tier-badge.tier-1 {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.tier-badge.tier-2 {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.tier-badge.tier-3 {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.3);
    color: #facc15;
}

.tier-badge.tier-4 {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ============================================
   ITEM IMAGE WITH FALLBACK
   ============================================ */

.item-image {
    position: relative;
    background: rgba(20, 20, 30, 0.5);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.item-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    gap: 8px;
}

.item-image-placeholder i {
    font-size: 2rem;
    opacity: 0.5;
}

/* Default fallback image styling */
.item-card-image img[src^="data:"],
.item-image img[src^="data:"],
.modal-item-image img[src^="data:"],
.search-result-image[src^="data:"] {
    opacity: 0.4;
    padding: 20%;
}

/* ============================================
   ITEM GRID LAYOUTS
   ============================================ */

.item-grid {
    display: grid;
    gap: 16px;
}

/* Responsive grid - 2 columns on mobile, scales up */
.item-grid-responsive {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .item-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .item-grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1280px) {
    .item-grid-responsive {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Fixed column grids */
.item-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.item-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.item-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   CATEGORY TABS (Wrap by default)
   ============================================ */

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px;
}

/* Optional: horizontal scroll variant */
.category-tabs-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(147, 51, 234, 0.3) transparent;
    -webkit-overflow-scrolling: touch;
}

.category-tabs-scroll::-webkit-scrollbar {
    height: 6px;
}

.category-tabs-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.category-tabs-scroll::-webkit-scrollbar-thumb {
    background: rgba(147, 51, 234, 0.3);
    border-radius: 3px;
}

/* ============================================
   SEARCH INPUT
   ============================================ */

.item-search {
    display: flex;
    align-items: center;
    background: rgba(30, 30, 40, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 10px;
    padding: 0 16px;
    transition: all 0.2s ease;
}

.item-search:focus-within {
    border-color: rgba(147, 51, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.item-search i {
    color: #9ca3af;
    margin-right: 12px;
}

.item-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 12px 0;
    outline: none;
}

.item-search input::placeholder {
    color: #6b7280;
}

/* ============================================
   LOADING STATES
   ============================================ */

.item-card-skeleton {
    background: rgba(30, 30, 40, 0.8);
    border: 1px solid rgba(75, 85, 99, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

.skeleton-image {
    aspect-ratio: 1;
    background: linear-gradient(90deg,
        rgba(55, 65, 81, 0.5) 25%,
        rgba(75, 85, 99, 0.5) 50%,
        rgba(55, 65, 81, 0.5) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg,
        rgba(55, 65, 81, 0.5) 25%,
        rgba(75, 85, 99, 0.5) 50%,
        rgba(55, 65, 81, 0.5) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s infinite;
    border-radius: 4px;
    margin: 12px;
}

.skeleton-text-sm {
    height: 12px;
    width: 60%;
}

@keyframes skeleton-pulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-muted {
    color: #6b7280;
}

.item-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: #9ca3af;
}

.item-empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.item-empty-state p {
    font-size: 1rem;
    margin: 0;
}

/* ============================================
   RESPONSIVE TOUCH TARGETS
   ============================================ */

@media (max-width: 640px) {
    .item-card {
        /* Ensure minimum touch target size */
        min-height: 44px;
    }

    .category-pill {
        padding: 10px 16px;
        /* Minimum touch target */
        min-height: 44px;
    }

    .item-search {
        padding: 0 12px;
    }

    .item-search input {
        padding: 14px 0;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}
