/* ============================================================================
   Live Q&A - TechTools
   Mobile-First Design - Optimized for Participant Experience
   ============================================================================ */

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --secondary-dark: #059669;
    --background: #0f0f1a;
    --surface: #1a1a2e;
    --surface-light: #252542;
    --surface-hover: #2d2d4a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden {
    display: none !important;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

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

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

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

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

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

.btn-full {
    width: 100%;
}

/* ============================================================================
   Landing Section
   ============================================================================ */

#landingSection {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.section {
    min-height: 100%;
    padding: 0;
}

.landing-header {
    padding: 10px 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color var(--transition);
}

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

.landing-content {
    text-align: center;
    padding: 40px 0;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
}

.landing-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 48px;
}

/* Action Cards */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 700px;
    margin: 0 auto;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    transition: all var(--transition);
}

.action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.card-icon.create {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.card-icon.join {
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
}

.action-card h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.action-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.action-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-card input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: all var(--transition);
}

.action-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

/* ============================================================================
   Event Section - Mobile-First Layout
   ============================================================================ */

#eventSection {
    height: 100%;
    overflow: hidden;
}

.event-layout {
    display: flex;
    height: 100%;
}

.event-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* ============================================================================
   Compact Event Header
   ============================================================================ */

.event-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.event-title-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.event-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.event-code-badge {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Host-only button (QR toggle) - hidden by default */
.host-only {
    display: none;
}

/* ============================================================================
   Status Banner
   ============================================================================ */

.status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.15);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================================================
   Questions Container (Scrollable)
   ============================================================================ */

.questions-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

/* Toolbar */
.questions-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 16px;
}

.questions-count-display {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.questions-count-display span {
    color: var(--text-primary);
    font-weight: 700;
}

/* ============================================================================
   Questions List
   ============================================================================ */

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Question Card - Mobile Optimized */
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: border-color var(--transition);
}


.question-content {
    display: flex;
    gap: 14px;
}

