/**
 * Hello Middleton - Market Sidebar Component
 * Premium editorial sidebar matching the Events widget design system
 *
 * Design: Mirrors events.css (se-*) structure with sm-* prefix
 * - Teal accent gradient (differentiates from events' amber)
 * - Price badges replace date stamps
 * - Variant badge colors for price types
 *
 * @requires tokens.css
 * @since 2.6.1
 */

/* ==========================================================================
   SIDEBAR MARKET WIDGET - Premium Editorial Design
   ========================================================================== */

.sidebar-market {
    background: var(--hm-bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.03);
}

/* --------------------------------------------------------------------------
   Header - Refined with teal accent line
   -------------------------------------------------------------------------- */

.sm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: linear-gradient(180deg, var(--hm-bg-elevated) 0%, var(--hm-bg-subtle) 100%);
    border-bottom: 1px solid var(--hm-border);
    position: relative;
}

/* Premium accent line — teal to differentiate from events' amber */
.sm-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        #0d9488 0%,
        #14b8a6 50%,
        #0d9488 100%
    );
}

.sm-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--hm-text);
    letter-spacing: -0.01em;
}

.sm-title span:first-child {
    font-size: 1.15rem;
    filter: saturate(0.9);
}

.sm-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: #0d9488;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-xl);
    background: rgba(13, 148, 136, 0.06);
    transition: all 0.2s ease;
}

.sm-link:hover {
    background: rgba(13, 148, 136, 0.12);
    color: #0f766e;
    transform: translateX(2px);
}

.sm-link::after {
    content: '\2192';
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.sm-link:hover::after {
    transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   Market List - Perfectly Aligned Stack
   -------------------------------------------------------------------------- */

.sm-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.sm-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    position: relative;
    transition: all 0.2s ease;
}

/* Subtle separator between items */
.sm-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--hm-border) 20%,
        var(--hm-border) 80%,
        transparent 100%
    );
}

.sm-item:last-child::after {
    display: none;
}

.sm-item:hover {
    background: linear-gradient(90deg,
        rgba(13, 148, 136, 0.04) 0%,
        rgba(13, 148, 136, 0.02) 100%
    );
}

/* --------------------------------------------------------------------------
   Photo Thumbnail (when listing has an image)
   -------------------------------------------------------------------------- */

.sm-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
}

.sm-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
}

.sm-thumb-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 800;
    color: #fff;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.sm-thumb-badge.sm-badge--fixed    { background: #16a34a; }
