/* =========================================
   Base & Resets
========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;

    --pros-color: #3b82f6;
    --cons-color: #ef4444;

    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Pretendard', sans-serif;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 480px;
    /* Mobile App Size */
    height: 100vh;
    background: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* For larger screens, simulate tablet/desktop for Host */
@media (min-width: 768px) {
    #app {
        max-width: 1024px;
        height: 90vh;
        border-radius: 20px;
    }
}

.view {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
    background: var(--light);
}

.view.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   Typography & Components
========================================= */
h1,
h2,
h3 {
    color: var(--text-main);
    font-weight: 800;
}

p {
    color: var(--text-muted);
    line-height: 1.5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    width: 100%;
}

.btn-round {
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.btn-icon:hover {
    color: var(--primary);
}

.text-danger {
    color: var(--danger) !important;
    font-size: 0.9rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.input-group label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.input-group input {
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 1rem;
    font-family: inherit;
    transition: 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
    outline: none;
}

.app-header {
    background: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.content-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

/* =========================================
   Entry Screen
========================================= */
#entry-screen {
    justify-content: center;
    align-items: center;
    padding: 40px;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

.logo-container {
    text-align: center;
    margin-bottom: 60px;
}

.main-logo-icon {
    width: 64px;
    height: 64px;
    color: var(--primary);
    margin-bottom: 16px;
    display: none;
}

.brand-logo {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary);
    position: relative;
    display: inline-flex;
    align-items: flex-end;
    margin-bottom: 4px;
    letter-spacing: -2px;
}

.brand-logo .deb,
.brand-logo .ate {
    text-transform: lowercase;
}

.brand-logo .m-insert {
    color: var(--secondary);
    font-size: 2.5rem;
    position: absolute;
    top: -20px;
    left: 48%;
    /* Adjust to sit exactly between b and a */
    transform: translateX(-50%);
    text-transform: uppercase;
    text-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Red glowing checkmark insertion mark (like sketch) */
.brand-logo .m-insert::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 45%;
    transform: translateX(-50%) rotate(40deg);
    width: 20px;
    height: 50px;
    border-right: 6px solid #ff0000;
    border-bottom: 6px solid #ff0000;
    border-radius: 4px;
    filter: drop-shadow(0px 0px 6px rgba(255, 0, 0, 0.8));
    z-index: -1;
}

.logo-container h1 {
    font-size: 1.8rem;
    letter-spacing: -1px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.role-selection {
    width: 100%;
    max-width: 320px;
}

.role-selection .divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.role-selection .divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: var(--border);
}

.role-selection .divider span {
    position: relative;
    background: #ebedee;
    padding: 0 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* =========================================
   Host Dashboard
========================================= */
.host-theme {
    background: #0f172a;
    color: white;
    justify-content: space-between;
}

.room-info {
    display: flex;
    flex-direction: column;
}

.room-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.room-code {
    font-size: 1.8rem;
    letter-spacing: 2px;
}

.dashboard-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: #f8fafc;
    overflow-y: auto;
}

.topic-banner {
    background: white;
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-soft);
}

.topic-banner h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.topic-banner h1 {
    font-size: 1.8rem;
    word-break: keep-all;
}

.debate-arena {
    display: flex;
    gap: 20px;
    flex: 1;
}

/* Responsive arena for desktop/host */
@media (max-width: 767px) {
    .debate-arena {
        flex-direction: column;
    }
}

.team-panel {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-soft);
}

