* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Landing page */
.landing {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.landing-content {
    text-align: center;
    max-width: 500px;
}

.landing-logo {
    max-width: 320px;
    height: auto;
    margin-bottom: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.tagline {
    font-size: 20px;
    color: #888;
    margin-bottom: 40px;
}

.features {
    text-align: left;
    margin-bottom: 40px;
}

.feature {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #2a2a4e;
}

.feature-icon {
    font-size: 24px;
}

.login-btn {
    display: inline-block;
    padding: 15px 40px;
    background: #888;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
}

.login-btn:hover {
    background: #aaa;
}

.trust-info {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.trust-title {
    color: #4ade80;
    font-weight: bold;
    margin: 0 0 10px 0;
    font-size: 14px;
}

.trust-item {
    color: #ccc;
    font-size: 13px;
    padding: 4px 0;
    padding-left: 15px;
    position: relative;
}

.trust-item::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4ade80;
}

.trust-note {
    color: #888;
    font-size: 12px;
    margin: 15px 0 0 0;
    line-height: 1.5;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    background: #16213e;
    z-index: 999;
    flex-direction: column;
    padding: 8px 10px;
    border-bottom: 1px solid #2a2a4e;
}

.mobile-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
}

.mobile-logo-img {
    height: 28px;
    width: auto;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-user-info span {
    color: #aaa;
    font-size: 16px;
}

.mobile-logout-btn {
    color: #e74c3c;
    text-decoration: none;
    font-size: 13px;
}

.mobile-header-btns {
    display: flex;
    gap: 8px;
    width: 100%;
}

.mobile-header-btn {
    flex: 1;
    background: #2a2a4e;
    color: #fff;
    border: 1px solid #3a3a5e;
    padding: 10px 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.mobile-header-btn:hover {
    background: #ccc;
}

/* Left Sidebar */
.left-sidebar {
    width: 250px;
    background: #16213e;
    padding: 15px;
    flex-shrink: 0;
    border-right: 1px solid #2a2a4e;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.sidebar-toggle-btns {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.sidebar-toggle-btn {
    flex: 1;
    padding: 10px 8px;
    background: #0f0f23;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.sidebar-toggle-btn:hover {
    background: #2a2a4e;
    color: #fff;
}

.sidebar-toggle-btn.active {
    background: #aaa;
    color: #000;
}

.sidebar-panel {
    display: block;
}

.sidebar-panel.hidden {
    display: none;
}

.sidebar-search {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #3a3a5e;
    border-radius: 5px;
    background: #1a1a2e;
    color: #fff;
    font-size: 13px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.sidebar-search::placeholder {
    color: #666;
}

.sidebar-search:focus {
    outline: none;
    border-color: #4a4a7e;
}

.close-left-btn {
    display: none;
}

.left-overlay {
    display: none;
}

/* Hidden items in left sidebar */
.hidden-item-left {
    display: flex;
    gap: 10px;
    padding: 8px;
    background: #0f0f23;
    border-radius: 6px;
    margin-bottom: 8px;
    align-items: center;
}

.hidden-item-left img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    background: #1a1a2e;
    border-radius: 4px;
    flex-shrink: 0;
}

.hidden-item-left-info {
    flex: 1;
    min-width: 0;
}

.hidden-item-left-title {
    font-size: 11px;
    line-height: 1.3;
    max-height: 28px;
    overflow: hidden;
    color: #ccc;
    text-decoration: none;
    display: block;
}

.hidden-item-left-title:hover {
    color: #fff;
}

.hidden-item-reason {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

.unhide-btn-small {
    background: #27ae60;
    border: none;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.unhide-btn-small:hover {
    background: #2ecc71;
}

.load-more-btn {
    width: 100%;
    padding: 10px;
    background: #2a2a4e;
    border: 1px solid #3a3a5e;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
}

.load-more-btn:hover {
    background: #3a3a5e;
}

/* Watching items in sidebar */
.watching-btns {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.refresh-watching-btn {
    flex: 1;
    padding: 8px;
    background: #0f0f23;
    border: 1px solid #2a2a4e;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    font-size: 12px;
}

.refresh-watching-btn:hover {
    background: #2a2a4e;
    color: #fff;
}

.delete-ended-btn {
    flex: 1;
    padding: 8px;
    background: #3d1a1a;
    border: 1px solid #5a2a2a;
    border-radius: 6px;
    color: #e74c3c;
    cursor: pointer;
    font-size: 11px;
}

.delete-ended-btn:hover {
    background: #5a2a2a;
    color: #ff6b6b;
}

/* Delete modal */
.delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.delete-modal {
    background: #1a1a2e;
    border-radius: 10px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.delete-modal h3 {
    margin: 0 0 15px 0;
    color: #fff;
    font-size: 16px;
}

.delete-modal-list {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
    margin-bottom: 15px;
    border: 1px solid #2a2a4e;
    border-radius: 6px;
    padding: 10px;
}

.delete-modal-item {
    padding: 8px 0;
    border-bottom: 1px solid #2a2a4e;
}

.delete-modal-item:last-child {
    border-bottom: none;
}

.delete-modal-item-title {
    font-size: 12px;
    color: #ccc;
    margin-bottom: 2px;
}

.delete-modal-item-details {
    font-size: 10px;
    color: #888;
}

.delete-modal-btns {
    display: flex;
    gap: 10px;
}

.delete-modal-cancel {
    flex: 1;
    padding: 10px;
    background: #2a2a4e;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.delete-modal-cancel:hover {
    background: #3a3a5e;
}

.delete-modal-confirm {
    flex: 1;
    padding: 10px;
    background: #e74c3c;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.delete-modal-confirm:hover {
    background: #c0392b;
}

.watching-item {
    display: flex;
    gap: 10px;
    padding: 8px;
    background: #0f0f23;
    border-radius: 6px;
    margin-bottom: 8px;
    align-items: center;
}

.watching-item img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    background: #1a1a2e;
    border-radius: 4px;
    flex-shrink: 0;
}

.watching-item-info {
    flex: 1;
    min-width: 0;
}

.watching-item-title {
    font-size: 11px;
    line-height: 1.3;
    max-height: 28px;
    overflow: hidden;
    color: #ccc;
    text-decoration: none;
    display: block;
}

.watching-item-title:hover {
    color: #fff;
}

.watching-item-price {
    font-size: 11px;
    color: #4ade80;
    margin-top: 2px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.watching-status {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.watching-status.ended {
    background: #666;
    color: #fff;
}

.watching-status.sold {
    background: #e74c3c;
    color: #fff;
}

.watching-item.ended {
    opacity: 0.6;
}

.remove-watch-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    flex-shrink: 0;
}

.remove-watch-btn:hover {
    color: #e74c3c;
}

.saved-search {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #0f0f23;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    cursor: default;
}

.saved-search.dragging {
    opacity: 0.5;
}

.saved-search.drag-over-top {
    border-top: 2px solid #aaa;
}

.saved-search.drag-over-bottom {
    border-bottom: 2px solid #aaa;
}

.drag-handle {
    cursor: grab;
    color: #555;
    margin-right: 8px;
    font-size: 12px;
    letter-spacing: -2px;
}

.drag-handle:hover {
    color: #888;
}

.drag-handle:active {
    cursor: grabbing;
}

.saved-search-name {
    cursor: pointer;
    color: #fff;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-search-name:hover {
    color: #ccc;
}

.saved-search-edit {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
}

.saved-search-edit:hover {
    color: #ccc;
}

.saved-search-delete {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0 0 0 4px;
    font-size: 16px;
}

.saved-search-delete:hover {
    color: #e74c3c;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-logo {
    height: 48px;
    width: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username {
    color: #ccc;
}

.logout-btn {
    color: #888;
    text-decoration: none;
}

.logout-btn:hover {
    color: #fff;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#searchInput {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    background: #16213e;
    color: #fff;
    min-width: 0;
    height: 48px;
    box-sizing: border-box;
}

#searchInput:focus {
    outline: 2px solid #aaa;
}

#minPrice, #maxPrice {
    width: 80px;
    padding: 12px 10px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    background: #16213e;
    color: #fff;
    height: 48px;
    box-sizing: border-box;
}

#minPrice:focus, #maxPrice:focus {
    outline: 2px solid #aaa;
}

#minPrice::placeholder, #maxPrice::placeholder {
    color: #666;
}

#searchBtn {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    background: #aaa;
    color: #000;
    height: 48px;
    box-sizing: border-box;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}

#searchBtn:hover {
    background: #ccc;
}

#saveSearchBtn {
    padding: 12px 16px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    background: #16213e;
    height: 48px;
    box-sizing: border-box;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

#saveSearchBtn:hover {
    background: #2a2a4e;
}

.search-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 10px;
    background: #16213e;
    border-radius: 8px;
    height: 48px;
    color: #ccc;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.2;
    text-align: center;
}

