/* Сброс и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success-color: #10b981;
    --success-dark: #059669;
    --danger-color: #ef4444;
    --danger-dark: #dc2626;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --bg-white: #ffffff;
    --bg-gray: #f9fafb;
    --bg-gray-dark: #f3f4f6;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease-in-out;
}

/* Основной фон и типографика */
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    line-height: 1.5;
    color: var(--text-primary);
    font-weight: 400;
}

/* Контейнер приложения */
.app-container {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Заголовки */
.screen-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
    line-height: 1.3;
}

.screen-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.5;
}

/* Код комнаты */
.room-code-section {
    margin: 24px 0;
}

.room-code-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 8px;
    display: block;
}

.room-code-display {
    font-size: 42px;
    font-weight: 800;
    color: var(--primary-color);
    background: var(--bg-gray);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
    text-align: center;
    letter-spacing: 8px;
    font-feature-settings: "tnum";
    transition: var(--transition);
    margin-bottom: 8px;
}

.room-code-hint {
    font-size: 13px;
    color: var(--text-light);
    text-align: center;
    margin-top: 8px;
}

/* Формы ввода */
.input-section {
    margin: 32px 0;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

.room-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-white);
    transition: var(--transition);
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.room-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-white);
}

.room-input::placeholder {
    color: var(--text-light);
    font-weight: 400;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    min-height: 56px;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

/* Варианты кнопок */
.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:not(:disabled):hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-success:not(:disabled):hover {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-danger:not(:disabled):hover {
    background: var(--danger-dark);
}

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:not(:disabled):hover {
    background: var(--bg-gray-dark);
    color: var(--text-primary);
}

/* Размеры кнопок */
.btn-full {
    width: 100%;
}

.btn-large {
    padding: 18px 28px;
    font-size: 17px;
}

/* Группы кнопок */
.btn-group {
    display: flex;
    gap: 12px;
    margin: 24px 0;
}

.btn-group .btn {
    flex: 1;
}

/* Статус индикаторы */
.status-indicator {
    background: var(--bg-gray);
    padding: 16px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin: 20px 0;
    border-left: 4px solid var(--primary-color);
}

.status-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.status-indicator.connecting {
    border-left-color: var(--warning-color);
    background: #fffbeb;
}

.status-indicator.connected {
    border-left-color: var(--success-color);
    background: #ecfdf5;
}

.status-indicator.error {
    border-left-color: var(--danger-color);
    background: #fef2f2;
}

/* Экран входящего звонка */
.incoming-call-alert {
    text-align: center;
    padding: 16px 0;
}

.call-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    box-shadow: var(--shadow-lg);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.caller-info {
    margin-bottom: 8px;
}

.caller-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.caller-number {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Таймер звонка */
.call-timer-section {
    text-align: center;
    margin: 24px 0;
}

.call-timer {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    margin: 16px 0;
}

.connection-status {
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--bg-gray);
    padding: 8px 16px;
    border-radius: 20px;
    display: inline-block;
}

/* Видео контейнер */
.video-section {
    margin: 24px 0;
}

.video-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 20px 0;
}

@media (min-width: 480px) {
    .video-container {
        grid-template-columns: 1fr 1fr;
    }
}

.video-wrapper {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-md);
    aspect-ratio: 4/3;
}

.video-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, #1f2937, #374151);
    z-index: 1;
}

.video-wrapper video {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 3;
    backdrop-filter: blur(10px);
}

/* Локальное видео (зеркальное отображение) */
#localVideo {
    transform: scaleX(-1);
}

/* Действия звонка */
.call-actions {
    margin: 24px 0;
}

/* Состояния экранов */
.screen {
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Отладочная информация */
.debug-info {
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    margin-top: 20px;
    padding: 12px;
    background: var(--bg-gray);
    border-radius: var(--radius-md);
}

/* Адаптивность для мобильных */
@media (max-width: 480px) {
    .app-container {
        padding: 24px;
        border-radius: 20px;
    }

    .room-code-display {
        font-size: 36px;
        padding: 16px;
        letter-spacing: 6px;
    }

    .btn-group {
        flex-direction: column;
    }

    .video-container {
        grid-template-columns: 1fr;
    }

    .btn {
        min-height: 52px;
    }
}

/* Особо маленькие экраны */
@media (max-width: 360px) {
    .app-container {
        padding: 20px;
    }

    .room-code-display {
        font-size: 32px;
        letter-spacing: 4px;
    }

    .screen-title {
        font-size: 22px;
    }
}

/* Интерактивные состояния */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Улучшенный фокус для доступности */
.btn:focus-visible,
.room-input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}