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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #333;
    font-size: 28px;
}

.status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.status.connected {
    background: #10b981;
    color: white;
}

.status.disconnected {
    background: #ef4444;
    color: white;
}

.status.connecting {
    background: #f59e0b;
    color: white;
}

.controls {
    background: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover {
    background: #5568d3;
}

button:active {
    transform: scale(0.98);
}

.stream-count {
    color: #666;
    font-size: 14px;
}

.streams-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.stream-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, grid-column 0.2s;
    cursor: pointer;
}

.stream-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.stream-header {
    background: #f3f4f6;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.stream-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stream-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pin-btn,
.expand-btn {
    padding: 4px 10px;
    font-size: 12px;
}

.stream-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.stream-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
}

.stream-type.screen {
    background: #3b82f6;
    color: white;
}

.stream-type.webcam {
    background: #10b981;
    color: white;
}

.stream-client-id {
    font-size: 12px;
    color: #6b7280;
    font-family: monospace;
}

.stream-content {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stream-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.pip-container {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30%;
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.stream-image-pip {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.pip-placeholder {
    font-size: 10px;
    padding: 4px;
}

.stream-placeholder {
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
}

.no-streams {
    grid-column: 1 / -1;
    background: white;
    padding: 60px 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    color: #6b7280;
}

.no-streams p {
    font-size: 18px;
}

/* Expanded (maximized) card */
.stream-card.expanded {
    grid-column: 1 / -1;
}

.stream-card.expanded .stream-content {
    aspect-ratio: 16 / 9;
}

@media (max-width: 768px) {
    .streams-container {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .controls {
        flex-direction: column;
        gap: 15px;
    }
}
