/* Essential canvas and positioning that can't be replaced with Tailwind */
html,
body {
    touch-action: manipulation;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: Arial, sans-serif;
    height: 100vh;
    width: 100vw;
}

#layoutCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: crosshair;
    touch-action: none;
    display: block;
}

#layoutCanvas.eraser-cursor-active {
    cursor: none !important;
}

.eraser-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 80;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.45);
    transform: translate(-3px, -5px) rotate(-12deg);
    opacity: 0;
    transition: opacity 0.08s linear;
}

.eraser-cursor.visible {
    opacity: 1;
}

.eraser-cursor .material-symbols-outlined {
    font-size: 26px;
    line-height: 1;
    font-variation-settings:
        'FILL' 1,
        'wght' 500,
        'GRAD' 0,
        'opsz' 24;
}

.shortcut-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 70;
    pointer-events: none;
    background: rgba(17, 24, 39, 0.92);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.45rem 0.65rem;
    border-radius: 0.375rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.shortcut-toast.visible {
    opacity: 1;
}

.shortcut-button {
    position: relative;
    padding-right: 1.45rem;
}

.shortcut-hint {
    position: absolute;
    right: 0.35rem;
    bottom: 0.2rem;
    font-size: 0.6rem;
    line-height: 1;
    font-weight: 700;
    opacity: 0.8;
    color: rgba(255, 255, 255, 0.9);
    pointer-events: none;
}

.bt-bubble.selected {
    background-color: #a3e635;
}

.city-context-menu {
    position: fixed;
    z-index: 100;
    display: none;
    min-width: 8.5rem;
    padding: 0.25rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.city-context-menu.visible {
    display: block;
}

.city-context-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 0.45rem;
    padding: 0.4rem 0.55rem;
    border-radius: 0.25rem;
    color: #1f2937;
    font-size: 0.75rem;
    line-height: 1.1;
    text-align: left;
}

.city-context-menu button:hover,
.city-context-menu button:focus-visible {
    background: #f3f4f6;
    outline: none;
}

.city-context-menu__delete {
    color: #dc2626 !important;
}

.city-context-menu__divider {
    height: 1px;
    margin: 0.25rem 0;
    background: #e5e7eb;
}

.city-context-menu__globe-control {
    position: relative;
}

.city-context-menu__globe-trigger .material-symbols-outlined,
.city-context-menu__globe .material-symbols-outlined {
    font-size: 0.9rem;
    line-height: 1;
}

.city-context-menu__chevron {
    margin-left: auto;
    font-size: 1rem;
    line-height: 0.8;
}

.city-context-menu__submenu {
    position: absolute;
    z-index: 101;
    top: -0.25rem;
    /* Touches the parent: any gap here breaks the hover chain on the way to the submenu. */
    left: 100%;
    display: none;
    min-width: 4.25rem;
    padding: 0.25rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.city-context-menu__globe-control:hover .city-context-menu__submenu,
.city-context-menu__globe-control.expanded .city-context-menu__submenu {
    display: block;
}

.city-context-menu__globe.selected,
.city-context-menu__globe.selected:hover,
.city-context-menu__globe.selected:focus-visible {
    color: #fff;
    background: #eab308;
}

/* Animation for entity placement */
@keyframes entityPlace {
    0% { transform: scale(0.5); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.entity-placed {
    animation: entityPlace 0.3s ease-out;
}

/* Custom scrollbar */
#cityList {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

#cityList::-webkit-scrollbar {
    width: 6px;
}

#cityList::-webkit-scrollbar-track {
    background: transparent;
}

#cityList::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

#cityList::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.8);
}

/* Button hover effects */
.floating-panel button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.floating-panel button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Toolbar button original colors */
#toolbar-controls button[data-type="select"] {
  background-color: #6b7280;
}

#toolbar-controls button[data-type="move"] {
  background-color: #8b5cf6;
}

#toolbar-controls button#deleteButton {
  background-color: #ef4444;
}

/* Selected state */
#toolbar-controls button.bg-yellow-500,
#toolbar-buildings button.bg-yellow-500 {
  background-color: #eab308;
}

/* Prevent text selection while resizing */
#sidebarResizer {
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent text selection while resizing */
body.resizing {
    cursor: ew-resize !important;
    user-select: none;
    -webkit-user-select: none;
}

/* Bottom Section Styles */
#helpSection,
#actionsSection {
    max-height: 70vh;
    overflow-y: auto;
    transform-origin: top;
    transition: max-height 0.2s ease-out;
}

#helpSection.hidden,
#actionsSection.hidden {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

/* Mobile Panel Styles */
.mobile-panel {
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background-color: white;
    transform: translateY(100%);
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    z-index: 40;
    max-height: 80vh;
    overflow-y: auto;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    visibility: hidden;
    opacity: 0;
}

.mobile-panel.active {
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
}

@media (min-width: 768px) {
    #mobileNav, #mobilePanels {
        display: none !important;
    }
}

@media (max-width: 767px) {
    #rightSidebar {
        display: none;
    }
    #topControls {
        margin-left: 0;
        margin-right: 0 !important;
    }
    #toolbar-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    #toolbar-controls button {
        flex: 0 0 auto;
        min-width: max-content;
        padding: 0.5rem 0.75rem;
        line-height: 1.25rem;
    }
}
