/* ODE Meet - Video Conferencing UI */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f0f23;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --text-primary: #f3f4f6;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.5);
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #9ca3af;
        --text-secondary: #f3f4f6;
        --text-muted: #e5e7eb;
        --focus-ring: 0 0 0 3px #ffffff, 0 0 0 5px #000000;
    }

    .control-btn,
    .btn,
    .reaction,
    .layout-option,
    .menu-item {
        border: 2px solid var(--border-color);
    }

    .control-btn.active,
    .control-btn.muted {
        border-color: #ffffff;
    }

    .video-tile.speaking {
        box-shadow: 0 0 0 4px #ffffff, 0 0 0 6px #10b981;
    }

    kbd {
        border: 2px solid var(--border-color);
    }
}

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

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible styles for keyboard navigation */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

#app {
    width: 100vw;
    height: 100vh;
}

.page {
    display: none;
    width: 100%;
    height: 100%;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   Landing Page
   ============================================ */

#landing {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.landing-header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 3rem;
}

.logo-text {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.meeting-actions {
    display: flex;
    align-items: stretch;
    gap: 2rem;
    max-width: 900px;
}

.action-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
}

.action-card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.action-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.action-card input {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.action-card input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--focus-ring);
}

.action-card input:focus-visible {
    border-color: var(--accent-primary);
    box-shadow: var(--focus-ring);
}

.action-card input::placeholder {
    color: var(--text-muted);
}

/* Form field wrapper */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.field-error {
    font-size: 0.75rem;
    color: var(--accent-danger);
    min-height: 1em;
}

.field-error:not(:empty) {
    margin-top: 0.25rem;
}

/* Input validation states */
.action-card input:invalid:not(:placeholder-shown) {
    border-color: var(--accent-danger);
}

.action-card input:valid:not(:placeholder-shown) {
    border-color: var(--accent-success);
}

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

.options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.divider {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.btn {
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:focus-visible {
    box-shadow: var(--focus-ring), 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading state for buttons */
.btn .btn-loading {
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loading {
    display: inline;
}

.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* Link-style button */
.btn-link {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.875rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.btn-link:hover {
    color: var(--text-primary);
}

.btn-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.hidden {
    display: none !important;
}

.landing-footer {
    position: absolute;
    bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Meeting title in header */
.meeting-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* ============================================
   Meeting Room
   ============================================ */

#meeting-room {
    background: var(--bg-tertiary);
}

.meeting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

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

#meeting-title-display {
    font-weight: 600;
}

.meeting-id {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.meeting-timer {
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--text-secondary);
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
    margin-right: 1rem;
}

.meeting-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    color: var(--text-secondary);
}

#recording-indicator {
    color: var(--accent-danger);
    animation: pulse 2s infinite;
}

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

.meeting-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Video Grid Layouts */
.video-grid {
    flex: 1;
    display: grid;
    gap: 0.5rem;
    padding: 0.5rem;
    overflow: hidden;
}

.layout-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: minmax(200px, 1fr);
}

.layout-speaker {
    grid-template-columns: 1fr 200px;
    grid-template-rows: 1fr;
}

.layout-speaker .video-tile:first-child {
    grid-row: 1 / -1;
}

.layout-spotlight {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 100px;
}

.layout-spotlight .video-tile:first-child {
    grid-row: 1;
}

.layout-spotlight .video-thumbnails {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

/* Video Tile */
.video-tile {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-height: 150px;
}

.video-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-tile .participant-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-tile .participant-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.video-tile .participant-status {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.video-tile.speaking {
    box-shadow: 0 0 0 3px var(--accent-success);
}

.video-tile.screen-share {
    grid-column: span 2;
    grid-row: span 2;
}

.video-tile .no-video {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.video-tile .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
}

/* Participants List */
.participant-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.participant-item:hover {
    background: var(--bg-tertiary);
}

.participant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.participant-details {
    flex: 1;
}

.participant-details .name {
    font-weight: 500;
}

.participant-details .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Chat */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
}

.chat-message .sender {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.chat-message .time {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.chat-message .content {
    color: var(--text-secondary);
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-input button {
    padding: 0.625rem 1rem;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
}

/* Controls */
.meeting-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.controls-left,
.controls-center,
.controls-right {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--border-color);
}

.control-btn:focus-visible {
    box-shadow: var(--focus-ring);
}

.control-btn .icon {
    font-size: 1.25rem;
}

.control-btn .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.control-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.control-btn.muted {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
}

.control-btn-danger {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
}

.control-btn-danger:hover {
    background: #dc2626;
}

/* Popups */
.popup {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 1000;
}

#reaction-picker {
    display: flex;
    gap: 0.25rem;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
}

.reaction {
    padding: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: transform 0.1s;
}

.reaction:hover {
    transform: scale(1.2);
    background: var(--bg-tertiary);
}

#layout-picker,
#more-menu {
    bottom: 80px;
    right: 20px;
    min-width: 200px;
}

.layout-option,
.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    border-radius: var(--radius-sm);
}

.layout-option:hover,
.menu-item:hover {
    background: var(--bg-tertiary);
}

.layout-icon {
    font-size: 1.25rem;
}

/* Floating Reactions */
.floating-reactions {
    position: fixed;
    bottom: 100px;
    left: 0;
    right: 0;
    pointer-events: none;
    overflow: hidden;
    height: 300px;
}

.floating-reaction {
    position: absolute;
    font-size: 2rem;
    animation: float-up 3s ease-out forwards;
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-200px) scale(1.5);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: toast-in 0.3s ease;
}

