:root {
    --primary: #1a5f7a;
    --secondary: #c9a227;
    --bg-dark: #0d1b2a;
    --bg-card: #1b2838;
    --text: #e8e8e8;
    --text-muted: #8892a0;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
}

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

body {
    font-family: 'Noto Sans TC', -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1b2838 100%);
    color: var(--text);
    min-height: 100vh;
    user-select: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

header {
    text-align: center;
    padding: 15px 0;
}

header h1 {
    font-size: 1.8rem;
    background: linear-gradient(90deg, var(--secondary), #f0d78c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.main-layout {
    display: grid;
    grid-template-columns: 180px 1fr 260px;
    gap: 15px;
    margin-top: 15px;
}

/* Toolbox */
.toolbox {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.toolbox h3 {
    color: var(--secondary);
    font-size: 0.8rem;
    margin: 12px 0 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #3a4a5a;
}

.toolbox h3:first-child {
    margin-top: 0;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    margin-bottom: 5px;
    background: #243447;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.tool-item:hover {
    background: #2d4a5f;
    transform: translateX(2px);
}

.tool-item .icon {
    font-size: 1.1rem;
}

.tool-item.person {
    border-left: 3px solid #4a9fdf;
    background: linear-gradient(90deg, rgba(74, 159, 223, 0.1), transparent);
}

.tool-item.room {
    border-left: 3px solid #9f4adf;
}

.tool-item.facility {
    border-left: 3px solid #df9f4a;
}

/* Canvas Area */
.canvas-wrapper {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    position: relative;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.canvas-header h3 {
    color: var(--secondary);
    font-size: 0.85rem;
}

.canvas-actions button {
    padding: 5px 10px;
    margin-left: 6px;
    border: 1px solid #3a4a5a;
    border-radius: 5px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.75rem;
}

.canvas-actions button:hover {
    border-color: var(--secondary);
}

#floorCanvas {
    width: 100%;
    height: 550px;
    background:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        #0a1218;
    background-size: 20px 20px;
    border-radius: 8px;
    cursor: default;
}

.compass {
    position: absolute;
    top: 50px;
    right: 22px;
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    border: 2px solid #5a6a7a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: grab;
    transition: border-color 0.2s;
    user-select: none;
}

.compass:hover {
    border-color: var(--secondary);
}

.compass:active {
    cursor: grabbing;
}

.compass-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.1s ease-out;
}

.compass-n {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--danger);
    font-weight: bold;
    font-size: 0.9rem;
}

.compass-s {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--secondary);
}

.compass-e {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-w {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-hint {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Output Panel */
.output-panel {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.output-panel h3 {
    color: var(--secondary);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.config-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
    max-height: 250px;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background: #243447;
    border-radius: 5px;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.config-item .dir {
    color: var(--secondary);
    font-weight: bold;
}

.generate-btn {
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--primary), #2d8eb4);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(26, 95, 122, 0.4);
}

.prompt-output {
    margin-top: 10px;
    padding: 10px;
    background: #0d1520;
    border-radius: 6px;
    font-size: 0.7rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    display: none;
}

.prompt-output.show {
    display: block;
}

.copy-btn {
    margin-top: 8px;
    padding: 8px;
    border: 2px solid var(--success);
    border-radius: 6px;
    background: transparent;
    color: var(--success);
    cursor: pointer;
    font-size: 0.8rem;
    display: none;
}

.copy-btn.show {
    display: block;
}

.copy-btn:hover {
    background: var(--success);
    color: var(--bg-dark);
}

.hint {
    margin-top: 10px;
    padding: 8px;
    background: rgba(201, 162, 39, 0.1);
    border-radius: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
}

footer {
    text-align: center;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

/* Animations */
@keyframes bounceBack {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.8);
    }

    100% {
        transform: scale(1);
    }
}

.bounce-back {
    animation: bounceBack 0.3s ease;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

@media (max-width: 1000px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .toolbox {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        max-height: none;
    }

    .toolbox h3 {
        width: 100%;
        margin: 8px 0 5px 0;
    }

    .tool-item {
        margin-bottom: 0;
    }
}