/* CSS Variables for theme colors */
:root {
    --color-primary: #667eea;
    --color-secondary: #764ba2;
    --color-danger: #f56565;
}

/* Global reset and base styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Global body styling */
.app-body {
    min-width: 300px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #374151;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Container styling */
.app-container {
    width: 100%;
    max-width: 28rem;
    padding: 1.25rem;
}

/* Card styling */
.app-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(24px);
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.app-card.hidden {
    display: none;
}

/* Logo styling */
.app-logo {
    width: 5rem;
    height: 5rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    color: white;
    font-size: 2.25rem;
}

/* Typography */
.app-title {
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #1f2937;
}

.app-subtitle {
    color: #6b7280;
    margin-bottom: 2.5rem;
    font-size: 1rem;
    line-height: 1.625;
}

/* Input group styling */
.input-group {
    margin-bottom: 2rem;
    text-align: left;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    color: #374151;
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-field {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 1rem;
    background: #f9fafb;
    transition: all 0.3s ease;
    outline: none;
}

.input-field:focus {
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 10px 25px -5px rgba(102, 126, 234, 0.1);
}

.input-field::placeholder {
    color: #9ca3af;
}

/* Button group styling */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

/* Base button styling */
.btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Primary button */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow: 0 10px 25px -5px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -5px rgba(102, 126, 234, 0.4);
}

/* Secondary button */
.btn-secondary {
    background: white;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
    transform: translateY(-2px);
}

/* Danger button */
.btn-danger {
    background: linear-gradient(135deg, #ef4444, var(--color-danger));
    color: white;
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -5px rgba(239, 68, 68, 0.4);
}

/* Telegram button */
.btn-telegram {
    border-radius: 50%;
    background: linear-gradient(135deg, #0088cc, #0077b3);
    color: white;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    box-shadow: 0 6px 16px rgba(0, 136, 204, 0.3);
}

.btn-telegram:hover:not(:disabled) {
    background: linear-gradient(135deg, #0077b3, #006699);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 136, 204, 0.4);
}

/* Copy button */
.btn-copy {
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.btn-copy:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a67d8, #6d28d9);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-copy.copied {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-copy:active,
.btn-telegram:active {
    transform: translateY(0);
}

/* Status styling */
.status {
    padding: 1rem;
    border-radius: 0.75rem;
    margin: 1.25rem 0;
    font-size: 0.875rem;
    border-left: 4px solid;
}

.status.info {
    background: #f3f4f6;
    color: #374151;
    border-left-color: var(--color-primary);
}

.status.success {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #22c55e;
}

.status.error {
    background: #fef2f2;
    color: #991b1b;
    border-left-color: #ef4444;
}

.status.connected {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #22c55e;
}

/* Call Screen Layout */
.call-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.call-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.call-duration-room {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.call-room-info {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.call-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    margin-bottom: 2rem;
    width: 100%;
    overflow: hidden; /* Prevent content from overflowing */
}

.call-footer {
    margin-top: auto;
}

/* Video Placeholder Styles */
.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: 1rem;
    border: 2px dashed #cbd5e0;
    margin-bottom: 1rem;
}

.placeholder-content {
    text-align: center;
    color: #6b7280;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #9ca3af;
}

.placeholder-room-id {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* Video Container Updates */
.video-container {
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Prevent container from shrinking */
}

.video-wrapper {
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
    background: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Default dimensions for landscape */
    height: 300px;
    /* Ensure it doesn't overflow parent */
    max-height: 60vh;
    /* Smooth transitions for orientation changes */
    transition: width 0.3s ease, height 0.3s ease;
    /* Center the wrapper itself */
    margin: 0 auto;
}

/* Portrait video orientation */
.video-wrapper.portrait {
    width: 225px;
    height: 400px;
    max-height: 60vh;
    max-width: calc(100vw - 3rem);
}

/* Landscape video orientation */
.video-wrapper.landscape {
    width: 400px;
    height: 300px;
    max-width: calc(100vw - 3rem);
    max-height: 60vh;
}

/* Square video orientation */
.video-wrapper.square {
    width: 350px;
    height: 350px;
    max-width: calc(100vw - 3rem);
    max-height: 60vh;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #374151;
    transition: object-fit 0.2s ease;
}

/* Alternative object-fit for better aspect ratio handling */
.video-wrapper.contain .remote-video {
    object-fit: contain;
}

/* Loading state for video */
.video-wrapper.loading {
    opacity: 0.8;
}

.video-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.video-label {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Media Controls Updates */
.media-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}


.btn-media {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    color: #374151;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-hangup {
    background: #ef4444;
    color: white;
}


.btn-media:hover {
    background: #e5e7eb;
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn-hangup:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-media.disabled {
    background: #ef4444;
    color: white;
}

.btn-media.disabled:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Status positioning update */
.call-main .status {
    margin: 1rem 0 0 0;
    align-self: stretch;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .call-top-row {
        flex-direction: row;
        align-items: flex-start;
        gap: 1rem;
    }

    .call-duration-room {
        align-self: stretch;
        justify-content: center;
    }

    .call-header .share-section {
        align-self: stretch;
        display: flex;
        justify-content: center;
    }

    .call-room-info {
        font-size: 0.75rem;
    }

    /* Mobile video adjustments */
    .video-container {
        padding: 0 1rem;
    }
    
    .video-wrapper.landscape {
        max-width: 95vw;
        height: auto;
        aspect-ratio: 16/9;
        max-height: 50vh;
    }

    .video-wrapper.portrait {
        width: auto;
        max-width: 60vw;
        height: 50vh;
        aspect-ratio: 9/16;
    }

    .video-wrapper.square {
        width: auto;
        height: auto;
        max-width: 80vw;
        max-height: 50vh;
        aspect-ratio: 1/1;
    }

    .video-placeholder {
        height: 250px;
    }

    .placeholder-icon {
        font-size: 3rem;
    }

    .btn-media {
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }
}

/* Share section styling - positioned in header */
.call-header .share-section {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.call-header .share-section.hidden {
    display: none;
}

.call-header .share-buttons {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.call-header .btn-telegram,
.call-header .btn-copy {
    border-radius: 50%;
    padding: 0.5rem;
    font-size: 0.875rem;
    min-width: auto;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer styling */
.app-footer {
    text-align: center;
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 2rem;
    line-height: 1.5;
}

/* Hidden elements */
.hidden {
    display: none;
}

audio {
    display: none;
}

/* Responsive design */
@media (max-width: 480px) {
    .app-container {
        padding: 1rem;
    }

    .app-card {
        padding: 2rem 1.5rem;
    }

    .app-title {
        font-size: 1.5rem;
    }

    .button-group {
        gap: 0.625rem;
    }

    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.875rem;
    }

    .share-buttons {
        gap: 0.625rem;
    }

    .btn-telegram,
    .btn-copy {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Screen transitions */
.screen {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 40px 30px;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 30px;
    color: white;
    font-size: 36px;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #2d3748;
}

.subtitle {
    color: #718096;
    margin-bottom: 40px;
    font-size: 16px;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 30px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #4a5568;
    font-weight: 500;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    background: #f8fafc;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input::placeholder {
    color: #a0aec0;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

button {
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
    box-shadow: 0 8px 20px rgba(245, 101, 101, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(245, 101, 101, 0.4);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.status {
    background: #edf2f7;
    padding: 16px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 14px;
    color: #4a5568;
    border-left: 4px solid #667eea;
}

.status.connected {
    background: #f0fff4;
    border-left-color: #48bb78;
    color: #22543d;
}

.status.success {
    background: #f0fff4;
    border-left-color: #48bb78;
    color: #22543d;
}

.status.error {
    background: #fed7d7;
    border-left-color: #f56565;
    color: #742a2a;
}

.auth-status {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border-left: 3px solid #667eea;
}

.auth-status.authenticated {
    border-left-color: #48bb78;
    color: #22543d;
}

.auth-status.unauthenticated {
    border-left-color: #f56565;
    color: #742a2a;
}

/* Share Section Styles */
.share-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #cbd5e0;
}

.share-info p {
    margin-bottom: 15px;
    color: #4a5568;
    font-weight: 500;
}

.share-buttons {
    display: flex;
    flex-direction: row;
    gap: 12px;
    justify-content: center;
}

.share-link-input {
    display: none;
}

.btn-telegram {
    background: linear-gradient(135deg, #0088cc, #0077b3);
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 16px rgba(0, 136, 204, 0.3);
}

.btn-telegram:hover:not(:disabled) {
    background: linear-gradient(135deg, #0077b3, #006699);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 136, 204, 0.4);
}

.btn-copy {
    background: #667eea;
    color: white;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

.btn-copy:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-copy:active,
.btn-telegram:active {
    transform: translateY(0);
}

.btn-copy.copied {
    background: #48bb78;
    box-shadow: 0 6px 16px rgba(72, 187, 120, 0.3);
}

/* Call Screen Styles */
.call-screen {
    display: none;
}

.call-info {
    text-align: center;
    margin-bottom: 40px;
}

.audio-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
}

.audio-indicator {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.local-audio {
    background: linear-gradient(135deg, #48bb78, #38a169);
}

.remote-audio {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.footer {
    text-align: center;
    color: #718096;
    font-size: 12px;
    margin-top: 30px;
    line-height: 1.4;
}

.background-audio-notice {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    font-size: 11px;
    color: #4c51bf;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .card {
        padding: 30px 20px;
    }

    h1 {
        font-size: 24px;
    }

    .button-group {
        gap: 10px;
    }

    button {
        padding: 14px 20px;
        font-size: 14px;
    }

    .share-buttons {
        gap: 10px;
    }

    .btn-telegram,
    .btn-copy {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Hidden audio elements */
audio {
    display: none;
}

/* Screen transitions */
.screen {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Animation for status updates */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Hidden audio elements */
audio {
    display: none;
}

/* Screen transitions */
.screen {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Animation for status updates */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.pulse {
    animation: pulse 2s infinite;
}