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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* === APP CONTAINER === */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === NAV MENU (like Claude.ai) === */
.nav-menu {
    width: 240px;
    min-width: 240px;
    background: #0d0d1a;
    border-right: 1px solid #2d2d5a;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

.nav-menu.collapsed {
    width: 60px;
    min-width: 60px;
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #2d2d5a;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.logo-icon {
    font-size: 20px;
    color: #6366f1;
    flex-shrink: 0;
}

.logo-text {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.nav-menu.collapsed .logo-text {
    opacity: 0;
    width: 0;
}

.nav-toggle {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nav-toggle:hover {
    background: #1e1e3a;
    color: #fff;
}

.nav-menu.collapsed .nav-toggle svg {
    transform: rotate(180deg);
}

.nav-items {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: #888;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: #1e1e3a;
    color: #fff;
}

.nav-item.active {
    background: #252550;
    color: #fff;
}

.nav-item.active .nav-icon {
    color: #6366f1;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-label {
    font-size: 14px;
    transition: opacity 0.2s;
}

.nav-menu.collapsed .nav-label {
    opacity: 0;
    width: 0;
}

.nav-footer {
    padding: 12px 8px;
    border-top: 1px solid #2d2d5a;
}

.nav-user {
    gap: 10px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.view-container {
    display: none;
    height: 100%;
    overflow: hidden;
}

.view-container.active {
    display: flex;
}

/* === PLACEHOLDER VIEWS === */
.placeholder-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #555;
    gap: 16px;
}

.placeholder-view svg {
    opacity: 0.3;
}

.placeholder-view h2 {
    font-size: 24px;
    font-weight: 600;
    color: #888;
}

.placeholder-view p {
    font-size: 14px;
    color: #666;
}

.coming-soon {
    padding: 6px 16px;
    background: #252550;
    border-radius: 20px;
    font-size: 12px;
    color: #6366f1;
    margin-top: 8px;
}

/* === EDA APP === */
.app { 
    display: flex; 
    height: 100%;
    width: 100%;
}

/* === SIDEBAR === */
.sidebar {
    width: 250px;
    background: #16162a;
    border-right: 1px solid #2d2d5a;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 14px;
    border-bottom: 1px solid #2d2d5a;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: #7777aa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.search-box {
    width: 100%;
    padding: 8px 10px;
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
}
.search-box:focus { outline: none; border-color: #4444aa; }

.signal-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.signal-list::-webkit-scrollbar { width: 5px; }
.signal-list::-webkit-scrollbar-thumb { background: #3d3d6a; border-radius: 3px; }

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid #2d2d5a;
    font-size: 10px;
    color: #666;
    background: rgba(0,0,0,0.2);
}
.sidebar-footer span { color: #888; }

.signal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: #1e1e3a;
    border: 1px solid transparent;
    border-left: 3px solid #555;
    border-radius: 4px;
    cursor: grab;
    transition: all 0.15s;
    font-size: 12px;
    min-width: 0; /* Important pour le truncate */
}
.signal-item:hover { background: #252550; border-color: #3d3d6a; }
.signal-item.dragging { opacity: 0.4; }
.signal-item.active { border-left-color: #00cc66; }
.signal-item.active .signal-dot {
    background: #00cc66;
    box-shadow: 0 0 6px #00cc66;
}

.signal-dot {
    width: 8px; 
    height: 8px;
    min-width: 8px; /* Empêche le rétrécissement */
    border-radius: 50%;
    background: #555;
    transition: all 0.15s;
    flex-shrink: 0; /* Ne jamais rétrécir */
}

.signal-name { 
    flex: 1;
    min-width: 0; /* Permet le truncate */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signal-unit { 
    color: #666; 
    font-size: 10px;
    flex-shrink: 0; /* Ne jamais rétrécir */
    min-width: 30px;
    text-align: right;
}

/* === MAIN === */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    padding: 10px 16px;
    background: #16162a;
    border-bottom: 1px solid #2d2d5a;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-title { font-size: 16px; font-weight: 600; }

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.toolbar-group label { font-size: 11px; color: #888; }

/* Source selector */
#sourceSelector {
    padding: 6px 10px;
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
    cursor: pointer;
    min-width: 150px;
}
#sourceSelector:focus { outline: none; border-color: #4444aa; }
#sourceSelector:hover { background: #252550; }
#sourceSelector option { background: #1e1e3a; color: #e0e0e0; }
#sourceSelector option:disabled { color: #666; }

button {
    background: #3d3d7a;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
button:hover { background: #4d4d9a; }
button:disabled { background: #2d2d4a; color: #666; cursor: default; }

input[type="number"] {
    width: 60px;
    padding: 5px 8px;
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
}

/* === PLOTS === */
.plots-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px 16px;
}

.plots-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.plot-container {
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    min-height: 100px;
    overflow: hidden;
}
.plot-container.drop-target {
    border-color: #5555cc;
    box-shadow: 0 0 10px rgba(85, 85, 204, 0.3);
}

.plot-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 10px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid #2d2d5a;
    border-radius: 6px 6px 0 0;
    flex-shrink: 0;
}

.plot-main {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.plot-body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.plot-body .chart {
    width: 100%;
    height: 100%;
}

.plot-legend {
    width: 150px;
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
    border-left: 1px solid #2d2d5a;
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.plot-legend::-webkit-scrollbar { width: 4px; }
.plot-legend::-webkit-scrollbar-thumb { background: #3d3d6a; border-radius: 2px; }

.legend-item {
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    font-size: 10px;
    overflow: hidden;
}

.legend-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    cursor: pointer;
    transition: background 0.1s;
}

.legend-item-header:hover {
    background: rgba(255,255,255,0.05);
}

.legend-color-btn {
    width: 16px;
    height: 10px;
    border-radius: 2px;
    border: none;
    cursor: pointer;
    padding: 0;
}

.legend-color-btn::-webkit-color-swatch-wrapper { padding: 0; }
.legend-color-btn::-webkit-color-swatch { border: none; border-radius: 2px; }

.legend-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #ccc;
}

.legend-toggle {
    opacity: 0.4;
    font-size: 8px;
    transition: transform 0.2s;
}

.legend-item.expanded .legend-toggle {
    transform: rotate(180deg);
}

.legend-remove {
    opacity: 0;
    cursor: pointer;
    color: #666;
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.1s;
}

.legend-item-header:hover .legend-remove {
    opacity: 1;
}

.legend-remove:hover {
    color: #ff6666;
}

.legend-controls {
    display: none;
    padding: 6px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid #2d2d5a;
}

.legend-item.expanded .legend-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-control-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-control-row label {
    color: #888;
    font-size: 9px;
    min-width: 35px;
}

.legend-control-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: #2d2d5a;
    border-radius: 2px;
    outline: none;
}

.legend-control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: #5555cc;
    border-radius: 50%;
    cursor: pointer;
}

.legend-control-row select {
    flex: 1;
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    color: #ccc;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
}

.legend-control-row select:focus {
    outline: none;
    border-color: #5555cc;
}

.legend-width-value {
    color: #aaa;
    font-size: 9px;
    min-width: 20px;
    text-align: right;
}

.plot-delete {
    background: transparent;
    border: 1px solid #553333;
    color: #aa6666;
    padding: 2px 8px;
    font-size: 11px;
}
.plot-delete:hover { background: #332222; }

.plot-stats {
    padding: 2px 10px;
    font-size: 9px;
    color: #555;
    font-family: monospace;
    flex-shrink: 0;
    border-top: 1px solid #2d2d5a;
    background: rgba(0,0,0,0.2);
}

/* Splitter */
.splitter {
    height: 8px;
    background: transparent;
    cursor: row-resize;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.splitter:hover, .splitter.active {
    background: rgba(85, 85, 204, 0.2);
}

.splitter::after {
    content: '';
    width: 40px;
    height: 3px;
    background: #3d3d6a;
    border-radius: 2px;
}

.splitter:hover::after, .splitter.active::after {
    background: #5555cc;
}

/* Drop zone at bottom */
.drop-zone {
    border: 2px dashed #3d3d6a;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    color: #555;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 8px;
}
.drop-zone.active { border-color: #5555cc; background: rgba(85,85,204,0.1); color: #8888cc; }

.empty-plot {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    background: #1e1e3a;
    border: 1px solid #2d2d5a;
    border-radius: 6px;
}

/* Cursors */
.cursor-line {
    position: absolute;
    top: 0; bottom: 0;
    width: 6px;
    margin-left: -3px;
    pointer-events: auto;
    z-index: 50;
    cursor: ew-resize;
}
.cursor-line::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--cursor-color);
}
.cursor-line:hover::after {
    width: 4px;
    left: 1px;
}
.cursor-1 { --cursor-color: rgba(0, 255, 100, 0.7); }
.cursor-2 { --cursor-color: rgba(255, 100, 150, 0.7); }
.cursor-line.dragging::after {
    width: 4px;
    left: 1px;
}

.cursor-label {
    position: absolute;
    font-size: 10px;
    font-family: monospace;
    padding: 2px 5px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 60;
    white-space: nowrap;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--sig-color);
    color: var(--sig-color);
}

.cursor-info {
    padding: 6px 16px;
    background: #1a1a30;
    border-bottom: 1px solid #2d2d5a;
    font-size: 11px;
    display: none;
    gap: 20px;
}
.cursor-info.visible { display: flex; }
.cursor-info .c1 { color: #00ff66; }
.cursor-info .c2 { color: #ff6699; }
.cursor-info .delta { color: #ffaa44; }