.sm-thumb-badge.sm-badge--free     { background: var(--hm-primary); }
.sm-thumb-badge.sm-badge--negotiable { background: #0d9488; }
.sm-thumb-badge.sm-badge--trade    { background: #0d9488; }
.sm-thumb-badge.sm-badge--curb     { background: #ea580c; }
.sm-thumb-badge.sm-badge--iso      { background: #2563eb; }

/* --------------------------------------------------------------------------
   Price Badge - Elegant Stamp Design (replaces date badge)
   -------------------------------------------------------------------------- */

.sm-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    color: white;
    flex-shrink: 0;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

/* Subtle shine effect */
.sm-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.12) 0%,
        transparent 100%
    );
    border-radius: 10px 10px 0 0;
}

.sm-item:hover .sm-badge {
    transform: scale(1.05) rotate(-2deg);
}

/* --- Badge Variants --- */

/* Fixed price (green) */
.sm-badge--fixed {
    background: linear-gradient(145deg, #16a34a 0%, #15803d 100%);
    box-shadow:
        0 2px 8px rgba(22, 163, 74, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sm-item:hover .sm-badge--fixed {
    box-shadow:
        0 4px 16px rgba(22, 163, 74, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Free (orange/primary) */
.sm-badge--free {
    background: linear-gradient(145deg, var(--hm-primary) 0%, var(--hm-primary-hover) 100%);
    box-shadow:
        0 2px 8px rgba(180, 83, 9, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sm-item:hover .sm-badge--free {
    box-shadow:
        0 4px 16px rgba(180, 83, 9, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Negotiable / OBO (teal) */
.sm-badge--negotiable {
    background: linear-gradient(145deg, #0d9488 0%, #0f766e 100%);
    box-shadow:
        0 2px 8px rgba(13, 148, 136, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sm-item:hover .sm-badge--negotiable {
    box-shadow:
        0 4px 16px rgba(13, 148, 136, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Trade (teal) */
.sm-badge--trade {
    background: linear-gradient(145deg, #0d9488 0%, #0f766e 100%);
    box-shadow:
        0 2px 8px rgba(13, 148, 136, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sm-item:hover .sm-badge--trade {
    box-shadow:
        0 4px 16px rgba(13, 148, 136, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ISO / Wanted (blue) */
.sm-badge--iso {
    background: linear-gradient(145deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow:
        0 2px 8px rgba(37, 99, 235, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sm-item:hover .sm-badge--iso {
    box-shadow:
        0 4px 16px rgba(37, 99, 235, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Curb Alert (orange + pulse) */
.sm-badge--curb {
    background: linear-gradient(145deg, #ea580c 0%, #c2410c 100%);
    box-shadow:
        0 2px 8px rgba(234, 88, 12, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    animation: sm-curb-pulse 2s ease-in-out infinite;
}

.sm-item:hover .sm-badge--curb {
    box-shadow:
        0 4px 16px rgba(234, 88, 12, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes sm-curb-pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
    50%      { box-shadow: 0 2px 16px rgba(234, 88, 12, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
}

/* Badge typography */
.sm-badge-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.sm-badge-value {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

/* When value is text-only (FREE, TRADE, CURB, ISO) — smaller to fit */
.sm-badge--free .sm-badge-value,
.sm-badge--trade .sm-badge-value,
.sm-badge--curb .sm-badge-value,
.sm-badge--iso .sm-badge-value {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   Listing Info - Refined Typography
   -------------------------------------------------------------------------- */

.sm-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.sm-name {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--hm-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.sm-item:hover .sm-name {
    color: #0d9488;
}

.sm-details {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--hm-text-muted);
    letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   Status Dots — on_hold (yellow) / pending_pickup (blue)
   -------------------------------------------------------------------------- */

.sm-item[data-status="on_hold"] .sm-name::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #eab308;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.sm-item[data-status="pending_pickup"] .sm-name::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3b82f6;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Footer — CTA Button
   -------------------------------------------------------------------------- */

.sm-footer {
    padding: 12px 20px 16px;
    text-align: center;
}

.sm-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: #0d9488;
    background: rgba(13, 148, 136, 0.08);
    border: 1px solid rgba(13, 148, 136, 0.15);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s ease;
}

.sm-cta:hover {
    background: rgba(13, 148, 136, 0.14);
    color: #0f766e;
    border-color: rgba(13, 148, 136, 0.25);
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */

.sm-empty {
    padding: 32px 20px;
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--hm-text-muted);
    font-style: italic;
}

.sm-empty a {
    color: #0d9488;
    text-decoration: none;
    font-weight: 600;
}

.sm-empty a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   RESPONSIVE - Tablet (max-width: 992px)
   ========================================================================== */

@media (max-width: 992px) {
    .sidebar-market {
        border-radius: 14px;
    }

    .sm-header {
        padding: 16px 18px;
    }

    .sm-item {
        padding: 12px 18px;
        gap: 12px;
    }

    .sm-badge {
        width: 48px;
        height: 48px;
    }

    .sm-badge-value {
        font-size: 1rem;
    }

    .sm-badge--free .sm-badge-value,
    .sm-badge--trade .sm-badge-value,
    .sm-badge--curb .sm-badge-value,
    .sm-badge--iso .sm-badge-value {
        font-size: 0.65rem;
    }
}

/* ==========================================================================
   RESPONSIVE - Mobile (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
    .sidebar-market {
        border-radius: var(--radius-md);
        margin: 0;
    }

    .sm-header {
        padding: 14px 16px;
    }

    .sm-title {
        font-size: 0.95rem;
    }

    .sm-link {
        padding: 5px 10px;
        font-size: 0.7rem;
    }

    .sm-item {
        padding: 12px 16px;
        gap: 12px;
    }

    .sm-item::after {
        left: 16px;
        right: 16px;
    }

    .sm-badge {
        width: 46px;
        height: 46px;
        border-radius: 8px;
    }

    .sm-badge-label {
        font-size: 0.55rem;
    }

    .sm-badge-value {
        font-size: 0.95rem;
    }

    .sm-badge--free .sm-badge-value,
    .sm-badge--trade .sm-badge-value,
    .sm-badge--curb .sm-badge-value,
    .sm-badge--iso .sm-badge-value {
        font-size: 0.6rem;
    }

    .sm-name {
        font-size: 0.825rem;
    }

    .sm-details {
        font-size: 0.65rem;
    }
}

/* ==========================================================================
   RESPONSIVE - Small Mobile (max-width: 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .sm-header {
        padding: 12px 14px;
    }

    .sm-title {
        font-size: 0.9rem;
        gap: 8px;
    }

    .sm-item {
        padding: 10px 14px;
        gap: 10px;
    }

    .sm-badge {
        width: 42px;
        height: 42px;
    }

    .sm-badge-value {
        font-size: 0.9rem;
    }

    .sm-badge--free .sm-badge-value,
    .sm-badge--trade .sm-badge-value,
    .sm-badge--curb .sm-badge-value,
    .sm-badge--iso .sm-badge-value {
        font-size: 0.55rem;
    }

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

/* ==========================================================================
   ACCESSIBILITY - REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .sm-item,
    .sm-badge,
    .sm-link,
    .sm-cta {
        transition: none;
    }

    .sm-item:hover .sm-badge {
        transform: none;
    }

    .sm-badge--curb {
        animation: none;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .sidebar-market {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .sm-header::before {
        display: none;
    }

    .sm-link,
    .sm-footer {
        display: none;
    }
}
