/* ============================================
   BASE CARD STYLES
   Core plate card layout, grid, skeleton loading,
   plate images, details, and pricing
   ============================================ */

/* Apply font to all card elements */
.plate-card,
.plate-card * {
    font-family: var(--font-card);
}

/* ---- Skeleton Loading Placeholders ---- */
.skeleton-card {
    background-color: #f5f5f5;
    border-radius: 18px;
    overflow: hidden;
    height: 325px;
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-plate {
    height: 180px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-details {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    height: 20px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-line.short {
    width: 60%;
    height: 16px;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

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

/* ---- Base Plate Card ---- */
.plate-card {
    background: linear-gradient(145deg, #ffffff 0%, #fafafa 100%);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 265px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.03);
    box-sizing: border-box;
    position: relative;
    height: 325px;
    display: flex;
    flex-direction: column;
    animation: cardFadeIn 0.4s ease-out;
    will-change: auto;
    contain: layout style paint;
    transform: translateZ(0);
}

.plate-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 8px 20px rgba(139, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.04);
    border-color: rgba(139, 0, 0, 0.08);
    will-change: transform;
}

.plate-card:not(:hover) {
    will-change: auto;
}

/* Remove focus outline from cards */
.plate-card:focus,
.plate-card:focus-visible {
    outline: none;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Plates Grid ---- */
.plates-grid {
    display: grid;
    grid-template-columns: repeat(4, 265px);
    gap: 25px;
    width: 100%;
    justify-content: center;
}

/* ---- Sponsored Plates Carousel ---- */
.sponsored-plates {
    display: flex;
    overflow-x: auto;
    gap: 25px;
    padding: 10px 15px 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    position: relative;
    scroll-snap-type: none !important;
    contain: layout;
    transform: translateZ(0);
}

.sponsored-plates .plate-card {
    scroll-snap-align: none !important;
    scroll-snap-stop: none !important;
    flex: 0 0 auto;
}

/* ---- Plate Number Container ---- */
.plate-number-container {
    height: 200px;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #f8f8f8 0%, #f0f0f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 -1px 3px rgba(0,0,0,0.03);
}

/* Subtle corner accent */
.plate-number-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* ---- Plate Image ---- */
.plate-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shine effect on hover */
.plate-image-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.plate-card:hover .plate-image-wrapper::after {
    opacity: 1;
    animation: plateShine 0.6s ease-out;
}

.plate-card.random-shine .plate-image-wrapper::after {
    opacity: 1;
    animation: plateShine 0.8s ease-out;
}

@keyframes plateShine {
    from { left: -100%; }
    to { left: 150%; }
}

/* Shimmer while image loads */
.plate-image-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 50%;
    background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.3) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
    border-radius: 8px;
    z-index: 1;
    pointer-events: none;
}

.plate-image-wrapper:has(.plate-image.loaded)::before {
    display: none;
}

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

/* Placeholder image (empty plate background) */
.plate-placeholder {
    max-width: 85%;
    max-height: 85%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Plate image from Supabase storage */
.plate-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 85%;
    max-height: 85%;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.plate-image.lazy-plate:not(.loaded) {
    opacity: 0;
}

.plate-image.loaded {
    opacity: 1;
}

/* ---- Plate Number ---- */
.plate-number {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 2px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    text-align: center !important;
    direction: ltr;
    unicode-bidi: plaintext;
    display: block;
    position: relative;
    z-index: 1;
    margin: 0 auto;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    transform: translate(7px, 8px);
}

/* ---- Plate Details ---- */
.plate-details {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, rgba(255,255,255,0.8), rgba(255,255,255,1));
    border-top: 1px solid rgba(0,0,0,0.03);
    position: relative;
    min-height: 120px;
    justify-content: space-between;
}

.plate-category {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 6px;
    font-weight: 600;
    opacity: 0.8;
}

.plate-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.plate-price {
    font-weight: 700;
    font-size: 18px;
    color: #8B0000;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* Highest Offer styling */
.plate-price.highest-offer {
    color: #000;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0;
}

.plate-price.highest-offer .highest-offer-text {
    color: #000;
}

/* ---- Loading Animation ---- */
@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

.loading .plate-card {
    pointer-events: none;
}

.loading .plate-number-container {
    background-color: var(--card-gray-200);
    background-image: linear-gradient(
        to right,
        var(--card-gray-200) 0%,
        var(--card-gray-100) 20%,
        var(--card-gray-200) 40%,
        var(--card-gray-200) 100%
    );
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
}

.loading .plate-category,
.loading .plate-price-row {
    background-color: var(--card-gray-200);
    border-radius: 4px;
    height: 14px;
    margin-bottom: 8px;
    background-image: linear-gradient(
        to right,
        var(--card-gray-200) 0%,
        var(--card-gray-100) 20%,
        var(--card-gray-200) 40%,
        var(--card-gray-200) 100%
    );
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
}

/* ---- Fade-in Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.15s ease forwards;
}

.plates-grid .plate-card {
    animation-delay: 0s;
    transition: opacity 0.15s ease;
}

.plate-card.fade-in {
    animation: fadeInUp 0.1s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---- Dashboard Plate Actions ---- */
.plate-actions-dashboard {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.plate-actions-dashboard button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.edit-btn {
    background-color: #3182ce;
    color: white;
}

.edit-btn:hover {
    background-color: #2c5282;
    transform: translateY(-1px);
}

.delete-btn {
    background-color: #e53e3e;
    color: white;
}

.delete-btn:hover {
    background-color: #c53030;
    transform: translateY(-1px);
}

body:not(.dashboard-page) .plate-actions-dashboard {
    display: none;
}

/* ---- RTL Support for Cards ---- */
body.rtl .plate-details,
body.rtl .plate-category {
    direction: rtl;
    text-align: right;
}

body.rtl .plate-price-row {
    direction: ltr;
    text-align: left;
}

body.rtl .plate-price {
    direction: ltr;
    text-align: left;
}

body.rtl .plate-number-container,
body.rtl .plate-number {
    direction: ltr;
}

body.rtl .sponsored-label {
    right: auto;
    left: 8px;
}

/* Ensure plate number stays centered in all languages */
.plate-number {
    text-align: center !important;
    direction: ltr;
    unicode-bidi: plaintext;
    display: block;
}

body.rtl .plate-number {
    text-align: center !important;
    direction: ltr;
}

body.rtl .plate-number-container {
    text-align: center;
}
