/* CSS Variables for theming */
:root {
    /* Colors */
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    /* Backgrounds */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-overlay: rgba(15, 23, 42, 0.95);
    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    /* Borders & Shadows */
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: rgba(248, 250, 252, 0.8);
    --bg-overlay: rgba(255, 255, 255, 0.95);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Layout */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr 400px;
    flex: 1;
    gap: var(--space-md);
    padding: var(--space-md);
    height: calc(100vh - 80px);
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    backdrop-filter: blur(10px);
}

/* Video Grid */
.video-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex: 1;
}

.video-grid {
    display: grid;
    gap: var(--space-sm);
    padding: var(--space-sm);
    width: 100%;
    height: 100%;
}

.video-grid.grid-1 {
    grid-template-columns: 1fr;
}

.video-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.video-grid.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

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

.video-grid.grid-many {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.video-tile {
    position: relative;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 200px;
}

.video-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-tile .participant-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: var(--space-sm);
    font-size: 0.875rem;
}

/* Control Bar */
.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-top: var(--space-md);
}

.control-group {
    display: flex;
    gap: var(--space-sm);
}

.control-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

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

.control-btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.control-btn.active {
    background: var(--success-color);
    color: white;
}

/* Chat Panel */
.chat-container {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    height: 100%;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.chat-message {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    max-width: 80%;
}

.chat-message.self {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
}

.chat-message.other {
    background: var(--bg-card);
    color: var(--text-primary);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
    font-size: 0.75rem;
    opacity: 0.8;
}

.message-content {
    font-size: 0.875rem;
    line-height: 1.4;
}

.chat-input-container {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.typing-dots {
    display: flex;
    gap: var(--space-xs);
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.participants-list {
    padding: var(--space-sm);
}

.participant-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.participant-item:hover {
    background: var(--bg-secondary);
}

.participant-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.participant-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
}

/* Forms */
.form-group {
margin-bottom: var(--space-md);
}

.form-input, .form-select {
    width: 100%;
    padding: var(--space-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* Connection Status */
.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background-color var(--transition-fast);
}

.status-dot.connected {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot.disconnected {
    background: var(--error-color);
}

.status-dot.connecting {
    background: var(--warning-color);
    animation: pulse 1s infinite;
}

.status-dot.error {
    background: var(--error-color);
}

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

/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.notification {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    pointer-events: auto;
}

.notification.show {
    transform: translateX(0);
}

.notification.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification.notification-warning {
    border-left: 4px solid var(--warning-color);
}

.notification.notification-error {
    border-left: 4px solid var(--error-color);
}

.notification.notification-info {
    border-left: 4px solid var(--primary-color);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    color: var(--text-primary);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 500;
}

.error-state {
    text-align: center;
    color: var(--text-primary);
}

.error-state h2 {
    margin-bottom: var(--space-md);
    color: var(--error-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 300px 1fr;
    }
    .right-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        padding: var(--space-sm);
    }
    .left-sidebar {
        display: none;
    }
    .control-bar {
        flex-direction: column;
        gap: var(--space-sm);
    }
    .control-group {
        width: 100%;
        justify-content: center;
    }
}

/* Utility Classes */
.hidden {
display: none !important;
}

.text-center {
text-align: center;
}

.flex {
display: flex;
}

.flex-col {
flex-direction: column;
}

.items-center {
align-items: center;
}

.justify-between {
justify-content: space-between;
}

.gap-sm {
gap: var(--space-sm);
}

.gap-md {
gap: var(--space-md);
}

.offline {
    opacity: 0.7;
}

.offline .connection-status {
    filter: grayscale(1);
}