/* Vote Section - Large Touch Target */
.vote-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vote-btn {
    width: 56px;
    height: 56px;
    background: var(--surface-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.vote-btn.voted {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.vote-count {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

/* Question Body */
.question-body {
    flex: 1;
    min-width: 0;
}

.question-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 10px;
    word-break: break-word;
}

.question-meta-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.author-name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.author-name i {
    color: var(--primary);
}

.question-time {
    color: var(--text-muted);
    font-size: 12px;
}


/* Host Actions */
.question-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn span {
    display: none;
}

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

.action-btn.delete:hover,
.action-btn.delete:active {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: var(--danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 60px 20px;
}

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

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

/* ============================================================================
   Ask Question Section - Fixed Bottom
   ============================================================================ */

.ask-section {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.ask-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ask-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.name-input {
    flex: 1;
    padding: 12px 14px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color var(--transition);
}

.name-input:focus {
    outline: none;
    border-color: var(--primary);
}

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

.question-input {
    flex: 1;
    padding: 12px 14px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color var(--transition);
}

.question-input:focus {
    outline: none;
    border-color: var(--primary);
}

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

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

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

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

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================================
   Host Sidebar
   ============================================================================ */

.host-sidebar {
    width: 320px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-light) 100%);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 10;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.sidebar-qr {
    margin-bottom: 20px;
}

.qr-display {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.qr-display img {
    max-width: 160px;
    width: 100%;
}

.sidebar-code {
    text-align: center;
    margin-bottom: 16px;
}

.sidebar-code .code-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.code-big {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--primary);
    background: var(--surface-light);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-family: 'Courier New', monospace;
}

.sidebar-link {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-link .link-label {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.link-url {
    color: var(--text-secondary);
    font-size: 13px;
    word-break: break-all;
}

.sidebar-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 24px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
}

.sidebar-controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

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

.modal-content h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.modal-content h2 i {
    color: var(--primary);
}

.modal-content > p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.share-code-display,
.share-link-display,
.qr-section {
    margin-bottom: 20px;
}

.code-label,
.link-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.code-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary);
    background: var(--surface-light);
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
}

.link-input-wrapper {
    display: flex;
    gap: 10px;
}

.link-input-wrapper input {
    flex: 1;
    padding: 12px 14px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
}

.qr-code {
    background: white;
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
}

.qr-code img {
    max-width: 150px;
}

/* ============================================================================
   Toast
   ============================================================================ */

.toast {
    position: fixed;
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 100px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast i {
    color: var(--success);
}

/* ============================================================================
   Mobile Styles (< 769px)
   ============================================================================ */

@media (max-width: 768px) {
    /* Landing */
    .landing-content {
        padding: 24px 0;
    }

    .landing-content h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
        margin-bottom: 32px;
    }

    .logo {
        width: 64px;
        height: 64px;
        font-size: 28px;
    }

    .action-cards {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .action-card {
        padding: 24px;
    }

    /* Event Layout */
    .event-layout {
        flex-direction: column;
    }

    /* Host Sidebar - Full Screen Overlay */
    .host-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        border-right: none;
        padding-top: 60px;
    }

    .host-sidebar.visible {
        transform: translateY(0);
    }

    .host-sidebar .sidebar-close-btn {
        display: flex;
    }

    .code-big {
        font-size: 2rem;
        letter-spacing: 4px;
        padding: 14px 16px;
    }

    /* Show QR toggle for host on mobile */
    .host-only {
        display: flex !important;
    }

    /* Header */
    .event-header {
        padding: 10px 12px;
    }

    .event-header h1 {
        font-size: 1rem;
    }

    .event-code-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Questions Container */
    .questions-container {
        padding: 12px;
    }

    /* Vote Button - Extra Large for Touch */
    .vote-btn {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }

    .vote-count {
        font-size: 20px;
    }

    /* Question Card */
    .question-card {
        padding: 14px;
    }

    .question-content {
        gap: 12px;
    }

    .question-text {
        font-size: 15px;
    }

    /* Host action buttons - larger on mobile for touch */
    .question-actions {
        gap: 8px;
    }

    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    /* Ask Section */
    .ask-section {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .ask-form {
        gap: 8px;
    }

    .ask-input-row {
        gap: 8px;
    }

    .name-input,
    .question-input {
        padding: 10px 12px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* Modal */
    .modal-content {
        padding: 24px;
        max-width: none;
        margin: 16px;
    }

    .code-value {
        font-size: 1.5rem;
        letter-spacing: 3px;
    }
}

/* ============================================================================
   Small Phones (< 400px)
   ============================================================================ */

@media (max-width: 400px) {
    .container {
        padding: 12px;
    }

    .landing-content h1 {
        font-size: 1.5rem;
    }

    .action-card {
        padding: 20px;
    }

    .card-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .event-header {
        gap: 8px;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .event-code-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .vote-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .vote-count {
        font-size: 18px;
    }

    .question-text {
        font-size: 14px;
    }

    .author-name,
    .question-time {
        font-size: 11px;
    }

    .toast {
        left: 12px;
        right: 12px;
        transform: translateX(0) translateY(100px);
        width: auto;
    }

    .toast.show {
        transform: translateX(0) translateY(0);
    }
}

/* ============================================================================
   Desktop Host View Adjustments
   ============================================================================ */

@media (min-width: 769px) {
    /* QR toggle button not needed on desktop - sidebar always visible */
    .host-only {
        display: none !important;
    }
}

/* ============================================================================
   Touch-Friendly States
   ============================================================================ */

@media (hover: none) {
    .btn:hover {
        transform: none;
    }

    .action-card:hover {
        transform: none;
    }

    .vote-btn:hover {
        transform: none;
        border-color: var(--border);
        color: var(--text-secondary);
    }

    .vote-btn.voted:hover {
        border-color: var(--primary);
        color: white;
    }

    .btn:active {
        transform: scale(0.98);
        opacity: 0.9;
    }

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

    .action-card:active {
        transform: scale(0.99);
    }
}

/* ============================================================================
   Safe Area Support
   ============================================================================ */

@supports (padding: max(0px)) {
    .event-header {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .questions-container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .ask-section {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}
