/* ========================================
   ActiveSlide — Premium Dark UI
   ======================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8); }
    70% { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

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

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes wordAppear {
    from { opacity: 0; transform: scale(0.3) rotate(-10deg); }
    to { opacity: 1; transform: scale(1) rotate(var(--rotate, 0deg)); }
}

/* ---- Reset & Tokens ---- */
:root {
    --bg: #0a0a0f;
    --bg-card: #14141c;
    --bg-card-hover: #1a1a26;
    --bg-input: #1a1a26;
    --border: #2a2a3a;
    --text: #f0f0f5;
    --text-muted: #8888a0;
    --accent: #00d4aa;
    --accent-hover: #00b894;
    --accent-glow: rgba(0, 212, 170, 0.15);
    --blue: #4ea8de;
    --pink: #f472b6;
    --orange: #fb923c;
    --yellow: #facc15;
    --red: #f87171;
    --cyan: #22d3ee;
    --lime: #a3e635;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */
.app-header {
    background: var(--bg-card);
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(20, 20, 28, 0.85);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 300;
    letter-spacing: -0.02em;
}

.logo strong {
    font-weight: 700;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--bg);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 800;
}

/* ---- Container ---- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow);
    animation: fadeIn 0.4s ease-out;
}

/* ---- Create Page ---- */
.creation-card {
    max-width: 480px;
    margin: 10vh auto 0;
    text-align: center;
}

.creation-card h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}

.creation-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"], textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color var(--transition);
    outline: none;
}

input[type="text"]:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

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

.btn-large {
    width: 100%;
    font-size: 1.1rem;
    padding: 1rem;
    border-radius: var(--radius);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.full-width { width: 100%; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.text-center { text-align: center; }

/* ====================================
   DASHBOARD — PRESENTER VIEW
   ==================================== */

.dashboard-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    min-height: calc(100vh - 100px);
}

/* ---- Sidebar ---- */
.control-panel {
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.control-panel h2 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ---- Editable Session Title ---- */
.session-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-card-hover);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.session-name-text {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-name-input {
    flex: 1;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.95rem;
    font-weight: 600;
}

.session-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity var(--transition);
}

.session-edit-btn:hover {
    opacity: 1;
}

/* ---- Activity List ---- */
.activity-list-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.empty-list-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1rem 0;
    opacity: 0.6;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
    animation: fadeIn 0.25s ease-out;
}

.activity-item:hover {
    border-color: rgba(0, 212, 170, 0.3);
    background: var(--bg-card-hover);
}

.activity-item.active {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.08);
}

.activity-item-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    min-width: 0;
}

.activity-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.activity-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-meta {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.activity-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
    opacity: 0;
    transition: all var(--transition);
    flex-shrink: 0;
}

.activity-item:hover .activity-delete {
    opacity: 1;
}

.activity-delete:hover {
    color: var(--red);
}

/* ---- Sidebar Divider ---- */
.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

/* ---- Collapsible Add Forms ---- */
.add-activity-details {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.add-activity-details summary {
    list-style: none;
    cursor: pointer;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    border: none;
    border-radius: var(--radius);
    text-align: left;
    width: 100%;
}

.add-activity-details summary::-webkit-details-marker {
    display: none;
}

.add-activity-details[open] summary {
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.add-form {
    padding: 0.75rem;
}

.add-form-actions {
    margin-top: 0.5rem;
}

.mt-1 { margin-top: 0.25rem; }

.activity-creator h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.activity-creator + .activity-creator {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ---- Projector View ---- */
.projector-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 500px;
    overflow: hidden;
}

/* ---- QR Code — HERO STATE (centered, prominent) ---- */
.qr-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.qr-hero .qr-frame {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 0 60px var(--accent-glow), var(--shadow-lg);
    margin-bottom: 1.5rem;
}

.qr-hero .qr-frame canvas,
.qr-hero .qr-frame img {
    display: block;
}

.qr-hero .qr-instructions {
    margin-top: 0.5rem;
}

.qr-hero .qr-instructions p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.qr-hero .qr-instructions .qr-url {
    color: var(--accent);
    font-weight: 600;
    font-size: 1.2rem;
    word-break: break-all;
}

.qr-hero .qr-instructions .qr-code-label {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 100px;
    color: var(--accent);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.15em;
}

.qr-hero .scan-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    animation: pulse 2s infinite;
}

.qr-hero .scan-hint span {
    font-size: 1.2rem;
    margin-right: 0.25rem;
}

/* ---- QR Code — MINI STATE (bottom-right corner) ---- */
.qr-mini {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    box-shadow: var(--shadow);
    z-index: 10;
    animation: popIn 0.4s ease-out;
}

.qr-mini .qr-frame {
    background: #ffffff;
    border-radius: 6px;
    padding: 4px;
}

.qr-mini .qr-frame canvas,
.qr-mini .qr-frame img {
    display: block;
    width: 90px !important;
    height: 90px !important;
}

.qr-mini .qr-mini-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.qr-mini .qr-mini-info .mini-code {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.qr-mini .qr-mini-info .mini-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Live Activity Area ---- */
.live-activity-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    animation: fadeIn 0.5s ease-out;
}

.activity-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.02em;
}

/* ---- Poll Chart ---- */
#poll-results {
    width: 100%;
    max-width: 800px;
    min-height: 300px;
    height: auto;
    padding: 1rem;
}

/* ---- Word Cloud ---- */
.wordcloud-canvas {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 2rem;
    min-height: 350px;
    width: 100%;
    max-width: 900px;
}

.wordcloud-word {
    display: inline-block;
    font-weight: 700;
    cursor: default;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: wordAppear 0.4s ease-out backwards;
    text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.wordcloud-word:hover {
    transform: scale(1.15) !important;
}

/* ====================================
   PARTICIPANT VIEW (MOBILE-FIRST)
   ==================================== */

.participant-view {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
    min-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.participant-view .session-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.2);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1rem;
}

.participant-view h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.waiting-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.waiting-state .waiting-icon {
    font-size: 3rem;
    animation: float 3s ease-in-out infinite;
}

.waiting-state p {
    font-size: 1.1rem;
}

.waiting-state .waiting-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ---- Participant Poll ---- */
.participant-poll {
    animation: fadeIn 0.4s ease-out;
}

.participant-poll h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.poll-option-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.poll-option-btn:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

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

.poll-option-btn .opt-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--border);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.poll-option-btn:hover .opt-letter {
    background: var(--accent);
    color: var(--bg);
}

/* ---- Participant Word Cloud ---- */
.participant-wordcloud {
    animation: fadeIn 0.4s ease-out;
}

.participant-wordcloud h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.participant-wordcloud .wc-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.word-input-group {
    display: flex;
    gap: 0.5rem;
}

.word-input-group input {
    flex: 1;
}

.word-input-group .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.sent-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.sent-word-tag {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--accent);
    animation: popIn 0.3s ease-out;
}

/* ---- Success Feedback ---- */
.success-feedback {
    animation: popIn 0.4s ease-out;
    padding: 2rem;
}

.success-feedback .check-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.success-feedback h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.success-feedback p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .control-panel {
        position: static;
    }
    .projector-view {
        min-height: 60vh;
    }
}

@media (max-width: 500px) {
    .container {
        padding: 1rem;
    }
    .card {
        padding: 1.25rem;
    }
    .activity-title {
        font-size: 1.3rem;
    }
    .qr-hero .qr-frame {
        padding: 12px;
    }
}

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