/* ========== RESET Y BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0a0a1a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

/* ========== LAYOUT PRINCIPAL ========== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* HEADER */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version {
    font-size: 0.7rem;
    background: #2a2a4a;
    padding: 2px 10px;
    border-radius: 12px;
    color: #888;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ========== BOTONES ========== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    background: #2a2a4a;
    color: #e0e0e0;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, #00b894, #00a381);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 8px 12px;
    font-size: 1.2rem;
}

/* ========== STATUS ========== */
.status-badge {
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    background: #ff4444;
    color: #fff;
}

.status-badge.connected {
    background: #44ff44;
    color: #000;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.status-dot.active {
    background: #44ff44;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========== MAIN CONTENT ========== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background: #111128;
    border-right: 1px solid #2a2a4a;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: #1a1a3e;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 0.85rem;
}

.ecu-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 8px 0;
}

.ecu-item {
    padding: 10px;
    background: #1a1a3e;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ecu-item:hover {
    background: #2a2a5e;
    transform: translateX(4px);
}

.ecu-item .ecu-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ecu-item .ecu-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: #2a2a4a;
    border-radius: 10px;
    color: #00d2ff;
}

.ecu-item .ecu-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.ecu-item .ecu-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.8rem;
}

.ecu-item .ecu-pinout {
    font-size: 0.7rem;
    color: #888;
    margin-top: 4px;
    padding: 4px 8px;
    background: #0a0a2a;
    border-radius: 4px;
    font-family: monospace;
}

/* MAIN PANEL */
.main-panel {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #0f0f1f;
}

/* ========== CARDS ========== */
.panel-card {
    background: #141428;
    border-radius: 10px;
    border: 1px solid #2a2a4a;
    padding: 16px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 8px;
}

/* ========== PARAM GROUPS ========== */
.param-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.param-group label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-group input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    background: #2a2a4a;
    border-radius: 2px;
    outline: none;
}

.param-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00d2ff;
    cursor: pointer;
}

.param-group input[type="number"],
.param-group select {
    padding: 6px 10px;
    background: #1a1a3e;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.85rem;
    width: 100%;
}

.param-group input[type="number"]:focus,
.param-group select:focus {
    border-color: #00d2ff;
    outline: none;
}

.param-group span {
    font-size: 0.85rem;
    color: #00d2ff;
    font-weight: 600;
}

.param-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.global-params {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ========== SIGNALS GRID ========== */
.signals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.signal-card {
    background: #141428;
    border-radius: 10px;
    border: 1px solid #2a2a4a;
    overflow: hidden;
    transition: all 0.3s ease;
}

.signal-card:hover {
    border-color: #3a3a6a;
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.05);
}

.signal-card.signal-group {
    grid-column: span 2;
}

.signal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #1a1a3e;
    border-bottom: 1px solid #2a2a4a;
}

.signal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.signal-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    font-size: 0.75rem;
    color: #888;
}

.signal-body {
    padding: 16px;
}

.signal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #1a1a3e;
}

.signal-frequency {
    font-size: 0.75rem;
    color: #888;
    font-family: monospace;
    margin-left: auto;
}

/* ========== STORAGE CONTROLS ========== */
.storage-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.cloud-sync {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.input-sm {
    padding: 4px 8px;
    background: #1a1a3e;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.75rem;
    flex: 1;
    min-width: 100px;
}

.status-small {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #2a2a4a;
}

.status-small.success {
    background: #00b894;
    color: #fff;
}

.status-small.error {
    background: #ff6b6b;
    color: #fff;
}

/* ========== FOOTER ========== */
footer {
    padding: 8px 24px;
    background: #111128;
    border-top: 1px solid #2a2a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: #666;
}

.footer-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.log-content {
    max-height: 150px;
    overflow-y: auto;
    background: #0a0a1a;
    padding: 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    margin: 8px 0;
}

.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid #1a1a2e;
}

.log-entry .timestamp {
    color: #666;
}

.log-entry .level-info {
    color: #00d2ff;
}

.log-entry .level-error {
    color: #ff6b6b;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0a1a;
}

::-webkit-scrollbar-thumb {
    background: #2a2a4a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a3a6a;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .signals-grid {
        grid-template-columns: 1fr;
    }
    .signal-card.signal-group {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        max-height: 300px;
        border-right: none;
        border-bottom: 1px solid #2a2a4a;
    }
    .param-row {
        grid-template-columns: 1fr;
    }
    .header-controls {
        flex-wrap: wrap;
    }
}