.pros-panel h2 {
    color: var(--pros-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cons-panel h2 {
    color: var(--cons-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--light);
    color: var(--text-muted);
}

.status-indicator.ready {
    background: #dcfce7;
    color: #166534;
}

.center-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.timer {
    font-size: 3.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--dark);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.moderator-card {
    background: #f1f5f9;
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    max-width: 300px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.moderator-card i {
    color: var(--primary);
    fill: rgba(79, 70, 229, 0.1);
    width: 32px;
    height: 32px;
}

.moderator-card p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

/* =========================================
   Join & Role Selection
========================================= */
.role-cards {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.role-card {
    flex: 1;
    cursor: pointer;
    position: relative;
}

.role-card input {
    display: none;
}

.role-card .card-content {
    background: white;
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
}

.role-card input:checked+.card-content {
    border-color: var(--primary);
    background: #eff6ff;
}

.role-card.pros input:checked+.card-content {
    border-color: var(--pros-color);
    color: var(--pros-color);
}

.role-card.cons input:checked+.card-content {
    border-color: var(--cons-color);
    color: var(--cons-color);
}

.role-card i {
    width: 40px;
    height: 40px;
}

.role-card span {
    font-weight: 800;
    font-size: 1.1rem;
}

/* =========================================
   Scaffold Slider (Windows Security Style)
========================================= */
.security-slider-container {
    display: flex;
    gap: 24px;
}

.slider-area {
    width: 60px;
    display: flex;
    justify-content: center;
    position: relative;
}

.slider-track {
    position: relative;
    width: 8px;
    background: #cbd5e1;
    border-radius: 4px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: height 0.3s ease;
}

input[type=range][orient=vertical] {
    appearance: slider-vertical;
    width: 40px;
    height: 300px;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    z-index: 5;
}

.slider-markers {
    position: absolute;
    left: 16px;
    height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.marker {
    color: var(--text-muted);
    font-weight: 800;
    font-size: 1rem;
}

.level-info-area {
    flex: 1;
}

.level-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--primary);
}

.level-header i {
    width: 28px;
    height: 28px;
}

.level-desc {
    font-size: 0.95rem;
    margin-bottom: 24px;
    background: white;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.persona-status-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.persona-status {
    display: flex;
    gap: 12px;
    align-items: center;
    background: white;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: 0.3s;
}

.p-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
}

.p-icon img {
    width: 24px;
    height: 24px;
}

.p-text {
    display: flex;
    flex-direction: column;
}

.p-text strong {
    font-size: 0.9rem;
}

.p-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.p-text span.highlight {
    color: var(--primary);
    font-weight: 600;
}

.bottom-actions {
    padding: 24px;
    background: white;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

/* =========================================
   Participant Workspace
========================================= */
.student-theme {
    background: var(--primary);
    color: white;
    justify-content: space-between;
}

.team-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.timer-mini {
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.topic-banner.mini {
    padding: 12px 20px;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.topic-banner.mini .label {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
}

.topic-banner.mini strong {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-dock {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--border);
}

.dock-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: 0.2s;
    color: var(--text-muted);
    opacity: 0.6;
}

.dock-btn.active {
    border-bottom-color: var(--primary);
    opacity: 1;
    color: var(--primary);
    background: #f8fafc;
}

.dock-btn img {
    width: 24px;
    height: 24px;
    filter: invert(0.5);
}

.dock-btn.active img {
    filter: invert(0.2) sepia(1) saturate(5) hue-rotate(220deg);
}

.dock-btn span {
    font-size: 0.75rem;
    font-weight: 600;
}

.tab-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    overflow: hidden;
    /* Fix layout boundary */
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    /* Required for scrolling */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bubble {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chat-bubble.ai {
    background: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-bubble.ai p strong {
    color: var(--primary);
    font-size: 0.85rem;
    display: inline-block;
    margin-bottom: 4px;
}

.chat-bubble.student {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble .ai-thinking {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.chat-bubble .ai-thinking span {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-bubble .ai-thinking span:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-bubble .ai-thinking span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.input-area {
    padding: 16px;
    background: white;
    display: flex;
    gap: 12px;
    align-items: center;
    border-top: 1px solid var(--border);
}

.input-area input {
    flex: 1;
    border: none;
    background: #f1f5f9;
    padding: 14px 20px;
    border-radius: 24px;
    font-size: 0.95rem;
}

.input-area input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* =========================================
   Settings Modal
========================================= */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.2s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.2rem;
}

.modal-body {
    padding: 20px;
}

.modal-desc {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}