/*
style.css
*/
:root {
    --primary-color: #6C63FF;
    --secondary-color: #FF6B6B;
    --accent-color: #4ECDC4;
    --dark-color: #292F36;
    --light-color: #F7FFF7;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
}

/* Fixed width main container */
.container {
    width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
}

.logo span.highlight {
    color: var(--secondary-color);
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 2rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--accent-color);
}

.logo img {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
    object-fit: contain;
    object-position: center;
    margin: 5px 0;
}

.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8A80FF 100%);
    color: white;
    padding: 3rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    background-color: var(--secondary-color);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.btn-outline {
    background: transparent;
    border: 2px solid white;
    margin-left: 1rem;
}

/* Tile Map Editor Specific Styles with Fixed Dimensions */
.tile-map-editor {
    width: 1240px; /* Container width - padding */
    margin: 0 auto;
}

.editor-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.editor-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 18px;
}

/* Fixed grid dimensions */
.grid {
    display: grid;
    grid-template-columns: 400px 800px;
    gap: 20px;
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.control-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #5A52D5;
}

select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

textarea {
    width: 100%;
    height: 300px;
    box-sizing: border-box;
}

.json-error {
    color: red;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
}

.update-notice {
    color: #4CAF50;
    font-size: 14px;
    margin-top: 5px;
    animation: fadeOut 2s forwards;
    animation-delay: 3s;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.preview {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: auto;
    min-height: 300px;
    background-color: #f9f9f9;
}

/* Fixed size tileset container */
.tileset-canvas-container {
    width: 360px; /* 400px section - 40px padding */
    height: 450px;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    position: relative;
}

/* Custom scrollbar styling */
.tileset-canvas-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.tileset-canvas-container::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.tileset-canvas-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 6px;
    border: 3px solid #f0f0f0;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0.8;
    pointer-events: none;
    z-index: 100;
}

/* Fixed size map preview */
.map-canvas-container {
    width: 760px; /* 800px section - 40px padding */
    height: 560px;
    overflow: auto;
}

/* Tileset preview specific styling */
#tilesetPreview {
    display: block; /* Change to block to ensure proper scrolling */
    min-width: min-content; /* Ensure content doesn't shrink below its natural size */
    padding: 10px;
}

#tilesetPreview > div {
    display: flex;
}

.tileset-item {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid #444;
    width: 32px;
    height: 32px;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
}

.tileset-item.selected {
    border: 3px solid var(--secondary-color);
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.7);
    transform: scale(1.05);
    z-index: 10;
}

.tile-selection-indicator {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid var(--secondary-color);
    display: none;
}

.tileset-item.selected .tile-selection-indicator {
    display: block;
}

#editModeStatus {
    color: var(--secondary-color);
    font-weight: bold;
}

#selectedTileInfo {
    padding: 5px 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
    display: inline-block;
}

.tile-value {
    position: absolute;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 4px;
    font-size: 12px;
    pointer-events: none;
}

/* Bottom metadata grid */
.metadata-grid {
    display: grid;
    grid-template-columns: 595px 595px; /* (1240px - 50px) ÷ 2 */
    gap: 50px;
}

/* Tooltip styling */
#tilesetTooltip {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0,0,0,0.8);
    color: white;
    padding: 15px;
    border-radius: 8px;
    z-index: 1000;
    width: 200px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#tilesetTooltip.visible {
    display: block;
    opacity: 1;
    visibility: visible;
}

#tilesetTooltip::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px;
    border-style: solid;
    border-color: rgba(0,0,0,0.8) transparent transparent transparent;
}

/* Selection overlay styling */
#selection-overlay {
    pointer-events: none;
    transition: border-color 0.3s ease;
    position: absolute;
    border: 2px dashed var(--secondary-color);
    background-color: rgba(255, 107, 107, 0.2);
    z-index: 100;
}

/* Hover effect on tiles */
.tileset-item:hover {
    outline: 1px solid var(--accent-color);
}

/* Styling for tiles that are within the current selection */
.tileset-item.in-selection {
    outline: 2px solid var(--secondary-color);
    position: relative;
    z-index: 5;
}

.tileset-item.in-selection::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 107, 107, 0.3);
    pointer-events: none;
}

/* Obstacle mode styles */
.toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    color: #555;
    transition: all 0.3s;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
}

.toggle-btn:hover {
    background-color: #e8e8e8;
}

.toggle-btn.active {
    background-color: rgba(80, 80, 80, 0.7);
    color: white;
    border-color: #666;
}

.toggle-btn.active:hover {
    background-color: rgba(90, 90, 90, 0.8);
}

.toggle-icon {
    font-size: 14px;
}

.mode-indicator {
    padding: 5px 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-weight: 500;
}

/* Collision mode overlay on map tiles */
.map-tile-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.map-tile-obstacle {
    background-color: rgba(0, 0, 0, 0.1);
    border: 2px dashed rgba(70, 70, 70, 0.6);
    box-shadow: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M1,1 L19,19 M19,1 L1,19" stroke="rgba(0,0,0,0.3)" stroke-width="1.5"/></svg>');
}

