html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5I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I2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Home page styles */
.home-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.room-form {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    margin-top: 2rem;
}

/* Room page styles */
.room-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
}

.connecting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.video-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    padding: 1rem;
    overflow: auto;
}

.video-container {
    position: relative;
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.video-container video,
.remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.local-video-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 200px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
    border: 2px solid #444;
    z-index: 100;
}

.local-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Mirror is set dynamically by JS based on camera facing mode */
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #2a2a2a;
}

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

.room-id {
    color: #fff;
    font-weight: 500;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.controls .btn {
    min-width: 100px;
}

/* Quality badge */
.quality-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.quality-badge.ultra {
    background: rgba(111, 66, 193, 0.9);
}

.quality-badge.high {
    background: rgba(40, 167, 69, 0.8);
}

.quality-badge.medium {
    background: rgba(23, 162, 184, 0.8);
}

.quality-badge.low {
    background: rgba(255, 193, 7, 0.8);
    color: #000;
}

.quality-badge.minimal {
    background: rgba(220, 53, 69, 0.8);
}

.quality-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    font-size: 0.85rem;
}

.quality-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
}

.quality-indicator .dot.ultra {
    background: #6f42c1;
}

.quality-indicator .dot.high {
    background: #28a745;
}

.quality-indicator .dot.medium {
    background: #17a2b8;
}

.quality-indicator .dot.low {
    background: #ffc107;
}

.quality-indicator .dot.minimal {
    background: #dc3545;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: 1fr;
    }

    .local-video-container {
        width: 120px;
        height: 90px;
        bottom: 80px;
        right: 10px;
    }

    .controls-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .controls .btn {
        min-width: auto;
        padding: 0.5rem;
    }
}

/* Chat panel styles */
.chat-panel {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 320px;
    height: 400px;
    background: #2a2a2a;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #3a3a3a;
    border-radius: 8px 8px 0 0;
    color: #fff;
    font-weight: 500;
}

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

.chat-message {
    background: #3a3a3a;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 85%;
}

.chat-message.own {
    background: #1b6ec2;
    align-self: flex-end;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-username {
    color: #aaa;
    font-size: 11px;
    font-weight: 500;
}

.chat-message.own .chat-username {
    color: rgba(255, 255, 255, 0.7);
}

.chat-time {
    color: #777;
    font-size: 10px;
}

.chat-message.own .chat-time {
    color: rgba(255, 255, 255, 0.5);
}

.chat-message-content {
    color: #fff;
    font-size: 13px;
    word-wrap: break-word;
}

.chat-message-image {
    margin-top: 4px;
}

.chat-message-image img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-message-image img:hover {
    transform: scale(1.05);
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #444;
}

.chat-input input {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 8px 12px;
    color: #fff;
    font-size: 13px;
}

.chat-input input:focus {
    outline: none;
    border-color: #1b6ec2;
}

.chat-input input::placeholder {
    color: #666;
}

.controls .btn.has-unread {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@media (max-width: 768px) {
    .chat-panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 80px;
        height: 300px;
    }

    .local-video-container {
        display: none;
    }

    .chat-panel ~ .local-video-container {
        display: none;
    }
}

/* Auth pages styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 20px;
}

.auth-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.auth-card .form-group {
    margin-bottom: 20px;
}

.auth-card .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.auth-card .form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.auth-card .form-control:focus {
    outline: none;
    border-color: #1b6ec2;
    box-shadow: 0 0 0 3px rgba(27, 110, 194, 0.1);
}

.auth-card .btn-block {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 10px;
}

.auth-card .alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.auth-card .alert-danger {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.auth-footer p {
    margin: 0;
    color: #666;
}

.auth-footer a {
    color: #1b6ec2;
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.validation-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

/* Video placeholder for when video is disabled */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a2a;
}

.avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
}

.local-video-container.video-disabled {
    background: #2a2a2a;
}

.local-video-container.video-disabled .avatar-circle {
    width: 60px;
    height: 60px;
    font-size: 20px;
}

