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

:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #FFC107;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --error: #F44336;
    --success: #4CAF50;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
}

.loading-spinner.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(33, 150, 243, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Call screen specific styling */
#call-screen.screen.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

h1 {
    font-size: 2.5rem;
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E0E0E0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #E0E0E0;
    color: var(--text-primary);
}

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

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.1);
}

.error-message {
    color: var(--error);
    margin-top: 1rem;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
}

/* App Screen */
header {
    background: var(--surface);
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}

.app-version {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    margin-top: -0.25rem;
    font-weight: normal;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-status {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s;
}

.notification-status.enabled {
    color: var(--success);
    background: rgba(76, 175, 80, 0.1);
}

.notification-status.disabled {
    color: var(--text-secondary);
    background: rgba(117, 117, 117, 0.1);
    text-decoration: underline;
}

.notification-status.disabled:hover {
    color: var(--primary-color);
    background: rgba(33, 150, 243, 0.1);
}

.language-switcher {
    display: flex;
    align-items: center;
}

.language-switcher select {
    padding: 0.5rem;
    border: 2px solid #E0E0E0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s;
}

.language-switcher select:hover {
    border-color: var(--primary-color);
}

.language-switcher select:focus {
    outline: none;
    border-color: var(--primary-color);
}

main {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 1.25rem;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contact-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s;
}

.contact-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.contact-info {
    flex: 1;
}

.contact-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.contact-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    flex: 1;
}

.status-indicator {
    font-size: 0.75rem;
    display: inline-block;
}

.status-indicator.online {
    opacity: 1;
}

.status-indicator.offline {
    opacity: 0.4;
}

.push-indicator {
    font-size: 0.75rem;
    display: inline-block;
    opacity: 0.7;
}

.contact-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* Pending Invites Section */
.pending-invites-section {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.invites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invite-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.invite-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.invite-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.invite-name {
    font-weight: 500;
    color: var(--text-primary);
}

.invite-link-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
    font-family: monospace;
}

.invite-actions {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.modal-actions .btn {
    flex: 1;
}

.invite-link-container {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.invite-link-container input {
    flex: 1;
}

/* Call Screen */
.call-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height to account for browser UI */
    max-height: 100vh;
    max-height: 100dvh;
    background: #000;
    overflow: hidden;
}

.video-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Important for flex children to respect container bounds */
    overflow: hidden; /* Prevent overflow */
    width: 100%;
    height: 100%;
}

#remote-video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* Maintain aspect ratio with black bars if needed */
    display: block;
}

#local-video {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 150px;
    height: 200px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid white;
    background: #000;
    cursor: move;
    touch-action: none;
    z-index: 10;
    user-select: none;
    display: block;
    visibility: visible;
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.8);
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-btn.end-call {
    background: var(--error);
}

.call-info {
    position: absolute;
    top: 10px;
    left: 20px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
}

.install-prompt {
    margin-top: 2rem;
    padding: 1rem;
    background: #E3F2FD;
    border-radius: 8px;
    text-align: center;
}

.prompt-banner {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.prompt-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.prompt-content span {
    flex: 1;
    font-weight: 500;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.prompt-content .btn-icon {
    color: white;
    font-size: 1.5rem;
    padding: 0;
    min-width: auto;
}

.invite-message {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.invite-message p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    #local-video {
        width: 120px;
        height: 160px;
    }
}

