/* 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;
}

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

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

.session-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 {
    position: relative;
    width: 800px; /* Default width */
    height: 600px; /* Default height */
    border: 2px solid #ccc;
    background-color: #fff;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1; /* Ensure canvas is above the parent's background */
}

.handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: #ff0000;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: grab;
    transform: translate(-50%, -50%); /* Center the handle on its coordinates */
    z-index: 10;
}

.handle:active {
    cursor: grabbing;
    background-color: rgba(255, 0, 0, 1);
}

#handle-tl {
    top: 0;
    left: 0;
}

#handle-tr {
    top: 0;
    right: 0;
    left: 100%; /* Use left for positioning to simplify JS logic */
}

#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 {
    width: 100%;
    height: 100%;
    border: none;
}
.main-layout.left-panel-hidden .left-panel {
    display: none;
}