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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Container Styles */
.container {
    width: 100%;
    max-width: 500px;
}

/* Login Container */
.login-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-container h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.login-container h2 {
    color: #555;
    font-size: 20px;
    margin-bottom: 20px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Button Styles */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Button Loading State */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: rotate 2s linear infinite;
}

.spinner .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

.btn-secondary {
    background: #f0f0f0;
    color: #555;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Error Message */
.error-message {
    color: #e53e3e;
    font-size: 14px;
    margin-top: 15px;
    padding: 10px;
    background: #fff5f5;
    border-radius: 6px;
    border-left: 4px solid #e53e3e;
}

/* Tech Dashboard */
.tech-dashboard {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    animation: slideUp 0.3s ease-out;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-header h1 {
    color: #333;
    font-size: 28px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: #666;
    font-size: 14px;
}

/* Support Code Section */
.support-code-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    color: white;
}

.support-code-section h2 {
    color: white;
    margin-bottom: 20px;
    font-size: 22px;
}

.code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.code-value {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    min-width: 280px;
    text-align: center;
}

.code-value.active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.code-info {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    text-align: center;
    margin-top: 10px;
}

/* Waiting Section */
.waiting-section {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 30px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.waiting-section p {
    color: #666;
    font-size: 16px;
}

/* Session Log */
.session-log {
    margin-top: 30px;
}

.session-log h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
}

.session-list {
    max-height: 400px;
    overflow-y: auto;
}

.no-data {
    color: #999;
    text-align: center;
    padding: 40px;
    font-style: italic;
}

/* Session Table */
.session-table {
    width: 100%;
    border-collapse: collapse;
}

.session-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
    font-size: 14px;
    border-bottom: 2px solid #e0e0e0;
}

.session-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #666;
}

.session-table tr:hover {
    background: #f8f9fa;
}

.status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status.completed {
    background: #d4edda;
    color: #155724;
}

.status.active {
    background: #fff3cd;
    color: #856404;
}

/* Permission Screen */
.permission-screen {
    width: 100vw;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.permission-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

.permission-icon {
    font-size: 72px;
    margin-bottom: 20px;
}

.permission-container h1 {
    color: #333;
    font-size: 24px;
    margin-bottom: 15px;
}

.permission-container > p {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.5;
}

/* Permission Status Display */
.permission-status {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border-radius: 8px;
    text-align: left;
}

.status-item:last-child {
    margin-bottom: 0;
}

.status-icon {
    font-size: 24px;
    min-width: 24px;
}

.status-text {
    flex: 1;
    color: #555;
    font-size: 16px;
    font-weight: 500;
}

.status-text span {
    font-weight: 600;
    color: #333;
}

/* Button Styles for Permission Screen */
.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 18px;
    margin-bottom: 15px;
}

.btn-icon {
    font-size: 24px;
    margin-right: 8px;
    vertical-align: middle;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    animation: pulse 2s infinite;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

/* Permission Help Section */
.permission-help {
    background: #fff9e6;
    border: 2px solid #ffd700;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: left;
}

.permission-help p {
    margin-bottom: 10px;
    color: #555;
    font-size: 14px;
}

.permission-help strong {
    color: #333;
    font-size: 16px;
}

.permission-help ol {
    margin: 10px 0 15px 20px;
    color: #666;
    font-size: 14px;
    line-height: 1.8;
}

.permission-help ol li {
    margin-bottom: 5px;
}

/* Call Container - Full Screen */
.call-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: none; /* Prevent pull-to-refresh on mobile */
}

body:has(.call-container) {
    margin: 0;
    padding: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Video Container - Takes all available space */
.video-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Remote video fills the container */
#remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #1a1a1a;
}

/* Local video - Picture in Picture */
.local-video-pip {
    position: absolute;
    top: 20px;
    right: 20px;
    width: clamp(120px, 25vw, 200px);
    height: clamp(90px, 18.75vw, 150px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10;
    border: 3px solid rgba(255, 255, 255, 0.2);
    background: #1a1a1a;
    transition: all 0.3s ease;
}

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

.video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
}