/* Collision mode active cursor */
.collision-mode-active canvas {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.93" y1="4.93" x2="19.07" y2="19.07"/></svg>'), auto;
}

/* Collision mode indicator */
.collision-mode-indicator {
    background-color: rgba(80, 80, 80, 0.7) !important;
    border: 1px solid rgba(50, 50, 50, 0.9);
}

/* Enhanced hover indicator styling */
.hover-indicator {
    position: absolute;
    pointer-events: none;
    z-index: 25;
    display: none;
    border: 2px solid var(--accent-color);
    background-color: rgba(78, 205, 196, 0.15);
    box-shadow: 0 0 8px rgba(78, 205, 196, 0.3);
    transition: all 0.2s ease;
    border-radius: 2px;
}

/* Style for when tile placement is valid or invalid */
.hover-indicator.valid {
    border-color: rgba(78, 205, 196, 0.8);
    background-color: rgba(78, 205, 196, 0.15);
}

.hover-indicator.invalid {
    border-color: rgba(255, 107, 107, 0.8);
    background-color: rgba(255, 107, 107, 0.15);
}

/* Multi-tile style improvements */
.multi-tile-indicator {
    display: grid;
    grid-template-columns: repeat(var(--columns, 1), 1fr);
    grid-template-rows: repeat(var(--rows, 1), 1fr);
    gap: 0;
}

.multi-tile-indicator-cell {
    background-color: rgba(78, 205, 196, 0.15);
    border: 1px solid rgba(78, 205, 196, 0.4);
}

/* Create a subtle shadow effect when hovering */
.hover-indicator.active {
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
    display: block;
}

/* Optional animated border effect */
@keyframes dashedBorder {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 100% 0;
    }
}

.hover-indicator.animated {
    background-image: linear-gradient(90deg, 
        var(--accent-color) 50%, 
        transparent 50%);
    background-size: 10px 1px;
    background-repeat: repeat-x;
    animation: dashedBorder 0.5s linear infinite;
}

/* WFC Button styles */
.wfc-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--primary-color);
    border: 1px solid #5A52D5;
    color: white;
    transition: all 0.3s;
    font-size: 14px;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    justify-content: center;
}

.wfc-btn:hover {
    background-color: #5A52D5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.wfc-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.wfc-btn.generating {
    background-color: #5A52D5;
    cursor: wait;
    opacity: 0.8;
}

.wfc-icon {
    font-size: 16px;
}

.wfc-status {
    margin-top: 8px;
    font-size: 14px;
    color: var(--primary-color);
    text-align: center;
    min-height: 20px;
    font-weight: 500;
}

/* WFC Generation Animation */
@keyframes wfcGenerating {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.wfc-generating {
    animation: wfcGenerating 1.5s infinite;
}

/* WFC Success/Error Messages */
.wfc-success {
    color: #4CAF50;
}

.wfc-error {
    color: var(--secondary-color);
}

/* Lock Mode Styles */
.lock-icon {
    font-size: 14px;
}

.regen-icon {
    font-size: 14px;
}

/* Locked Tile Styles */
.locked-tile-indicator {
    box-sizing: border-box;
    pointer-events: none;
    z-index: 20;
}

.lock-mode-active .map-canvas-container canvas {
    cursor: crosshair;
}

.lock-selection-box {
    position: absolute;
    border: 2px dashed #00ff00;
    background-color: rgba(0, 255, 0, 0.1);
    pointer-events: none;
    z-index: 15;
}

.lock-overlay {
    pointer-events: none;
    z-index: 15;
}

/* Info box and cards */
.info-box {
    background-color: #f5f5ff;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.info-section {
    margin: 40px 0;
    width: 1240px;
    margin-left: auto;
    margin-right: auto;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 380px);
    gap: 30px;
    justify-content: center;
}

.info-card {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.info-card:hover {
    transform: translateY(-5px);
}

.info-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Footer styles */
footer {
    background-color: var(--dark-color);
    color: white;
    padding: 3rem 0;
    margin-top: 3rem;
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.footer-column {
    flex: 1 1 250px;
    margin-bottom: 2rem;
}

.footer-column h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #444;
    margin-top: 2rem;
}

.file-upload {
    margin-bottom: 15px;
}

canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Responsive styles */
@media (max-width: 1300px) {
    .container,
    .tile-map-editor,
    .info-section {
        width: 100%;
        max-width: 1280px;
        padding: 0 15px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .tileset-canvas-container {
        width: 360px;
        margin: 0 auto;
    }
    
    .map-canvas-container {
        width: 100%;
        max-width: 760px;
        margin: 0 auto;
    }
    
    .metadata-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .info-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .tileset-canvas-container {
        width: 100%;
        max-width: 360px;
    }
    
    .metadata-grid {
        gap: 20px;
    }
}
