:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background gradient aesthetic */
body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo svg {
    color: var(--accent);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
}

input[type="file"]::file-selector-button {
    background-color: #3b82f6;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

input[type="file"]::file-selector-button:hover {
    background-color: #2563eb;
}

#layout-orientation {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 0.5rem 1rem;
    border: 1px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3), 0 2px 4px -1px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4), 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.main-content {
    flex: 1;
    position: relative;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.drop-zone {
    flex: 1;
    border: 2px dashed var(--glass-border);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.3);
    transition: all 0.3s ease;
}

.drop-zone.drag-active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.drop-zone-content {
    text-align: center;
    color: var(--text-secondary);
}

.drop-zone-content svg {
    margin-bottom: 1rem;
    color: var(--accent);
    opacity: 0.8;
}

.drop-zone-content h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.diagram-container {
    flex: 1;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}

.hidden {
    display: none !important;
}

/* SVG Styling */
#matv-diagram {
    cursor: grab;
    width: 100%;
    height: 100%;
}

#matv-diagram:active {
    cursor: grabbing;
}

.device-shape {
    fill: #1e293b;
    stroke: #475569;
    stroke-width: 2;
    transition: all 0.2s ease;
}

.device-group:hover .device-shape {
    stroke: var(--accent);
    fill: #27354f;
}

.device-symbol {
    stroke: var(--text-primary);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.device-label {
    fill: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 12px;
    user-select: none;
    pointer-events: none;
}

.connection-line {
    stroke: #94a3b8;
    stroke-width: 2;
    fill: none;
    transition: stroke 0.2s ease;
}

.connection-line:hover {
    stroke: var(--accent);
    stroke-width: 3;
}

/* Layers Panel */
.glass-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 1rem;
    color: var(--text-primary);
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.glass-panel h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.layer-toggle input {
    cursor: pointer;
}

/* Signal Data Text */
.sim-data-text {
    font-size: 10px;
    font-family: var(--font-family);
    fill: #34d399; /* emerald-400 */
    pointer-events: none;
    user-select: none;
}

.issue-text {
    font-size: 10px;
    font-weight: bold;
    font-family: var(--font-family);
    fill: #ef4444; /* red-500 */
    pointer-events: none;
    user-select: none;
}

.cable-label {
    font-size: 9px;
    font-family: var(--font-family);
    fill: var(--text-secondary);
    pointer-events: none;
    user-select: none;
}

.layer-hidden {
    display: none !important;
}

/* Drawing Toolbar */
.drawing-toolbar {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 12px;
    border-right: 1px solid #334155;
}

.toolbar-group:last-child {
    border-right: none;
    padding-right: 0;
}

.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #cbd5e1;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.tool-btn:hover {
    background: #334155;
}

.tool-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #2563eb;
}

#draw-color {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: none;
    cursor: pointer;
}

#line-end {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Drawing Elements */
.drawing-element {
    cursor: pointer;
    transition: opacity 0.2s;
}

.drawing-element:hover {
    opacity: 0.8;
}

.drawing-element.selected {
    outline: 2px dashed #3b82f6;
    outline-offset: 4px;
}

/* Keep lines and markers inheriting stroke color properly */
marker path, marker circle, marker rect {
    fill: context-stroke;
}

.style-col {
    display: flex;
    flex-direction: column;
    font-size: 10px;
    color: #94a3b8;
    gap: 2px;
}
.style-col label {
    text-transform: uppercase;
    font-weight: 600;
}
.check-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px !important;
    text-transform: none !important;
}
.tool-btn.small {
    font-size: 12px;
    padding: 2px 6px;
    font-weight: bold;
}
