/* Styles for TTRPG Map Easy */
body {
    font-family: sans-serif;
    background-color: #f0f0f0;
    color: #333;
    margin: 0;
}

.main-container {
    padding: 10px;
}

.main-layout {
    display: flex;
    gap: 20px;
}

.left-panel {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.right-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.table-controls select, .table-controls input {
    width: 100%;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.table-controls .table-buttons {
    display: flex;
    justify-content: space-between;
    gap: 5px; /* Tighter gap for more buttons */
}

.table-controls button {
    flex-grow: 1;
}

.controls {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 15px; /* Reduced margin */
}

.controls h3 {
    margin-top: 0;
}

#map-container-wrapper {
    position: relative;
    width: 100%;
    height: 600px; /* Default height */
    border: 2px solid #ccc;
    background-color: #87CEEB; /* Default sky color */
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#scene {
    width: 100%;
    height: 100%;
    perspective: 1000px;
    perspective-origin: 50% 50%;
    /* We want to make sure it doesn't block UI */
}

#camera {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(-800px) rotateX(0deg); /* Default camera */
    transition: transform 0.1s linear; /* Smooth mouse tracking */
}

#world {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
}

#ground {
    position: absolute;
    transform: translate(-50%, -50%) rotateX(90deg);
    background-color: #8FBC8F; /* Default ground color */
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    transform-style: preserve-3d;
}

/* Tokens in 3D */
.token-3d {
    position: absolute;
    transform-style: preserve-3d;
    transform-origin: 50% 100%;
    cursor: grab;
    /* left and top will be set by JS on the #ground */
}
.token-3d:active {
    cursor: grabbing;
}

.token-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let token-3d handle events */
}

.token-shadow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 50% 100%;
    z-index: -1;
    pointer-events: none;
    /* JS sets background-image, filter, skew, etc. */
}

.highlight-3d > .token-layer {
    filter: drop-shadow(0 0 5px yellow) drop-shadow(0 0 10px yellow);
}

#token-controls .token-dims {
    margin: 10px 0;
}

#token-controls input[type="number"] {
    width: 50px;
}

#token-preview {
    max-width: 50px;
    max-height: 50px;
    border: 1px solid #ccc;
    margin-top: 5px;
    vertical-align: middle;
    margin-left: 10px;
}

#token-buttons button {
    margin-top: 10px;
}


#token-library {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 20px;
    min-height: 100px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: flex-start;
}

.token-in-library {
    width: 60px;
    height: 60px;
    border: 2px dashed #ccc;
    cursor: pointer; /* Changed to pointer for editing */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative; /* For potential future UI elements on the token */
}

.token-in-library:active {
    cursor: grabbing;
    border-style: solid;
}

#on-map-token-list {
    max-height: 300px;
    overflow-y: auto;
}

.on-map-token-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 5px;
    cursor: pointer;
}

.on-map-token-item:hover {
    background-color: #f5f5f5;
}

.on-map-token-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.on-map-token-item .info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.on-map-token-item .info span {
    display: block;
    font-size: 0.8em;
    color: #666;
    white-space: nowrap;
}

.on-map-token-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}
.on-map-token-controls input[type="range"] {
    width: 60px;
    margin: 0;
}
.on-map-token-controls button {
    padding: 2px 5px;
    font-size: 0.8em;
    width: 100%;
}

.highlight {
    outline: 3px solid rgba(255, 255, 0, 0.9) !important;
    outline-offset: 2px;
}

#map-ui-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.map-ui-btn {
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.5em;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.map-ui-btn:hover {
    background-color: white;
}

.grid-controls-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

/* Fullscreen and Hidden Panel States */
.main-layout.fullscreen .left-panel {
    display: none;
}

.main-layout.fullscreen .right-panel {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    z-index: 100;
}
.main-layout.fullscreen #map-container-wrapper {
    width: 100%;
    height: 100%;
    border: none;
}
.main-layout.left-panel-hidden .left-panel {
    display: none;
}