:root {
    --bg-color: #1e1e1e;
    --sidebar-bg: #252526;
    --text-color: #cccccc;
    --accent-color: #007acc;
    --border-color: #3e3e42;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 220px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    user-select: none;
    overflow: hidden; /* Sidebar itself doesn't scroll */
}

.sidebar-header {
    padding: 15px 15px 0 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.category-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
    background: #333;
    border-radius: 10px;
    cursor: pointer;
    color: #888;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.category-tag:hover {
    background: #444;
    color: #ccc;
}

.category-tag.active {
    background: var(--accent-color);
    color: #fff;
    border-color: #fff;
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-footer {
    padding: 10px 15px;
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.1);
}

#app-version {
    font-size: 0.7rem;
    color: #555;
    text-align: center;
    font-family: monospace;
}

#left-sidebar {
    border-right: 1px solid var(--border-color);
}

#right-sidebar {
    border-left: 1px solid var(--border-color);
    padding: 15px; /* Keep padding for right sidebar for now */
    overflow-y: auto;
}

.sidebar h2, .sidebar h3 {
    font-size: 1.0rem;
    margin: 0 0 10px 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
    color: #fff;
}

.component-palette {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.component-item {
    background-color: #333;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.2s;
}

.component-item:hover {
    background-color: #3e3e42;
}

.component-item .icon {
    width: 60px;
    height: 60px;
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #222;
    border-radius: 4px;
    overflow: hidden;
}

.component-item .icon svg {
    max-width: 90%;
    max-height: 90%;
}

.component-item span {
    font-size: 0.8rem;
    text-align: center;
}

.color-palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.color-swatch {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 5px rgba(255,255,255,0.5);
}

#workspace {
    flex-grow: 1;
    position: relative;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    touch-action: none; /* Prevent browser zoom/scroll */
}

#hover-info {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: #00aaff;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #00aaff;
    pointer-events: none;
    font-size: 0.85rem;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    white-space: nowrap;
}

#hover-info strong { color: #fff; }
#hover-info span { color: #ffd700; margin-left: 5px; }

#view-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 2.5rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.15);
    pointer-events: none;
    text-transform: uppercase;
    user-select: none;
    z-index: 10;
}

svg {
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
}

.hole { cursor: pointer; transition: fill 0.1s; }
.hole:hover { fill: #ffffff; opacity: 0.5; }

.wire { pointer-events: stroke; cursor: pointer; }
.wire:hover { stroke-width: 6px; filter: drop-shadow(0 0 2px white); }
.wire.selected { stroke-dasharray: 5,5; filter: drop-shadow(0 0 4px #00aaff); }

.component { cursor: grab; transition: filter 0.2s; }
.component.selected rect { stroke: #00aaff; stroke-width: 2px; filter: drop-shadow(0 0 4px #00aaff); }
.component.locked { cursor: not-allowed; }
.component.locked rect { stroke: #ff4444; }

#selection-panel {
    display: none;
    background: #2d2d30;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #007acc;
}

#selection-panel.visible { display: block; }

.btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: #444;
    color: white;
    font-size: 0.85rem;
}

.btn:hover { background: #555; }
.btn-danger { background: #d32f2f; }
.btn-danger:hover { background: #b71c1c; }
.btn-primary { background: #007acc; }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: var(--sidebar-bg);
    margin: 10% auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    width: 50%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: #fff;
}

.close-modal {
    color: #888;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover {
    color: #fff;
}

#bom-list {
    margin-top: 20px;
    font-family: monospace;
    line-height: 1.6;
}

.bom-item {
    padding: 8px 0;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
}

.bom-item .labels {
    color: #00aaff;
    font-size: 0.9rem;
}

#instructions {
    margin-top: auto;
    font-size: 0.8rem;
    color: #888;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

#instructions p { margin: 4px 0; }

/* Mobile Mode Styles */
body.mobile-mode #app {
    flex-direction: column;
}

body.mobile-mode #left-sidebar,
body.mobile-mode #right-sidebar {
    display: none !important;
}

body.mobile-mode #workspace {
    width: 100%;
    height: 100%;
    flex-grow: 1;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

#mobile-header {
    display: none;
    width: 100%;
    padding: 12px 15px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
    text-align: center;
    z-index: 20;
    flex-shrink: 0;
}

body.mobile-mode #mobile-header {
    display: block;
}

#mobile-header h1 {
    margin: 0;
    font-size: 1.1rem;
    color: #fff;
    line-height: 1.2;
}

#mobile-header h1 span {
    font-size: 0.65rem;
    font-family: monospace;
    color: #666;
    font-weight: normal;
    margin-left: 5px;
}

.edit-notice {
    margin: 2px 0 0 0;
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-instructions {
    margin-top: 10px;
    font-size: 0.65rem;
    color: #555;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(255,255,255,0.03);
    padding-top: 8px;
}

body.mobile-mode #board-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

body.mobile-mode #view-overlay {
    display: none;
}

body.mobile-mode #hover-info {
    display: none !important; /* Disable standard hover tooltip in mobile */
}

/* Mobile Component Modal */
.pin-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.pin-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
}

.pin-row:last-child {
    border-bottom: none;
}

.pin-num {
    color: #888;
}

.pin-name {
    color: #fff;
    font-weight: bold;
}
