/* 1. Lock the entire page down from the root */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Kills the global phantom scrollbar */
}

/* 2. Universal Box Sizing */
* {
    box-sizing: border-box;
}

/* 3. The "Transparent-to-Visible" Scrollbar Trick */
/* Keep width permanent so the layout math never shifts */
#left-toolbar::-webkit-scrollbar,
#layersContainer::-webkit-scrollbar {
    width: 6px; 
    background: transparent;
}

#left-toolbar::-webkit-scrollbar-track,
#layersContainer::-webkit-scrollbar-track {
    background: transparent;
}

/* Make the thumb invisible by default */
#left-toolbar::-webkit-scrollbar-thumb,
#layersContainer::-webkit-scrollbar-thumb {
    background: transparent; 
    border-radius: 10px;
}

/* Only color the thumb when hovering over the panel */
#left-toolbar:hover::-webkit-scrollbar-thumb,
#layersContainer:hover::-webkit-scrollbar-thumb {
    background: #bbb;
}

#left-toolbar::-webkit-scrollbar-thumb:hover,
#layersContainer::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* Only reveals the scrollbar when your mouse is over the panel */
#left-toolbar:hover::-webkit-scrollbar,
#layersContainer:hover::-webkit-scrollbar {
    width: 6px;
}

#left-toolbar::-webkit-scrollbar-thumb,
#layersContainer::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 10px;
}

#left-toolbar::-webkit-scrollbar-thumb:hover,
#layersContainer::-webkit-scrollbar-thumb:hover {
    background: #888;
}

body {
    margin: 0;
    display: flex;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1e1e1e; /* Darker, more professional studio background */
    height: 100vh;
    overflow: hidden;
    color: #333;
}

/* New 3-Column Layout */
#left-toolbar {
    width: 260px;
    background-color: #f8f9fa;
    padding: 2vh 20px; /* Top/bottom padding scales with screen height */
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    z-index: 10;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2vh; /* The gaps between sections act like an accordion now */
}

#workspace {
    flex-grow: 1; 
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#right-toolbar {
    width: 250px;
    background-color: #f8f9fa;
    padding: 20px;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.canvas-container {
    box-shadow: 5px 5px 25px rgba(0,0,0,0.8);
    background-color: white;
}

/* Clean Button Alignments */
.tool-section {
    display: flex;
    flex-direction: column;
    gap: 0.8vh; /* The gaps between individual buttons scale dynamically */
}
.tool-section p {
    margin: 0;
    font-size: 14px;
    font-weight: bold;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
}
.row {
    display: flex;
    gap: 5px;
}
.row button, .row input, .row select {
    flex: 1;
}
button, .btn-label {
    padding: 0.8vh 10px; /* Button height shrinks slightly on small laptop screens */
    cursor: pointer;
    background: #e9ecef;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
}
button:hover, .btn-label:hover {
    background: #dde0e3;
}
input[type="number"], select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* The Layers Panel Styling */
#layersContainer {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.layer-item {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
}
.layer-item:hover {
    background: #f1f3f5;
}
.layer-item.active {
    background: #e3f2fd;
    border-color: #2196f3;
}
.layer-controls button {
    padding: 2px 5px;
    margin-left: 2px;
    font-size: 12px;
    background: #fff;
}

/* Layer Thumbnails & Text Formatting */
.layer-content {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex-grow: 1;
}
.layer-thumb {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #ccc;
    background: #eee;
}
.layer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* --- MOBILE RESPONSIVE UPDATES --- */

@media (max-width: 800px) {
    body {
        flex-direction: column; /* Stacks panels vertically */
        overflow-y: auto;       /* Allows scrolling on phones */
        height: auto;
    }

    #left-toolbar, #right-toolbar {
        width: 100%;           /* Toolbars take full width */
        box-sizing: border-box;
        box-shadow: none;
        border-bottom: 1px solid #ccc;
    }

    #workspace {
        width: 100%;
        min-height: 300px;     /* Ensures canvas has room */
        padding: 10px;
        background-color: #333;
    }

    /* Adjust the row of buttons for smaller screens */
    .row {
        flex-wrap: wrap; 
    }

    /* Ensure Export button is always easy to tap */
    #exportPdf {
        position: sticky;
        bottom: 0;
        z-index: 20;
    }
}

/* THE 3D POPUP MODAL */
#previewModal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
}

.modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* THE VIRTUAL BOOK */
#book-container {
    perspective: 2000px;
    width: 350px;  /* Size of a single printed page */
    height: 500px;
}

#zine-book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.modal-controls {
    display: flex;
    gap: 15px;
}

.modal-controls button {
    padding: 10px 25px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
}

/* --- HELP MODAL STYLES --- */
#helpModal {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.help-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    max-width: 450px;
    width: 90%;
    text-align: left;
    box-shadow: 0 4px 25px rgba(0,0,0,0.5);
    color: #333;
}

.help-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    max-width: 550px; /* Made slightly wider */
    width: 90%;
    text-align: left;
    box-shadow: 0 4px 25px rgba(0,0,0,0.5);
    color: #333;
}

.help-text {
    max-height: 60vh; /* Prevents it from being taller than the screen */
    overflow-y: auto; /* Adds a scrollbar if needed */
    padding-right: 15px; /* Keeps text away from the scrollbar */
    margin-bottom: 20px;
}

.help-text p {
    margin-top: 5px;
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 14px;
}

.creator-credit {
    margin-top: auto; /* Pushes the credit to the bottom of the sidebar */
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.creator-credit .name {
    font-size: 10px;
    color: #999;
    letter-spacing: 2px; /* Gives it that premium Art History feel */
    font-weight: 700;
}

.creator-credit .divider {
    width: 20px;
    height: 1px;
    background: #ddd;
    margin: 4px 0;
}

.creator-credit .insta-link {
    font-size: 11px;
    color: #2196f3;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.creator-credit .insta-link:hover {
    opacity: 0.7;
}