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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --dark-overlay: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-light: rgba(255, 255, 255, 0.9);
    --text-primary: #ffffff;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 16px 64px rgba(0, 0, 0, 0.2);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    overflow: hidden;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Общие стили для экранов */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Экран приветствия */
.welcome-content {
    text-align: center;
    color: var(--text-primary);
    z-index: 10;
    max-width: 400px;
    width: 90%;
}

.logo {
    margin-bottom: 3rem;
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

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

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    font-size: 1.1rem;
    color: var(--text-light);
    font-weight: 400;
}

.join-form {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong);
    margin-bottom: 2rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    transition: var(--transition);
    font-weight: 500;
}

.input-group input:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 1);
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: #666;
}

.primary-btn {
    position: relative;
    width: 100%;
    padding: 1.2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--accent-gradient);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(245, 87, 108, 0.4);
}

.primary-btn.large-btn {
    padding: 1.5rem;
    font-size: 1.2rem;
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.primary-btn:hover .btn-glow {
    left: 100%;
}

.features {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
}

.feature-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Плавающие фигуры */
.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    animation: floatShape 20s linear infinite;
}

.shape-1 {
    width: 60px;
    height: 60px;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 80px;
    height: 80px;
    left: 80%;
    animation-delay: 5s;
}

.shape-3 {
    width: 40px;
    height: 40px;
    left: 60%;
    animation-delay: 10s;
}

.shape-4 {
    width: 100px;
    height: 100px;
    left: 30%;
    animation-delay: 15s;
}

@keyframes floatShape {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10%, 90% {
        opacity: 0.7;
    }
    50% {
        transform: translateY(-50vh) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Экран ожидания */
.waiting-content {
    text-align: center;
    color: var(--text-primary);
}

.waiting-animation {
    position: relative;
    margin-bottom: 2rem;
}

.pulse-dot {
    width: 20px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(245, 87, 108, 0.5);
    border-radius: 50%;
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

.waiting-content h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.room-info {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.room-code {
    background: var(--glass-bg);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid var(--glass-border);
}

.help-text {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.secondary-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Экран входящего звонка */
.call-content {
    text-align: center;
    color: var(--text-primary);
}

.call-avatar {
    position: relative;
    margin-bottom: 2rem;
    display: inline-block;
}

.avatar-circle {
    width: 120px;
    height: 120px;
    background: var(--glass-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    position: relative;
    z-index: 2;
}

.call-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    border: 3px solid rgba(245, 87, 108, 0.5);
    border-radius: 50%;
    animation: callPulse 2s ease-out infinite;
}

@keyframes callPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.8);
        opacity: 0;
    }
}

.call-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.caller-name {
    font-size: 1.4rem;
    margin-bottom: 3rem;
    font-weight: 500;
    color: var(--text-light);
}

.call-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
}

.call-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.accept-btn {
    background: var(--success-gradient);
    color: white;
}

.reject-btn {
    background: var(--danger-gradient);
    color: white;
}

.call-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-strong);
}

/* Экран видеозвонка */
.video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 0;
    overflow: hidden;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#local-video {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 240px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--border-radius);
    border: 3px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
}

#local-video:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-strong);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.call-header {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.call-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-primary);
}

.duration {
    font-weight: 600;
    font-size: 1.1rem;
}

.status {
    font-size: 0.9rem;
    color: var(--text-light);
    position: relative;
}

.status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
    animation: statusBlink 2s ease-in-out infinite;
}

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

.controls-panel {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: all;
}

.controls {
    display: flex;
    gap: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 1rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    position: relative;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

.control-btn.end-call-btn {
    background: var(--danger-gradient);
}

.control-btn.end-call-btn:hover {
    background: linear-gradient(135deg, #e91e63 0%, #f44336 100%);
}

.control-btn.muted {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.control-btn.disabled {
    background: linear-gradient(135deg, #757575 0%, #616161 100%);
}

/* Экран готовности */
.ready-content {
    text-align: center;
    color: var(--text-primary);
    max-width: 400px;
}

.ready-content h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.ready-subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.preview-container {
    position: relative;
    width: 300px;
    height: 200px;
    margin: 0 auto 2rem;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 3px solid var(--glass-border);
    box-shadow: var(--shadow-strong);
}

#preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 1rem;
    color: white;
}

.preview-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Уведомления */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 300px;
}

.notification {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    animation: slideInRight 0.3s ease;
    position: relative;
    overflow: hidden;
}

.notification.error {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.2), rgba(233, 30, 99, 0.2));
    border-color: rgba(244, 67, 54, 0.3);
}

.notification.success {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(139, 195, 74, 0.2));
    border-color: rgba(76, 175, 80, 0.3);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .welcome-content {
        max-width: 350px;
    }

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

    .join-form {
        padding: 2rem;
    }

    .features {
        gap: 0.5rem;
    }

    .feature {
        font-size: 0.8rem;
    }

    #local-video {
        width: 150px;
        height: 113px;
        top: 15px;
        right: 15px;
    }

    .controls {
        gap: 0.8rem;
        padding: 0.8rem;
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .call-buttons {
        gap: 1.5rem;
    }

    .call-btn {
        width: 70px;
        height: 70px;
    }

    .preview-container {
        width: 250px;
        height: 167px;
    }
}

@media (max-width: 480px) {
    .welcome-content {
        width: 95%;
    }

    .join-form {
        padding: 1.5rem;
    }

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

    .features {
        flex-direction: column;
        gap: 1rem;
    }

    .feature {
        flex-direction: row;
        gap: 0.5rem;
    }
}

/* Полноэкранный режим */
.fullscreen .video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
}

/* Темы */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-gradient: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        --glass-bg: rgba(255, 255, 255, 0.05);
        --glass-border: rgba(255, 255, 255, 0.1);
    }
}

/* Плавные переходы для всех интерактивных элементов */
button, input, video {
    transition: var(--transition);
}

/* Улучшенная доступность */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Дополнительные улучшения для фокуса */
button:focus-visible, input:focus-visible {
    outline: 2px solid rgba(245, 87, 108, 0.8);
    outline-offset: 2px;
}

/* Скроллбар (для будущего использования) */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #e91e63 0%, #f44336 100%);
}