/* Bottom Toolbar */
.toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.8));
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom)); /* Safe area for iPhone notch */
    z-index: 100;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 60px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    color: white;
}

.toolbar-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

/* Muted/Off state - Red background */
.toolbar-btn.muted,
.toolbar-btn.off {
    background: rgba(255, 59, 48, 0.3);
    border-color: rgba(255, 59, 48, 0.5);
}

.toolbar-btn.muted:hover,
.toolbar-btn.off:hover {
    background: rgba(255, 59, 48, 0.4);
}

.toolbar-btn.muted:active,
.toolbar-btn.off:active {
    background: rgba(255, 59, 48, 0.5);
    transform: scale(0.95);
}

/* Flashlight button states */
.toolbar-btn.flashlight-on {
    background: rgba(255, 204, 0, 0.3);
    border-color: rgba(255, 204, 0, 0.6);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.5);
}

.toolbar-btn.flashlight-on:hover {
    background: rgba(255, 204, 0, 0.4);
}

.toolbar-btn.flashlight-on:active {
    background: rgba(255, 204, 0, 0.5);
}

.toolbar-btn.flashlight-off {
    opacity: 0.6;
}

.toolbar-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.toolbar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toolbar-btn.muted,
.toolbar-btn.off {
    background: rgba(239, 68, 68, 0.8);
}

.toolbar-btn.leave-btn {
    background: rgba(239, 68, 68, 0.9);
}

.toolbar-btn.leave-btn:active {
    background: rgba(220, 38, 38, 1);
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    padding: 0 5px;
}

/* Status Header Bar */
.status-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.85));
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 110;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.header-code {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-name {
    font-weight: 600;
    color: white;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    text-decoration: none;
    font-size: 18px;
    transition: all 0.2s;
}

.header-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.header-link:active {
    transform: scale(0.95);
}

/* Connection Status */
.connection-status {
    position: absolute;
    top: 70px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-radius: 20px;
    z-index: 20;
    pointer-events: none;
}

/* Video Overlay Controls */
.video-overlay-btn {
    position: absolute;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 25;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.video-overlay-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.85);
}

.video-overlay-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.05);
}

.video-overlay-left {
    left: 20px;
}

.video-overlay-right {
    right: 20px;
}

.overlay-icon {
    font-size: 28px;
    line-height: 1;
}

/* When flashlight is on */
.video-overlay-btn.flashlight-on {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}


/* Chat Window */
.chat-window {
    position: fixed;
    background: rgba(20, 20, 20, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 105;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.chat-window.open {
    transform: translateY(0);
}

/* Default: Bottom drawer for mobile */
.chat-window {
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    max-height: 50vh;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

.chat-title {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.chat-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s;
}

.chat-close:active {
    background: rgba(255, 255, 255, 0.2);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.mine {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.message-avatar.remote {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-text {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 14px;
    border-radius: 16px;
    color: white;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.chat-message.mine .message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    padding: 0 4px;
}

/* Chat Error Notification */
.chat-error-notification {
    padding: 8px 12px;
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid rgba(255, 59, 48, 0.4);
    border-radius: 8px;
    color: #ff3b30;
    font-size: 13px;
    text-align: center;
    margin: 8px 0;
    transition: opacity 0.3s ease;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 10px 16px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    line-height: 1.4;
}

#chat-input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.15);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    align-self: flex-end;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

#chat-input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Chat Notification Bubble */
.chat-bubble {
    position: fixed;
    bottom: 100px;
    right: 20px;
    max-width: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 102;
    animation: bubbleSlide 0.3s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-bubble.bubble-animate {
    animation: bubblePulse 0.5s ease;
}

.chat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

@keyframes bubbleSlide {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bubblePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.bubble-content {
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fbbf24;
    animation: blink 1.5s infinite;
}

.status-dot.connected {
    background: #10b981;
    animation: none;
}

.status-dot.error {
    background: #ef4444;
}

.status-dot.warning {
    background: #fbbf24;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.status-text {
    color: white;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================
   RESPONSIVE STYLES
   Note: Mobile and Desktop styles are loaded
   dynamically from styles-mobile.css or 
   styles-desktop.css based on device detection
   ============================================ */




