/* ============================================
   Isometric Room Builder — Styles
   Pixel art pastel theme
   ============================================ */

:root {
    --bg: #F4F0EB;
    --bg-sidebar: #FEFCF9;
    --bg-card: #FFFFFF;
    --surface: #EDE8E1;
    --surface-hover: #E2DCD4;
    --primary: #7C6EAF;
    --primary-light: #9B8FCC;
    --accent: #E8937A;
    --accent-light: #F0AB96;
    --success: #7BBF82;
    --danger: #E87070;
    --text: #3A3440;
    --text-secondary: #6B6370;
    --text-muted: #9E97A5;
    --border: #E0D9D0;
    --border-hover: rgba(124, 110, 175, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 50;
    position: relative;
}

.header-inner {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.25rem;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(124, 110, 175, 0.3);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 6px rgba(232, 147, 122, 0.3);
}

.btn-accent:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--surface);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-icon {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 0.375rem;
    width: 32px;
    height: 32px;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
}

.btn-danger {
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(232, 112, 112, 0.1);
}

/* --- App Layout --- */
.app-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: calc(100vh - 52px);
}

/* --- Sidebar --- */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 0.75rem;
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Room controls */
.room-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.room-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.room-controls input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--surface);
    border-radius: 2px;
    outline: none;
}

.room-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.room-controls span {
    width: 16px;
    text-align: right;
    font-weight: 600;
    font-size: 0.75rem;
}

/* Texture grid */
.texture-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.375rem;
}

.texture-swatch {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.texture-swatch.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(124, 110, 175, 0.3);
}

.texture-swatch:hover {
    transform: scale(1.05);
}

.texture-swatch .texture-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.55rem;
    text-align: center;
    padding: 1px;
}

/* Furniture grid */
.furniture-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
}

.furniture-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.furniture-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.furniture-btn.active {
    border-color: var(--primary);
    background: rgba(124, 110, 175, 0.08);
}

.furniture-btn .emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.furniture-btn .label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Color palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.color-swatch.active {
    border-color: var(--text);
    transform: scale(1.15);
}

.color-swatch:hover {
    transform: scale(1.1);
}

/* Item controls */
.item-controls {
    display: flex;
    gap: 0.375rem;
}

/* --- Canvas Area --- */
.canvas-area {
    position: relative;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-wrapper {
    position: relative;
    cursor: crosshair;
}

#roomCanvas {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: #E8E2DA;
}

.zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--bg-card);
    padding: 0.375rem 0.625rem;
    border-radius: 99px;
    box-shadow: var(--shadow);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 0.8rem;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        display: flex;
        overflow-x: auto;
        gap: 1rem;
        padding: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-section {
        min-width: 180px;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .header-actions {
        flex-wrap: wrap;
    }
}