/* ==========================================================================
   Listing Detail Panel (Offcanvas)
   ========================================================================== */

/* Panel size */
.listing-detail-panel {
    border-left: none;
    background: var(--listing-bg-start);
    box-shadow: -8px 0 30px rgba(0,0,0,.08);
}
.dark-style .listing-detail-panel {
    box-shadow: -8px 0 30px rgba(0,0,0,.25);
}
.listing-detail-panel .offcanvas-header {
    border-bottom: 1px solid var(--listing-border);
    padding: 1rem 1.5rem;
    gap: .75rem;
    flex-wrap: wrap;
    background: var(--listing-surface);
}
.listing-detail-panel .offcanvas-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.08) transparent;
}
.listing-detail-panel .offcanvas-body::-webkit-scrollbar { width: 5px; }
.listing-detail-panel .offcanvas-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.08); border-radius: 3px; }
.dark-style .listing-detail-panel .offcanvas-body { scrollbar-color: rgba(255,255,255,.08) transparent; }
.dark-style .listing-detail-panel .offcanvas-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); }

/* Currency Note */
.ld-currency-note {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--listing-text);
    letter-spacing: .01em;
    padding: 0 .25rem .5rem;
}

/* Header */
.ld-header-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 360px;
    letter-spacing: -.01em;
}
.dark-style .ld-header-title { color: #e2e8f0; }

.ld-header-left {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-width: 0;
    flex: 1;
}
.ld-header-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.ld-status-badge {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .2rem .55rem;
    border-radius: 50rem;
    white-space: nowrap;
}
.ld-status--active { background: rgba(34,197,94,.1); color: #16a34a; }
.ld-status--inactive { background: rgba(239,68,68,.1); color: #dc2626; }
.ld-status--oos { background: rgba(245,158,11,.1); color: #d97706; }
.dark-style .ld-status--active { background: rgba(34,197,94,.15); color: #4ade80; }
.dark-style .ld-status--inactive { background: rgba(239,68,68,.15); color: #f87171; }
.dark-style .ld-status--oos { background: rgba(245,158,11,.15); color: #fbbf24; }

.ld-header-flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
}

.ld-refresh-btn,
.ld-dots-btn {
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    padding: .35rem;
    border-radius: .375rem;
    font-size: 1.05rem;
    line-height: 1;
    transition: background .12s, color .12s;
}
.ld-refresh-btn:hover, .ld-dots-btn:hover {
    background: var(--listing-accent-soft, rgba(115,103,240,.08));
    color: var(--listing-accent);
}
.dark-style .ld-refresh-btn,
.dark-style .ld-dots-btn { color: #94a3b8; }
.dark-style .ld-refresh-btn:hover,
.dark-style .ld-dots-btn:hover { background: rgba(115,103,240,.1); color: var(--listing-accent); }
.ld-dots-btn::after { display: none !important; }

/* Date filter pills */
.ld-date-filters {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
}
.ld-date-btn {
    border: 1px solid var(--listing-border);
    background: transparent;
    color: #64748b;
    font-size: .7rem;
    font-weight: 500;
    padding: .15rem .5rem;
    border-radius: 50rem;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.ld-date-btn:hover { border-color: var(--listing-accent); color: var(--listing-accent); }
.ld-date-btn.active {
    background: linear-gradient(135deg, var(--listing-accent), #8b7cf6);
    border-color: var(--listing-accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(115, 103, 240, .3);
}
.dark-style .ld-date-btn { color: #e2e8f0; border-color: rgba(148,163,184,.25); }
.dark-style .ld-date-btn:hover { color: var(--listing-accent); border-color: var(--listing-accent); }

/* Card grid */
.ld-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: .875rem;
}
@media (max-width: 991.98px) {
    .ld-grid { grid-template-columns: 1fr; }
    .ld-grid > * { grid-column: 1 / -1 !important; }
}

/* Card base */
.ld-card {
    background: var(--listing-card-bg);
    border: 1px solid var(--listing-border);
    border-radius: .75rem;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.04), 0 0 0 0 transparent;
    transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.ld-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
    border-color: rgba(115, 103, 240, .12);
}
.dark-style .ld-card {
    background: #25293c;
    border-color: rgba(148,163,184,.12);
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.dark-style .ld-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    border-color: rgba(115, 103, 240, .2);
}
.ld-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--listing-border);
    background: rgba(115, 103, 240, .025);
    border-left: 3px solid var(--listing-accent);
}
.dark-style .ld-card-header {
    background: rgba(115, 103, 240, .04);
}
.ld-card-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--listing-accent);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.ld-card-body {
    padding: 1rem;
}

/* Overview card */
.ld-overview {
    grid-column: span 8;
    grid-row: span 1;
}
.ld-overview-layout {
    display: flex;
    gap: 1.25rem;
}
.ld-overview-img {
    width: 140px;
    height: 140px;
    border-radius: .75rem;
    object-fit: contain;
    border: 1px solid var(--listing-card-image-border);
    background: var(--listing-card-image-bg);
    flex-shrink: 0;
    cursor: pointer;
    transition: box-shadow .25s, border-color .25s, transform .25s;
    padding: .25rem;
}
.ld-overview-img:hover {
    border-color: var(--listing-accent);
    box-shadow: 0 4px 16px rgba(115,103,240,.15);
    transform: scale(1.03);
}
.ld-overview-data {
    flex: 1;
    min-width: 0;
}
.ld-overview-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: .65rem;
}
.ld-overview-row:last-child { margin-bottom: 0; }
.ld-kv {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}
.ld-kv-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    margin-bottom: .1rem;
}
.ld-kv-value {
    font-size: .875rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}
.dark-style .ld-kv-value { color: #e2e8f0; }

.ld-kv-value .copy-btn {
    opacity: .3;
    margin-left: .25rem;
}
.ld-kv-value .copy-btn:hover { opacity: 1; color: var(--listing-accent); }

/* Settings card */
.ld-settings {
    grid-column: span 4;
    grid-row: span 2;
}
.ld-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem .5rem;
    border-bottom: 1px solid var(--listing-border);
    border-radius: .25rem;
    transition: background .15s;
}
.ld-setting-row:last-child { border-bottom: none; }
.ld-setting-row:hover { background: rgba(115, 103, 240, .03); }
.dark-style .ld-setting-row:hover { background: rgba(115, 103, 240, .05); }
.ld-setting-label {
    font-size: .8rem;
    font-weight: 500;
    color: #475569;
}
.dark-style .ld-setting-label { color: #cbd5e1; }
.ld-setting-input {
    width: 110px;
    text-align: right;
    font-size: .8rem;
    padding: .35rem .55rem;
    border: 1px solid var(--listing-border);
    border-radius: .5rem;
    background: transparent;
    color: #1e293b;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.ld-setting-input:hover {
    border-color: rgba(115, 103, 240, .25);
}
.ld-setting-input:focus {
    outline: none;
    border-color: var(--listing-accent);
    box-shadow: 0 0 0 3px rgba(115,103,240,.1);
    background: rgba(115, 103, 240, .02);
}
.dark-style .ld-setting-input {
    color: #e2e8f0;
    border-color: rgba(148,163,184,.2);
}
.dark-style .ld-setting-input:focus { border-color: var(--listing-accent); }

.ld-strategy-select {
    width: 130px;
    font-size: .8rem;
    padding: .3rem .5rem;
    border: 1px solid var(--listing-border);
    border-radius: .375rem;
    background: transparent;
    color: #1e293b;
    cursor: pointer;
    transition: border-color .15s;
}
.ld-strategy-select:focus {
    outline: none;
    border-color: var(--listing-accent);
    box-shadow: 0 0 0 3px rgba(115,103,240,.1);
}
.dark-style .ld-strategy-select {
    color: #e2e8f0;
    border-color: rgba(148,163,184,.2);
    background: #25293c;
}

.ld-settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: .65rem;
    padding-top: .65rem;
    border-top: 1px solid var(--listing-border);
}
.ld-save-settings-btn {
    font-size: .8rem;
    font-weight: 600;
    padding: .45rem 1.5rem;
    border-radius: .5rem;
    border: none;
    background: linear-gradient(135deg, var(--listing-accent), #8b7cf6);
    color: #fff;
    cursor: pointer;
    transition: opacity .15s, box-shadow .2s, transform .15s;
}
.ld-save-settings-btn:hover { box-shadow: 0 4px 12px rgba(115,103,240,.35); transform: translateY(-1px); }
.ld-save-settings-btn:active { transform: translateY(0) scale(.98); }
.ld-save-settings-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

/* Sales card */
.ld-sales {
    grid-column: span 12;
}
.ld-sales-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
@media (max-width: 575.98px) {
    .ld-sales-kpis { grid-template-columns: repeat(2, 1fr); }
}
.ld-chart-container {
    min-height: 250px;
    position: relative;
}
.ld-chart-toggle {
    display: flex;
    gap: .25rem;
}
.ld-chart-toggle-btn {
    border: 1px solid var(--listing-border);
    background: transparent;
    color: #64748b;
    font-size: .7rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 50rem;
    cursor: pointer;
    transition: all .15s;
}
.ld-chart-toggle-btn:hover {
    border-color: var(--listing-accent);
    color: var(--listing-accent);
}
.ld-chart-toggle-btn.active {
    background: var(--listing-accent);
    border-color: var(--listing-accent);
    color: #fff;
}

/* Fees card */
.ld-fees {
    grid-column: span 4;
    grid-row: span 1;
}
.ld-stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .55rem .5rem;
    border-bottom: 1px solid var(--listing-border);
    border-radius: .25rem;
    transition: background .15s;
}
.ld-stat-row:last-child { border-bottom: none; }
.ld-stat-row:hover { background: rgba(115, 103, 240, .03); }
.dark-style .ld-stat-row:hover { background: rgba(115, 103, 240, .05); }
.ld-stat-label {
    font-size: .8rem;
    color: #64748b;
    font-weight: 500;
}
.dark-style .ld-stat-label { color: #94a3b8; }
.ld-stat-value {
    font-size: .875rem;
    font-weight: 700;
    color: #1e293b;
}
.dark-style .ld-stat-value { color: #e2e8f0; }

/* Inventory card */
.ld-inventory {
    grid-column: span 4;
    grid-row: span 1;
}
.ld-inv-status {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 600;
    padding: .25rem .65rem;
    border-radius: 50rem;
}
.ld-inv-status--instock { background: rgba(34,197,94,.08); color: #16a34a; }
.ld-inv-status--oos { background: rgba(239,68,68,.08); color: #dc2626; }
.dark-style .ld-inv-status--instock { background: rgba(34,197,94,.12); color: #4ade80; }
.dark-style .ld-inv-status--oos { background: rgba(239,68,68,.12); color: #f87171; }

/* Performance card */
.ld-performance {
    grid-column: span 12;
}
.ld-perf-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
}
@media (max-width: 767.98px) {
    .ld-perf-grid { grid-template-columns: 1fr; }
}
.ld-mini-chart {
    border: 1px solid var(--listing-border);
    border-radius: .625rem;
    padding: .875rem;
    transition: border-color .2s, box-shadow .2s, transform .2s;
    background: var(--listing-card-bg);
}
.ld-mini-chart:hover {
    border-color: rgba(115,103,240,.2);
    box-shadow: 0 2px 8px rgba(115, 103, 240, .08);
    transform: translateY(-1px);
}
.dark-style .ld-mini-chart { border-color: rgba(148,163,184,.1); background: rgba(255,255,255,.02); }
.dark-style .ld-mini-chart:hover { box-shadow: 0 2px 8px rgba(115, 103, 240, .12); }
.ld-mini-chart-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin-bottom: .5rem;
}
.ld-mini-chart-area {
    min-height: 120px;
}

/* Notes card */
.ld-notes {
    grid-column: span 12;
}
.ld-notes-textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
    border: 1px solid var(--listing-border);
    border-radius: .625rem;
    padding: .75rem .875rem;
    font-size: .8125rem;
    line-height: 1.6;
    background: rgba(115, 103, 240, .015);
    color: #1e293b;
    transition: border-color .2s, box-shadow .2s, background .2s;
    font-family: inherit;
}
.ld-notes-textarea:focus {
    outline: none;
    border-color: var(--listing-accent);
    box-shadow: 0 0 0 3px rgba(115,103,240,.1);
    background: transparent;
}
.ld-notes-textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
}
.dark-style .ld-notes-textarea {
    color: #e2e8f0;
    border-color: rgba(148,163,184,.2);
}
.ld-notes-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: .5rem;
}
.ld-save-note-btn {
    font-size: .8rem;
    font-weight: 600;
    padding: .4rem 1.25rem;
    border-radius: .5rem;
    border: none;
    background: linear-gradient(135deg, var(--listing-accent), #8b7cf6);
    color: #fff;
    cursor: pointer;
    transition: opacity .15s, box-shadow .2s, transform .15s;
}
.ld-save-note-btn:hover { box-shadow: 0 4px 12px rgba(115,103,240,.35); transform: translateY(-1px); }
.ld-save-note-btn:active { transform: translateY(0) scale(.98); }
.ld-save-note-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

/* Loading state */
.ld-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: .75rem;
    color: var(--listing-muted);
    font-size: .8125rem;
}
.ld-loading .loader-spinner {
    width: 32px; height: 32px;
    border-width: 2.5px;
}

/* Cursor for table rows */
.listings-table tbody tr { cursor: pointer; }

/* Placeholder for charts when no data */
.ld-chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: #94a3b8;
    font-size: .8rem;
    font-style: italic;
}

/* Price highlight in overview */
.ld-kv-value--price {
    color: var(--listing-accent);
    font-weight: 700;
}
.ld-kv-value--positive { color: #16a34a; }
.ld-kv-value--negative { color: #dc2626; }

/* Toggle switches in settings */
.ld-settings .form-check-input:checked {
    background-color: var(--listing-accent);
    border-color: var(--listing-accent);
}

/* Card entrance animation */
.ld-grid .ld-card {
    animation: ldCardFadeIn .35s ease both;
}
.ld-grid .ld-card:nth-child(1) { animation-delay: 0s; }
.ld-grid .ld-card:nth-child(2) { animation-delay: .04s; }
.ld-grid .ld-card:nth-child(3) { animation-delay: .08s; }
.ld-grid .ld-card:nth-child(4) { animation-delay: .12s; }
.ld-grid .ld-card:nth-child(5) { animation-delay: .16s; }
.ld-grid .ld-card:nth-child(6) { animation-delay: .2s; }
.ld-grid .ld-card:nth-child(7) { animation-delay: .24s; }
@keyframes ldCardFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Close button refinement */
.listing-detail-panel .btn-close {
    opacity: .5;
    transition: opacity .15s, transform .15s;
}
.listing-detail-panel .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* Grid gap responsive */
@media (min-width: 992px) {
    .ld-grid { gap: 1rem; }
}


/* Settings info tooltip icon */
.ld-setting-tip {
    font-size: .85rem;
    color: var(--listing-muted);
    cursor: help;
    margin-left: .3rem;
    transition: color .15s;
}
.ld-setting-tip:hover {
    color: var(--listing-accent);
}

/* Chart placeholder styling */
.ld-chart-placeholder {
    border: 1px dashed var(--listing-border);
    border-radius: .375rem;
    background: rgba(115, 103, 240, .015);
}
.dark-style .ld-chart-placeholder {
    background: rgba(255, 255, 255, .015);
}

/* ==========================================================================
   Standalone Listing Detail Page
   ========================================================================== */
.listing-detail-page {
    background: var(--listing-bg-start, #fff);
    min-height: calc(100vh - 80px);
}
.listing-detail-page .offcanvas-header {
    border-bottom: 1px solid var(--listing-border);
    padding: 1rem 1.5rem;
    gap: .75rem;
    flex-wrap: wrap;
    background: var(--listing-surface);
    display: flex;
    align-items: center;
}
.listing-detail-page .offcanvas-body {
    padding: 1.25rem 1.5rem;
}
.ld-back-link {
    display: inline-flex;
    align-items: center;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--listing-muted, #94a3b8);
    text-decoration: none;
    transition: color .15s;
    padding: .25rem 0;
}
.ld-back-link:hover { color: var(--listing-accent, #7367f0); }

/* ==========================================================================
   Responsive — Panel & Page
   ========================================================================== */

/* Small screens: offcanvas full width */
@media (max-width: 575.98px) {
    .listing-detail-panel {
        width: 100vw !important;
    }
    .listing-detail-panel .offcanvas-header,
    .listing-detail-page .offcanvas-header {
        padding: .75rem 1rem;
    }
    .listing-detail-panel .offcanvas-body,
    .listing-detail-page .offcanvas-body {
        padding: .75rem 1rem;
    }
    .ld-header-left { max-width: 100%; }
    .ld-header-title { max-width: 200px; font-size: .9rem; }
    .ld-header-right { width: 100%; justify-content: flex-end; }
    .ld-date-filters { gap: .25rem; }
    .ld-date-btn { font-size: .65rem; padding: .2rem .5rem; }
    .ld-overview-layout { flex-direction: column; align-items: center; }
    .ld-overview-img { width: 120px; height: 120px; margin: 0 auto 1rem; }
    .ld-overview-data { width: 100%; }
    .ld-overview-row { grid-template-columns: 1fr !important; gap: .5rem; }
    .ld-perf-grid { grid-template-columns: 1fr !important; }
}

/* Medium screens */
@media (min-width: 576px) and (max-width: 767.98px) {
    .listing-detail-panel {
        width: min(92vw, 560px) !important;
    }
    .ld-header-title { max-width: 240px; }
    .ld-date-btn { font-size: .7rem; padding: .25rem .5rem; }
    .ld-overview-row { grid-template-columns: repeat(2, 1fr) !important; }
    .ld-overview-img { width: 100px; height: 100px; }
}

/* Tablet screens */
@media (min-width: 768px) and (max-width: 991.98px) {
    .listing-detail-panel {
        width: min(85vw, 720px) !important;
    }
    .ld-overview { grid-column: span 12 !important; }
    .ld-settings { grid-column: span 12 !important; grid-row: span 1 !important; }
    .ld-fees { grid-column: span 6 !important; }
    .ld-inventory { grid-column: span 6 !important; }
}

/* Large screens */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .listing-detail-panel {
        width: min(80vw, 900px) !important;
    }
}

/* XL screens */
@media (min-width: 1200px) {
    .listing-detail-panel {
        width: min(75vw, 1100px) !important;
    }
}
