/* CSS Variables for Modern Dark Theme */
:root {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #38bdf8;
    --accent-secondary: #818cf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --status-success: #10b981;
    --status-scanning: #eab308;
    --status-error: #ef4444;
    --shadow-light: rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden; /* Only prevent horizontal scrolling */
    overflow-y: auto; /* Allow vertical scrolling */
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    padding: 80px 20px 40px;
}

#cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background-color: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: var(--glass-border);
    box-shadow: -4px 0 24px rgba(0,0,0,0.5);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 24px;
    color: var(--text-primary);
    overflow-y: auto;
}

#cart-sidebar.open {
    transform: translateX(0);
}

#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    margin: 0;
    text-align: left;
    font-size: 1.5rem;
}

.close-sidebar {
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-sidebar:hover {
    color: var(--accent-primary);
}

#cart-items {
    flex: 0 0 auto;
    max-height: 40vh;
    overflow-y: auto;
    margin-bottom: 24px;
    border-top: 1px solid var(--bg-border);
    padding-top: 8px;
}

.cart-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg-border);
    font-size: 0.9rem;
}

.cart-item-title {
    flex: 2;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 2px;
}

.qty-controls button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.qty-controls button:hover {
    color: var(--accent-primary);
}

.qty-controls span {
    font-size: 0.9rem;
    min-width: 16px;
    text-align: center;
}

.cart-item-price {
    flex: 1;
    text-align: right;
    font-weight: 600;
    color: var(--accent-primary);
    margin-left: 12px;
}

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

.remove-btn:hover {
    color: #ff4757;
    background-color: rgba(255, 71, 87, 0.1);
}

.payment-section {
    border-top: 1px solid var(--bg-border);
    padding-top: 16px;
    flex-shrink: 0;
}

.payment-section h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.payment-option {
    display: flex;
    gap: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--bg-border);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.qr-code {
    flex-shrink: 0;
    width: 70px;
    height: 70px;
    background: white;
    padding: 3px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-code img {
    width: 100%;
    height: 100%;
    display: block;
}

.payment-details {
    flex: 1;
    overflow: hidden;
}

.payment-details h4 {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    color: var(--accent-primary);
}

.address-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.address-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-border);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    outline: none;
    width: 100%;
}

.copy-btn {
    background-color: var(--accent-primary);
    color: var(--bg-main);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background-color: var(--accent-secondary);
    transform: scale(1.05);
}

/* Verification Styles */
.verification-section {
    margin-top: 20px;
    text-align: center;
}

.input-group {
    margin-bottom: 12px;
}

.tx-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
}

.tx-input:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.verify-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-primary);
    color: var(--bg-main);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.verify-btn:hover:not(:disabled) {
    background: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.verify-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.status-msg {
    margin-top: 10px;
    font-size: 0.9rem;
    min-height: 20px;
}

.status-msg.scanning {
    color: var(--status-scanning);
    animation: pulse 1.5s infinite;
}

.status-msg.error {
    color: var(--status-error);
}

.success-message {
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: var(--status-success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
}

.success-message h3 {
    color: var(--status-success);
    font-size: 1.5rem;
    margin: 0 0 8px 0;
}

.hash {
    font-family: monospace;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

.code-box {
    background: rgba(255,255,255,0.05);
    border: 1px dashed var(--accent-primary);
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
}

.code-box h2 {
    font-family: monospace;
    font-size: 1.8rem;
    margin: 8px 0;
    letter-spacing: 2px;
    color: var(--accent-primary);
}

.note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

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

/* Rest of Main Page Styles */
#cart-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    border: var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all 0.3s ease;
    display: none;
    z-index: 100;
}

#cart-icon img {
    width: 24px;
    height: 24px;
    filter: invert(1);
}

#cart-icon:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-primary);
}

#timer-container {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    border: var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    text-align: center;
    z-index: 100;
}

#timer-container h2 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#timer {
    margin: 4px 0 0 0;
    font-size: 1.2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent-primary);
    letter-spacing: 0.02em;
}

.items-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    padding: 0 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.item {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.4), rgba(15, 23, 42, 0.4));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0);
    animation-fill-mode: forwards;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.3);
}

@keyframes suspense {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.item-cart-icon {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: none;
    z-index: 10;
}

.item:hover .item-cart-icon {
    opacity: 1;
    transform: translateY(0);
}

.item-cart-icon img {
    width: 20px;
    height: 20px;
    filter: invert(1);
}

.item-cart-icon:hover {
    background-color: var(--accent-secondary);
    box-shadow: 0 0 15px var(--accent-primary);
    transform: scale(1.1) translateY(0);
}

.item-info {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding-top: 8px;
    color: var(--text-primary);
}

.item-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.item-info p {
    margin: 0;
    font-size: 1rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.image-placeholder {
    width: 100%;
    height: 250px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.05), transparent);
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    box-sizing: border-box;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.image-container {
    width: 100%;
    height: 250px;
    border-radius: 12px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    cursor: crosshair; /* Hint at interaction */
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s; /* Subtle zoom or just smooth transition */
}

.image-placeholder::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.03), transparent);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.item.small {
    animation: suspense 0.8s ease-out forwards;
}

