:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #10b981;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--surface);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.drone-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 2s ease-in-out infinite;
}

.status-indicator.connected {
    background: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
}

/* Sidebar */
.sidebar {
    background: var(--surface);
    border-right: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-refresh {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: var(--primary-dark);
    transform: rotate(90deg);
}

.btn-refresh svg {
    width: 20px;
    height: 20px;
}

.streams-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.stream-item {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.stream-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.stream-item.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(16, 185, 129, 0.1));
}

.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.stream-ssrc {
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.stream-viewers {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stream-viewers svg {
    width: 16px;
    height: 16px;
}

.stream-origin {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state small {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Viewer - Grid Multi-Cámara */
.viewer {
    display: flex;
    flex-direction: column;
    background: var(--background);
}

.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
    background: var(--background);
    overflow: hidden;
}

.video-slot {
    position: relative;
    background: #000;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    min-height: 200px;
}

.video-slot:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

.video-slot.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.video-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: var(--text-secondary);
}

.drone-icon-small {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
    opacity: 0.3;
}

.overlay-content p {
    font-size: 0.875rem;
    margin: 0;
}

.video-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.slot-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-slot:hover .slot-info,
.video-slot.active .slot-info {
    opacity: 1;
}

.slot-ssrc {
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 600;
}

.btn-slot-disconnect {
    background: var(--danger-color);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.8;
}

.btn-slot-disconnect:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-slot-disconnect svg {
    width: 14px;
    height: 14px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.video-controls {
    background: var(--surface);
    border-top: 2px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stream-info {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.875rem;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.separator {
    color: var(--border-color);
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-control {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-control:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-control.btn-disconnect:hover:not(:disabled),
.btn-control.btn-disconnect-all:hover:not(:disabled) {
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-control svg {
    width: 20px;
    height: 20px;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 2px solid var(--border-color);
    padding: 1rem 2rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.footer-note {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--primary-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--surface);
    border: 2px solid;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    min-width: 300px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--danger-color);
}

.toast.info {
    border-color: var(--primary-color);
}

.toast.warning {
    border-color: var(--warning-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-hover);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        max-height: 200px;
    }

    .streams-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 1rem;
        gap: 0.75rem;
    }

    .stream-item {
        min-width: 200px;
        margin-bottom: 0;
    }

    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .stream-info {
        flex-wrap: wrap;
        font-size: 0.75rem;
    }

    .control-buttons {
        flex-wrap: wrap;
    }

    .video-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
    }
}