.search-checkbox:hover {
    background: #2a2a4e;
}

.search-checkbox input {
    cursor: pointer;
}

.search-checkbox span {
    white-space: nowrap;
}

/* Categories */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.category-btn {
    padding: 6px 12px;
    background: #16213e;
    border: none;
    border-radius: 15px;
    color: #888;
    cursor: pointer;
    font-size: 12px;
}

.category-btn:hover {
    background: #2a2a4e;
    color: #fff;
}

.category-btn.active {
    background: #aaa;
    color: #000;
}

.category-btn.active.filtered {
    background: #4ade80;
    color: #000;
}

.category-count {
    margin-left: 5px;
    opacity: 0.7;
}

/* Stats */
.stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #888;
    align-items: center;
}

.results-controls {
    display: none;
    gap: 10px;
    align-items: center;
}

.results-controls.show {
    display: flex;
}

.results-controls select,
.results-controls button {
    padding: 6px 12px;
    background: #0f0f23;
    border: 1px solid #2a2a4e;
    border-radius: 15px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
}

.results-controls select:hover,
.results-controls button:hover {
    background: #2a2a4e;
    color: #fff;
}

.results-controls select:focus,
.results-controls button:focus {
    outline: none;
    border-color: #888;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #0f0f23;
    border: 1px solid #2a2a4e;
    border-radius: 15px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
}