.item.medium {
    animation: suspense 1s ease-out forwards;
    animation-delay: 0.3s;
}

.item.large {
    animation: suspense 1.2s ease-out forwards;
    animation-delay: 0.6s;
}

/* Tablet and Medium Screens */
@media (max-width: 1024px) {
    body {
        padding: 80px 16px 32px;
    }

    .items-container {
        gap: 20px;
        padding: 0 16px;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    #timer-container {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    #timer {
        font-size: 1.1rem;
    }
}

/* Small Tablets */
@media (max-width: 768px) {
    body {
        padding: 90px 16px 24px;
        justify-content: flex-start;
    }

    #cart-sidebar {
        width: 100%;
        padding: 20px 16px;
    }

    .sidebar-header h2 {
        font-size: 1.3rem;
    }

    .items-container {
        gap: 16px;
        padding: 20px 16px;
    }

    .item {
        min-width: unset;
        max-width: unset;
        width: 100%;
        padding: 16px;
    }

    #timer-container {
        top: 16px;
        left: 50%;
        transform: translateX(-50%);
        width: auto;
        max-width: calc(100% - 80px);
        padding: 8px 12px;
    }

    #timer-container h2 {
        font-size: 0.75rem;
    }

    #timer {
        font-size: 1rem;
    }

    #cart-icon {
        top: 16px;
        right: 16px;
        width: 40px;
        height: 40px;
    }

    #cart-icon img {
        width: 20px;
        height: 20px;
    }

    .image-placeholder, .image-container {
        width: 100%;
        max-width: 100%;
        height: 220px;
        margin: 0 auto 16px;
    }
    
    .item-cart-icon {
        width: 44px;
        height: 44px;
        bottom: 16px;
        right: 16px;
    }

    .item-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .item-info h3 {
        font-size: 1.1rem;
    }

    .payment-option {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 12px;
    }

    .qr-code {
        width: 80px;
        height: 80px;
    }

    .address-input {
        font-size: 0.7rem;
        padding: 8px;
    }

    .cart-item-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .cart-item-title {
        flex: 1 1 100%;
        margin-bottom: 4px;
    }

    .qty-controls {
        flex: 0 0 auto;
    }

    .cart-item-price {
        flex: 1 1 auto;
        margin-left: 0;
    }
}

/* Mobile Devices */
@media (max-width: 480px) {
    body {
        padding: 80px 12px 20px;
    }

    .items-container {
        gap: 12px;
        padding: 16px 12px;
    }

    .item {
        padding: 14px;
    }

    #timer-container {
        padding: 6px 10px;
        font-size: 0.8rem;
        max-width: calc(100% - 70px);
    }

    #timer-container h2 {
        font-size: 0.7rem;
    }

    #timer {
        font-size: 0.95rem;
    }

    .sidebar-header h2 {
        font-size: 1.2rem;
    }

    .payment-details h4 {
        font-size: 0.85rem;
    }

    .address-input {
        font-size: 0.65rem;
        padding: 6px;
    }

    .copy-btn {
        width: 28px;
        height: 28px;
    }

    .qr-code {
        width: 70px;
        height: 70px;
    }

    .verify-btn {
        padding: 10px;
        font-size: 0.95rem;
    }

    .code-box h2 {
        font-size: 1.4rem;
    }

    .item-info h3 {
        font-size: 1rem;
    }

    .image-placeholder, .image-container {
        height: 200px;
    }
}

/* Very Small Screens */
@media (max-width: 360px) {
    .item {
        padding: 12px;
    }

    .item-info h3 {
        font-size: 0.95rem;
    }

    #timer-container {
        font-size: 0.75rem;
        padding: 5px 8px;
    }

    #timer {
        font-size: 0.9rem;
    }

    .image-placeholder, .image-container {
        height: 180px;
    }
}

/* Image Positioning Adjustments */

/* Product 1: Image 1 - Fix truncated feet (show bottom) */
#item1 .image-container img[data-index="0"] {
    object-position: center bottom;
}

/* Product 2: Image 1, 2 & 4 - Fix truncated heads (show top) */
#item2 .image-container img[data-index="0"],
#item2 .image-container img[data-index="1"],
#item2 .image-container img[data-index="3"] {
    object-position: center 20%;
}

/* Product 2: Image 3 - Fix truncated feet (show bottom) */
#item2 .image-container img[data-index="2"] {
    object-position: center bottom;
}