.toast.toast-exit {
    animation: toast-out 0.3s ease forwards;
}

.toast-success {
    border-left: 3px solid var(--accent-success);
}

.toast-error {
    border-left: 3px solid var(--accent-danger);
}

.toast-warning {
    border-left: 3px solid var(--accent-warning);
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

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

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

/* Modal / Dialog */
.modal {
    background: transparent;
    border: none;
    padding: 0;
    max-width: 480px;
    width: 90%;
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.125rem;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-close:focus-visible {
    box-shadow: var(--focus-ring);
}

.modal-body {
    padding: 1.5rem;
}

/* Keyboard Shortcuts List */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.shortcut-item dt {
    flex-shrink: 0;
}

.shortcut-item dd {
    color: var(--text-secondary);
}

kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.875rem;
    min-width: 2rem;
    text-align: center;
}

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.connection-status.connecting .connection-icon::before {
    content: "...";
    animation: connecting-dots 1.5s infinite;
}

.connection-status.reconnecting {
    border-color: var(--accent-warning);
}

.connection-status.disconnected {
    border-color: var(--accent-danger);
}

@keyframes connecting-dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Badge for unread counts */
.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent-danger);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.control-btn {
    position: relative;
}

/* Sidebar header with h2 */
.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 9999;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .meeting-actions {
        flex-direction: column;
    }

    .divider {
        padding: 1rem 0;
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
    }

    .control-btn .label {
        display: none;
    }

    .control-btn {
        padding: 0.75rem;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

/* Print styles */
@media print {
    .meeting-controls,
    .sidebar,
    .popup,
    .toast-container,
    .connection-status {
        display: none !important;
    }
}

/* Participants list styling */
.participants-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Video tile focus styles for keyboard navigation */
.video-tile:focus {
    outline: none;
    box-shadow: var(--focus-ring);
}

.video-tile:focus-visible {
    box-shadow: var(--focus-ring);
}

/* Hand raise indicator */
.control-btn.active .icon {
    animation: hand-wave 0.5s ease-in-out;
}

@keyframes hand-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Ensure visible focus for all interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Color-blind friendly active speaker indicator */
.video-tile.speaking::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: var(--accent-success);
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse-speaking 1.5s ease-in-out infinite;
}

@keyframes pulse-speaking {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Hand raised indicator on video tile */
.video-tile.hand-raised::before {
    content: '✋';
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 1.5rem;
    z-index: 10;
    animation: hand-pulse 2s ease-in-out infinite;
}

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