@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #070709;
    --bg-card: #121217;
    --bg-panel: #18181e;
    --accent: #f97316;
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --secondary: #0ea5e9;
    --text-high: #ffffff;
    --text-mid: #94a3b8;
    --text-low: #475569;
    --danger: #ef4444;
    --success: #10b981;
    --glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-high);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout Utils --- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.8rem;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    gap: 0.75rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    box-shadow: 0 8px 20px var(--primary-glow);
}
.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px var(--primary-glow);
}

.btn-outline {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-high);
}

.btn-danger-sm {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-sm:hover {
    background: var(--danger);
    color: white;
}

.btn-outline-sm {
    background: var(--glass);
    color: var(--text-high);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline-sm:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Dashboard Page Styles --- */
.dashboard-page {
    min-height: 100vh;
    background: var(--bg-dark);
}

.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(14, 165, 233, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(249, 115, 22, 0.05) 0%, transparent 50%);
    z-index: -1;
}

.dashboard-page header {
    padding: 1.5rem 0;
    background: rgba(24, 24, 30, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.hero-section {
    text-align: center;
    padding: 4rem 0;
}

.hero-section h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--text-high), var(--text-mid));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-section p {
    font-size: 1.1rem;
    color: var(--text-mid);
    max-width: 600px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.1);
}

.card-icon {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-high);
}

.card p {
    color: var(--text-mid);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.join-form input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    color: var(--text-high);
    outline: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.join-form input:focus {
    border-color: var(--primary);
}

.features-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-mid);
    font-size: 0.9rem;
    font-weight: 500;
}

/* --- Auth Pages --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-container { width: 100%; max-width: 420px; padding: 2rem; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 3rem;
    text-align: center;
}
.auth-card h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group { text-align: left; margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-mid); margin-bottom: 0.5rem; }
.form-group input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    padding: 0.85rem 1.1rem;
    border-radius: 14px;
    color: white;
    outline: none;
    transition: 0.3s;
}
.form-group input:focus { border-color: var(--primary); }

.btn-auth {
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 1rem;
    border-radius: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    margin-top: 1rem;
}

/* --- Session Page --- */
.session-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #000;
    overflow: hidden;
}

.session-header {
    height: 64px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.main-layout {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.workspace-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    min-width: 0;
    transition: margin-right 0.3s ease;
}

.video-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.5s ease;
}

/* Screen Sharing Active Styles */
.video-wrapper.sharing-active {
    box-shadow: inset 0 0 50px rgba(14, 165, 233, 0.2);
}

.video-wrapper.sharing-active::after {
    content: "LIVE SCREEN SHARE";
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--secondary);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    z-index: 10;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#remote-video { max-width: 100%; max-height: 100%; transition: transform 0.3s ease; }
.sharing-active #remote-video { transform: scale(0.98); }

.session-footer {
    height: 80px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
}

.control-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-high);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.control-btn.sharing-btn-active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
    animation: pulse-secondary 2s infinite;
}

@keyframes pulse-secondary {
    0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(14, 165, 233, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}

.local-preview {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 20;
}

.local-preview video { width: 100%; height: 100%; object-fit: cover; }

.local-preview .label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    font-size: 0.7rem;
    text-align: center;
    font-weight: 600;
}

/* Chat Panel */
.chat-panel {
    position: fixed;
    top: 64px;
    right: -380px;
    width: 380px;
    height: calc(100vh - 64px - 80px); /* Adjust for header and footer on desktop */
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 90;
    transition: right 0.3s ease;
}

.chat-panel.open {
    right: 0;
}

/* Adjustments for sliding chat panel in desktop */
@media (min-width: 769px) {
    .chat-panel {
        height: calc(100vh - 64px - 80px);
    }
}

.file-preview-container {
    position: absolute;
    bottom: 75px;
    left: 1.25rem;
    right: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    display: none;
    z-index: 100;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
}

.file-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

#preview-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--bg-dark);
}

.preview-info {
    flex: 1;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-mid);
}

.close-preview {
    cursor: pointer;
    color: var(--danger);
    padding: 5px;
    display: flex;
    align-items: center;
}

.chat-image-preview {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid var(--border);
}

.chat-image-preview:hover {
    border-color: var(--primary);
    transform: scale(1.02);
}

.chat-iframe-preview {
    width: 100%;
    height: 200px;
    border: none;
    border-radius: 8px;
    margin-top: 8px;
    background: #fff;
}

#annotation-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }

/* --- Enhanced Session Page UI --- */
.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: var(--success);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.session-code {
    font-size: 0.9rem;
    color: var(--text-mid);
    cursor: pointer;
    transition: all 0.2s;
    padding: 6px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.session-code:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
}

.status-connecting {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-mid);
    font-size: 0.85rem;
}

.status-connected {
    color: var(--success);
}

