/* LunarView Web Viewer Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* LunarView Brand Colors */
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Dark Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-input: #0f0f15;
    --border-default: rgba(255, 255, 255, 0.1);
    --border-subtle: rgba(255, 255, 255, 0.05);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Misc */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Screen Management */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
}

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

/* ================================
   Connect Screen
   ================================ */
#connect-screen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #15151f 100%);
}

.connect-container {
    width: 100%;
    max-width: 380px;
    padding: 24px;
    text-align: center;
}

/* Brand */
.brand {
    margin-bottom: 40px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 24px;
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(139, 92, 246, 0.3);
}

.brand-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.brand-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

/* Connect Form */
.connect-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    text-align: left;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group label svg {
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

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

/* Connect Button */
.btn-connect {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 8px;
}

.btn-connect:active {
    transform: scale(0.98);
}

.btn-connect:hover {
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

/* Error Message */
.error-message {
    font-size: 13px;
    color: var(--error);
    min-height: 20px;
}

/* Server Settings */
.server-settings {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    text-align: left;
}

.server-settings summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
}

.server-settings summary::-webkit-details-marker {
    display: none;
}

.settings-content {
    margin-top: 12px;
}

.settings-content label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.settings-content input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    font-family: monospace;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.connection-status.connecting .status-indicator {
    background: var(--warning);
}

.connection-status.connected .status-indicator {
    background: var(--success);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* ================================
   Viewer Screen
   ================================ */
#viewer-screen.active {
    justify-content: flex-start;
}

/* Viewer Toolbar */
.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 10;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.toolbar-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.connection-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.remote-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.connection-quality {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.quality-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.fps-badge {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

#remote-video,
#remote-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#remote-video {
    background: #000;
}

.canvas-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-muted);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.canvas-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Touch Bar */
.touch-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

.touch-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    font-size: 11px;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.touch-btn:active {
    background: var(--bg-input);
    transform: scale(0.96);
}

.touch-btn svg {
    color: var(--text-muted);
}

/* ================================
   Panels
   ================================ */
.keyboard-panel,
.special-keys-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-default);
    transform: translateY(0);
    transition: transform 0.3s ease;
    z-index: 100;
}

.keyboard-panel.hidden,
.special-keys-panel.hidden {
    transform: translateY(100%);
}

.keyboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
    font-weight: 500;
}

.close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.close-btn:hover {
    background: var(--bg-card);
    color: var(--error);
}

.keyboard-content {
    display: flex;
    gap: 10px;
    padding: 16px;
}

#keyboard-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
}

/* Special Keys Grid */
.special-keys-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
}

.special-key {
    padding: 14px 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.special-key:active {
    background: var(--accent-primary);
    color: white;
    transform: scale(0.96);
}

.special-key.modifier {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--accent-primary);
}

.special-key.modifier.active {
    background: var(--accent-primary);
    color: white;
}

.special-key.combo {
    grid-column: span 2;
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.3);
    color: var(--accent-secondary);
}

/* ================================
   Responsive
   ================================ */
@media (max-width: 480px) {
    .brand-name {
        font-size: 24px;
    }

    .logo-icon {
        width: 64px;
        height: 64px;
        border-radius: 18px;
    }

    .logo-icon svg {
        width: 36px;
        height: 36px;
    }

    .toolbar-center {
        display: none;
    }

    .touch-btn {
        padding: 10px 16px;
    }

    .special-keys-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Fullscreen Mode */
body.fullscreen .viewer-toolbar,
body.fullscreen .touch-bar {
    display: none;
}

body.fullscreen .canvas-container {
    height: 100vh;
}

/* Social Login */
.social-login-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.social-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-social:hover {
    background: var(--bg-input);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-social svg {
    width: 18px;
    height: 18px;
}