.video-placeholder .avatar-image {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.local-video-container.video-disabled .avatar-image {
    width: 60px;
    height: 60px;
}

/* Participants panel */
.participants-panel {
    position: fixed;
    left: 20px;
    bottom: 100px;
    width: 320px;
    max-height: 500px;
    background: #2a2a2a;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.participants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #3a3a3a;
    border-radius: 8px 8px 0 0;
    color: #fff;
    font-weight: 500;
}

.admin-section {
    padding: 8px 12px;
    border-bottom: 1px solid #444;
}

.participants-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.participants-section {
    margin-bottom: 12px;
}

.section-header {
    color: #888;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 8px 8px 4px;
    letter-spacing: 0.5px;
}

.participant-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: #3a3a3a;
}

.participant-item.self {
    background: #2d4a3e;
}

.participant-item.offline {
    opacity: 0.6;
}

.participant-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.participant-avatar.online {
    box-shadow: 0 0 0 2px #28a745;
}

.participant-avatar.offline {
    background: #555;
}

.participant-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.participant-name {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-badge {
    background: #ffc107;
    color: #000;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.you-badge {
    color: #888;
    font-size: 11px;
    font-weight: 400;
}

.participant-status {
    display: flex;
    gap: 4px;
}

.status-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.status-icon.muted {
    background: #dc3545;
    color: #fff;
}

.status-icon.video-off {
    background: #fd7e14;
    color: #fff;
}

.last-seen {
    color: #888;
    font-size: 11px;
}

.participant-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.participant-actions .btn {
    font-size: 10px;
    padding: 3px 8px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    min-width: 300px;
    max-width: 400px;
}

.modal-content h5 {
    margin-bottom: 16px;
    color: #333;
}

.modal-content label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

@media (max-width: 768px) {
    .participants-panel {
        left: 10px;
        right: 10px;
        width: auto;
        bottom: 80px;
        max-height: 300px;
    }

    .participant-actions {
        flex-direction: column;
    }

    .participant-actions .btn {
        width: 100%;
    }
}

/* Chat avatars */
.chat-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.chat-message-body {
    flex: 1;
    min-width: 0;
}

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

/* Participant avatar images */
.participant-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.participant-avatar-img.online {
    box-shadow: 0 0 0 2px #28a745;
}

.participant-avatar-img.offline {
    filter: grayscale(50%);
    opacity: 0.7;
}

/* MagicPatterns Design Animations */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

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

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

@keyframes slideInUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

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

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.animate-slideInRight {
    animation: slideInRight 0.3s ease-out forwards;
}

.animate-slideInLeft {
    animation: slideInLeft 0.3s ease-out forwards;
}

.animate-slideOutLeft {
    animation: slideOutLeft 0.3s ease-out forwards;
}

.animate-slideOutRight {
    animation: slideOutRight 0.3s ease-out forwards;
}

.animate-slideInUp {
    animation: slideInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out forwards;
}

.animate-scaleIn {
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.animate-pulse-slow {
    animation: pulse 2s ease-in-out infinite;
}

/* Control button hover effects */
.control-btn {
    transition: transform 0.15s ease, background-color 0.2s ease;
}

.control-btn:hover {
    transform: scale(1.1);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Avatar-only tiles on mobile - compact but wide */
@media (max-width: 768px) {
    .avatar-only {
        max-width: 100% !important;
        max-height: 180px !important;
        min-height: 140px !important;
        aspect-ratio: auto !important;
    }
}

/* Speaking indicator pulse animation */
@keyframes speakingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(107, 207, 127, 0.7);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(107, 207, 127, 0);
    }
}

.speaking {
    animation: speakingPulse 1s ease-in-out infinite;
}

/* Draggable local video tile */
.draggable-tile {
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.draggable-tile:active {
    cursor: grabbing;
}

.draggable-tile.dragging {
    opacity: 0.9;
    z-index: 100 !important;
}

/* Hide scrollbar for screen share thumbnail strip */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}