.filter-checkbox:hover {
    background: #2a2a4e;
    color: #fff;
}

.filter-checkbox input {
    cursor: pointer;
}

.toggle-sidebar {
    cursor: pointer;
    text-decoration: underline;
}

.toggle-sidebar:hover {
    color: #ccc;
}

/* Results Grid */
#results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Item Card */
.item {
    background: #16213e;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s;
}

.item:hover {
    transform: translateY(-3px);
}

.img-container {
    position: relative;
    background: #0f0f23;
    overflow: hidden;
}

.item-img {
    width: 100%;
    height: 450px;
    object-fit: contain;
    background: #0f0f23;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

.img-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
}

.img-nav:hover {
    background: rgba(170,170,170,0.8);
}

.img-nav.prev {
    left: 10px;
}

.img-nav.next {
    right: 10px;
}

.img-counter {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.item-info {
    padding: 12px;
}

.buy-label {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.item-title {
    font-size: 16px;
    line-height: 1.4;
    height: 1.4em;
    overflow: hidden;
    margin-bottom: 8px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.item-title a {
    color: #fff;
    text-decoration: none;
}

.item-title a:hover {
    color: #ccc;
}

.item-price-section {
    margin-bottom: 10px;
}

.item-price-line {
    font-size: 14px;
    color: #999;
}

.item-total {
    font-size: 20px;
    font-weight: bold;
    color: #4ade80;
    margin-top: 2px;
}

.watch-btn-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(39, 174, 96, 0.9);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}
.watch-btn-overlay:hover {
    background: rgba(46, 204, 113, 1);
}

.hide-label-row {
    text-align: center;
    color: #888;
    font-size: 11px;
    margin-bottom: 4px;
}

.item-buttons {
    display: flex;
    gap: 3px;
    align-items: center;
}

.item-buttons button {
    flex: 1;
    padding: 8px 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    color: #fff;
    white-space: nowrap;
}

.hide-btn-whitening {
    background: #8e44ad;
}
.hide-btn-whitening:hover {
    background: #9b59b6;
}

.hide-btn-corners {
    background: #e67e22;
}
.hide-btn-corners:hover {
    background: #f39c12;
}

.hide-btn-oc {
    background: #3498db;
}
.hide-btn-oc:hover {
    background: #5dade2;
}

.hide-btn-scuff {
    background: #16a085;
}
.hide-btn-scuff:hover {
    background: #1abc9c;
}

.hide-btn-maybe {
    background: #7f8c8d;
}
.hide-btn-maybe:hover {
    background: #95a5a6;
}

.hide-btn-custom {
    background: #e74c3c;
}
.hide-btn-custom:hover {
    background: #c0392b;
}


.error {
    background: #e74c3c;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.load-more-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
}

.load-more-container .load-more-btn {
    background: #3498db;
    color: #fff;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.load-more-container .load-more-btn:hover:not(:disabled) {
    background: #2980b9;
}

.load-more-container .load-more-btn:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    transform: translateX(100px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Mobile */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
    }

    .main-content > header {
        display: none;
    }

    .left-sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        width: 300px;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
        border-right: 1px solid #2a2a4e;
        padding: 15px;
        padding-top: 60px;
    }

    .left-sidebar.open {
        left: 0;
    }

    .close-left-btn {
        display: block;
        position: absolute;
        top: 15px;
        right: 15px;
        background: none;
        border: none;
        color: #fff;
        font-size: 28px;
        cursor: pointer;
        padding: 0;
    }

    .left-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.6);
        z-index: 1000;
    }

    .left-overlay.open {
        display: block;
    }

    .main-content {
        padding-top: 100px;
    }

    .search-box {
        display: flex;
        flex-wrap: nowrap;
        flex-direction: column;
        margin-top: 10px;
        gap: 8px;
    }

    #searchInput {
        width: 100%;
        flex: none;
        order: 1;
    }

    /* Create a wrapper effect using CSS grid for the second row */
    .search-box {
        display: grid;
        grid-template-columns: 1fr 1fr auto auto auto;
        grid-template-rows: auto auto;
        gap: 8px;
    }

    #searchInput {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    #minPrice {
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
        padding: 10px 6px;
        font-size: 13px;
        width: 100%;
    }

    #maxPrice {
        grid-column: 2;
        grid-row: 2;
        min-width: 0;
        padding: 10px 6px;
        font-size: 13px;
        width: 100%;
    }

    .search-checkbox {
        grid-column: 3;
        grid-row: 2;
        padding: 0 8px;
        font-size: 12px;
        height: auto;
        min-height: 44px;
    }

    #saveSearchBtn {
        grid-column: 4;
        grid-row: 2;
        padding: 10px 12px;
    }

    #searchBtn {
        grid-column: 5;
        grid-row: 2;
        padding: 10px 14px;
        font-size: 14px;
    }

    #results {
        grid-template-columns: 1fr;
    }

    .item-img {
        height: 350px;
    }

    .item-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        height: 2.8em;
    }
}