.status-error {
    color: var(--danger);
}

.status-error .pulse {
    background: var(--danger);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--text-mid);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

.status-connected .pulse {
    background: var(--success);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rdp-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
    border-left: 1px solid var(--border);
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-high);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-highlight {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.btn-highlight:hover {
    background: #0284c7;
    transform: scale(1.05);
}

/* Chat Panel Styles */
.chat-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.chat-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-high);
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-dark);
}

.chat-message {
    margin-bottom: 1rem;
    animation: slideIn 0.3s ease;
    padding: 0.75rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.chat-message.sent {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.2);
    margin-left: 1rem;
}

.chat-message.received {
    background: var(--bg-dark);
    margin-right: 1rem;
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-author {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.message-content {
    font-size: 0.85rem;
    color: var(--text-mid);
    line-height: 1.4;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-low);
    margin-top: 4px;
}

.file-link {
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 8px;
    margin-top: 0.5rem;
    transition: all 0.2s;
}

.file-link:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-high);
}

.chat-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-panel);
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-attach-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--text-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-attach-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-high);
}

#chat-input {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-high);
    outline: none;
    transition: all 0.2s;
    font-size: 0.85rem;
}

#chat-input:focus {
    border-color: var(--primary);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #7c3aed;
    transform: scale(1.05);
}

/* Remote Cursor Styles */
#remote-cursor {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transition: all 0.1s ease;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.5);
}

#keystroke-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: monospace;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

#keystroke-overlay.show {
    opacity: 1;
}

/* Waiting Room Overlay */
.waiting-room-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 7, 9, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.waiting-room-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.waiting-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.waiting-icon {
    margin-bottom: 1.5rem;
    color: var(--primary);
    opacity: 0.8;
}

.waiting-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-high);
}

.waiting-content p {
    color: var(--text-mid);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.waiting-session-code {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    font-size: 0.9rem;
}

.waiting-session-code span {
    color: var(--text-mid);
    display: block;
    margin-bottom: 0.5rem;
}

.waiting-session-code strong {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 800;
}

/* --- Responsive Design --- */
@media (max-width: 1024px) {
    .local-preview {
        width: 160px;
    }
}

@media (max-width: 768px) {
    .session-header {
        padding: 0 1rem;
        height: 56px;
    }
    
    .header-left .logo {
        font-size: 1rem;
        margin-right: 0.5rem;
    }
    
    .session-code {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
    
    .session-code b {
        font-size: 0.8rem;
    }
    
    .header-center {
        display: none;
    }
    
    .header-right button {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .header-right #share-link {
        margin-right: 0.25rem;
    }
    
    .local-preview {
        width: 120px;
        bottom: 70px;
        right: 10px;
    }
    
    .session-footer {
        height: 60px;
        padding: 0 1rem;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(24, 24, 30, 0.95);
        backdrop-filter: blur(10px);
    }
    
    .controls-group {
        gap: 0.5rem;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .rdp-tools {
        display: none;
    }
    
    .chat-panel {
        top: 56px;
        right: -100%;
        width: 100%;
        max-width: 380px;
        height: calc(100vh - 56px - 60px);
        background: var(--bg-panel);
        border-left: none;
        border-top: 1px solid var(--border);
    }
    
    .chat-panel.open {
        right: 0;
    }
    
    .chat-toggle {
        display: block;
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--primary);
        border: none;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 101;
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
        transition: all 0.2s;
    }
    
    .chat-toggle:hover {
        transform: scale(1.1);
        background: #7c3aed;
    }
    
    .chat-toggle.has-messages {
        animation: chat-pulse 2s infinite;
    }
    
    @keyframes chat-pulse {
        0%, 100% { box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4); }
        50% { box-shadow: 0 4px 20px rgba(139, 92, 246, 0.8); }
    }
}

@media (max-width: 480px) {
    .session-header {
        padding: 0 0.75rem;
    }
    
    .header-left .logo {
        font-size: 0.9rem;
    }
    
    .badge {
        font-size: 0.6rem;
        padding: 2px 6px;
    }
    
    .session-footer {
        padding: 0 0.75rem;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    .control-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .local-preview {
        width: 100px;
        bottom: 70px;
        right: 5px;
    }
    
    .chat-panel {
        max-width: 100%;
    }
}

/* Hide chat toggle on desktop if footer chat toggle is used */
@media (min-width: 769px) {
    .chat-toggle {
        display: none;
    }
}

/* --- Dashboard Responsive Updates --- */
@media (max-width: 768px) {
    .dashboard-page header {
        padding: 1rem;
    }
    
    .dashboard-page header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .action-cards {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .features-bar {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .hero-section p {
        font-size: 0.9rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .card h2 {
        font-size: 1.2rem;
    }
    
    .card p {
        font-size: 0.85rem;
    }
}
