/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Tahoma, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    text-align: right;
    color: #ffffff;
    overflow-x: hidden;
}

/* Container */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Management */
.page {
    display: none;
    width: 100%;
}

.page.active {
    display: block;
}

/* Login Box */
.login-box,
.name-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Logo */
.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.logo svg {
    width: 40px;
    height: 40px;
    color: #ffffff;
}

/* Typography */
h1 {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 12px;
}

.subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 32px;
    font-size: 14px;
}

/* Form Styles */
.input-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 15px;
    font-family: Tahoma, Arial, sans-serif;
    transition: all 0.3s ease;
    outline: none;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

input[type="text"]:focus,
input[type="password"]:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: Tahoma, Arial, sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Error Message */
.error-message {
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 107, 0.3);
    display: none;
}

.error-message.show {
    display: block;
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* Chat Page Styles */
#chatPage {
    min-height: 100vh;
    background: #1a1a2e;
    padding: 0;
}

.chat-header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-content h2 {
    font-size: 20px;
    margin: 0 0 8px 0;
    text-align: right;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.separator {
    opacity: 0.5;
}

.participants-count {
    background: rgba(102, 126, 234, 0.3);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Control Buttons */
.header-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    outline: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.control-btn.active {
    background: #ff6b6b;
}

.leave-btn {
    background: #ff6b6b;
}

.leave-btn:hover {
    background: #ff5252;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.video-container {
    position: relative;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.video-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(102, 126, 234, 0.5);
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a40;
}

.avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
}

.video-container.local video {
    transform: scaleX(-1);
    /* Mirror local video */
}

.video-label {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-label::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Status Message */
.status-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    padding: 24px 48px;
    border-radius: 16px;
    display: none;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.status-message.show {
    display: flex;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .login-box,
    .name-box {
        padding: 32px 24px;
    }

    .chat-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-controls {
        justify-content: center;
    }

    .video-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }
}

/* Accessibility */
/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    color: #ffffff;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #667eea;
}

.modal-content p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 20px;
}

.manual-step {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.manual-step h4 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #e0e7ff;
}

textarea {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #ffffff;
    font-family: monospace;
    font-size: 12px;
    padding: 10px;
    margin-bottom: 10px;
    resize: none;
}

textarea:focus {
    border-color: #667eea;
    outline: none;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    margin-bottom: 5px;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hint {
    font-size: 12px;
    color: rgba(102, 126, 234, 0.8);
    margin-top: 5px;
}

hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}