/* --- Base Styles --- */
body {
    background-color: #121212;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    width: 95%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2rem;
    background: linear-gradient(to bottom, #2a2a2a, #1c1c1c);
    border: 1px solid #444;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    text-align: center;
}

/* --- Header & Common Elements --- */
header {
    position: relative;
    text-align: center;
}

header h1 {
    font-family: 'Press Start 2P', cursive;
    font-size: 2rem;
    color: #00ffff;
    text-shadow: 2px 2px 4px #000000;
    margin-bottom: 1rem;
}

.led-text {
    background-color: #1a1a1a;
    color: #00ffff;
    border: 1px solid #00ffff;
    border-radius: 5px;
    padding: 10px;
    font-family: 'Digital-7 Mono', sans-serif;
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1rem;
    max-width: 400px;
    margin: 0 auto 1rem auto;
}

.rect-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem;
    line-height: 1;
    text-align: center;
    background-color: #555;
    color: #fff;
    border: 2px solid #000;
    border-radius: 5px;
    padding: 1rem;
    cursor: pointer;
    box-shadow: 0 3px #333;
    width: auto;
    margin-top: 1rem;
}

#back-to-main-btn {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

.rect-button:disabled {
    background-color: #333;
    cursor: not-allowed;
}

.rect-button:active {
    box-shadow: 0 1px #333;
    transform: translateY(2px);
}

/* --- Main Page Layout --- */
.main-layout {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    text-align: left;
}

.side-panel {
    flex: 0 0 200px;
    background: #1c1c1c;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #333;
    height: fit-content;
}

.side-panel .rect-button {
    width: 100%;
    margin-top: 0;
}

.main-panel {
    flex: 1;
}

.main-panel h2 {
    font-family: 'Press Start 2P', cursive;
    color: #00ffff;
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* --- NFT Grid Styles --- */
.nft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.nft-card {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.nft-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.nft-card img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    background-color: #121212;
}

.nft-card .nft-info {
    padding: 1rem;
    text-align: left;
}

.nft-card .nft-collection {
    font-size: 0.8rem;
    color: #aaa;
    margin: 0 0 0.25rem 0;
}

.nft-card .nft-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

.nft-card .nft-owner {
    font-size: 0.8rem;
    color: #00ffff;
    font-family: 'Digital-7 Mono', sans-serif;
}

/* --- "MY CONSOLE" Page Layout --- */
.console-layout {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    text-align: left;
}

.console-profile-panel {
    flex: 0 0 250px;
    background: #1c1c1c;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #333;
    text-align: center;
    height: fit-content;
}

.pfp-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 3px solid #00ffff;
    margin-bottom: 1rem;
    object-fit: cover;
    background-color: #121212;
}

.console-profile-panel h3 {
    margin-top: 0;
    font-size: 1.2rem;
    word-wrap: break-word;
}

.console-main-panel {
    flex: 1;
}

.grid-paper-background {
    background-color: #3a3a3a;
    background-image:
        linear-gradient(rgba(0, 128, 0, 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 128, 0, 0.2) 1px, transparent 1px);
    background-size: 25px 25px;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 2rem;
    min-height: 50vh;
}

.console-main-panel h2 {
    font-family: 'Press Start 2P', cursive;
    color: #00ffff;
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
}

.console-main-panel .nft-grid {
     grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* --- Machine Console Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: linear-gradient(to bottom, #2a2a2a, #1c1c1c);
    padding: 2.5rem;
    border: 1px solid #444;
    width: 90%;
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    position: relative;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
}

.close-modal-btn:hover {
    color: #fff;
}

.machine-console {
    max-width: 900px;
}

.machine-console-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.machine-console-left {
    flex: 0 0 300px;
    text-align: center;
}

.machine-console-left img {
    width: 100%;
    border-radius: 12px;
    border: 3px solid #555;
    margin-bottom: 1rem;
}

.machine-console-left h2 {
    font-family: 'Press Start 2P', cursive;
    color: #00ffff;
    font-size: 1.5rem;
}

.machine-console-right {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.readout-window {
    background-color: #121212;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #333;
}

.readout-window label {
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.5rem;
    display: block;
    text-align: center;
}

.led-readout {
    background-color: #000;
    color: #32ff32; /* Neon Green */
    font-family: 'Digital-7 Mono', sans-serif;
    padding: 0.8rem;
    text-align: right;
    border-radius: 5px;
    border: 1px solid #222;
    font-size: 1.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#virtual-hashes-readout {
    font-size: 1.5rem;
}

/* --- Device Modal --- */
.device-console {
    max-width: 400px; /* Smaller max-width for a card-like feel */
    text-align: center;
}

.device-console-layout {
    display: flex;
    flex-direction: column; /* Stack image and button vertically */
    align-items: center;
    gap: 1.5rem;
}

.device-console-left {
    width: 100%;
}

#device-modal-image {
    width: 100%;
    max-width: 250px; /* Control the image size */
    height: auto;
    border-radius: 12px;
    border: 3px solid #555;
    margin-bottom: 1rem;
}

#device-modal-title {
    font-family: 'Press Start 2P', cursive;
    color: #00ffff;
    font-size: 1.5rem;
    margin: 0;
}

.device-console-right {
    width: 100%;
}

#connect-device-btn {
    width: 100%;
    max-width: 250px; /* Match the image width */
    padding: 1rem;
    font-size: 1rem;
}


/* --- View Switch Toggle --- */
.view-switch {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.view-switch label {
    margin-right: 10px;
    font-size: 0.8rem;
    color: #aaa;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 25px;
    background-color: #333;
    border-radius: 25px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    transition: background-color 0.3s;
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background-color: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch:checked {
    background-color: #00ffff;
}

.toggle-switch:checked::before {
    transform: translateX(25px);
}


/* --- Responsive Design --- */

/* Tablet and smaller desktops */
@media (max-width: 992px) {
    .container {
        width: 100%;
        padding: 1rem;
    }

    .main-layout, .console-layout {
        flex-direction: column;
    }

    .side-panel, .console-profile-panel {
        flex: 0 0 auto; /* Reset flex-basis */
        width: 100%;
        margin-bottom: 1.5rem;
    }

    .machine-console-layout {
        flex-direction: column;
        align-items: center;
    }

    .machine-console-left {
        flex: 0 0 auto;
        width: 100%;
        max-width: 300px;
    }

    .machine-console-right {
        width: 100%;
    }
}

/* Mobile phones */
@media (max-width: 576px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .rect-button {
        font-size: 0.8rem;
        padding: 0.8rem;
    }

    #back-to-main-btn {
        top: 5px;
        left: 5px;
        font-size: 0.7rem;
        padding: 0.4rem 0.8rem;
        z-index: 10;
    }

    .side-panel, .console-profile-panel {
        box-sizing: border-box;
    }

    .nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

     .console-main-panel .nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .grid-paper-background {
        padding: 1rem;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .machine-console-layout {
        overflow-y: auto;
    }

    .machine-console-right {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .led-readout {
        font-size: 1.2rem;
    }

    #virtual-hashes-readout {
        font-size: 1.1rem;
    }
}

/* --- Manual Mobile View Toggle & Refined Mobile Styles --- */

/* This class will be toggled via JavaScript to force the mobile layout */
body.mobile-view .main-layout,
body.mobile-view .console-layout,
body.mobile-view .machine-console-layout {
    flex-direction: column;
}

body.mobile-view .console-profile-panel {
    width: auto; /* Let it shrink to fit content */
    margin-right: auto;
    margin-left: auto;
}

body.mobile-view #back-to-main-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
    z-index: 10;
}
