/**
 * Quiz Multi-Device Styles
 * Responsive layouts for host, display, and participant views
 */

/* ========================================
   SHARED STYLES
   ======================================== */

/* Animation keyframes */
@keyframes awardPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) translateY(-100px);
        opacity: 0;
    }
}

@keyframes questionEnter {
    0% {
        transform: translateX(100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes scoreUp {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #4ECDC4; }
    100% { transform: scale(1); }
}

@keyframes buzz {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.95); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(78, 205, 196, 0); }
}

/* Error message styling */
.multidevice-error {
    text-align: center;
    padding: 60px 20px;
}

.multidevice-error .error-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #FF6B6B, #ee5a5a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 3rem;
    color: white;
    font-weight: bold;
}

.multidevice-error h2 {
    color: #333;
    margin-bottom: 10px;
}

.multidevice-error p {
    color: #666;
    margin-bottom: 30px;
}

/* ========================================
   QR CODE MODAL
   ======================================== */

.qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.qr-modal {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.qr-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.qr-modal-close:hover {
    opacity: 1;
}

.qr-modal h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
    font-family: 'Fredoka', sans-serif;
}

.qr-codes-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 500px) {
    .qr-codes-container {
        grid-template-columns: 1fr;
    }
}

.qr-code-section {
    text-align: center;
}

.qr-code-section h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1rem;
}

.qr-code-img {
    width: 180px;
    height: 180px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.qr-url {
    font-size: 0.7rem;
    color: #888;
    word-break: break-all;
    margin-top: 10px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

.qr-modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

/* ========================================
   HOST MODE STYLES
   ======================================== */

body.quiz-host-mode {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

body.quiz-host-mode .container {
    max-width: 500px;
    padding: 15px;
}

.host-control-panel {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.host-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #4ECDC4, #44B8AC);
    color: white;
}

.host-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Fredoka', sans-serif;
}

.host-actions {
    display: flex;
    gap: 10px;
}

.host-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    color: white;
    transition: background 0.2s;
}

.host-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.host-progress {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
}

.progress-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #45B7D1);
    transition: width 0.3s ease;
}

.host-question-card {
    padding: 25px 20px;
    border-bottom: 1px solid #eee;
}

.question-number {
    font-size: 0.8rem;
    color: #999;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 1.2rem;
    color: #333;
    line-height: 1.5;
}

.question-answer {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #96CEB4, #88c4a6);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
}

.host-nav-controls {
    display: flex;
    padding: 15px;
    gap: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-btn.prev-btn {
    background: #e0e0e0;
    color: #666;
}

.nav-btn.next-btn {
    background: #4ECDC4;
    color: white;
}

.nav-btn.answer-btn {
    background: #FF6B6B;
    color: white;
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.host-participants-section {
    padding: 20px;
}

.participants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.participants-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

.participant-count {
    background: #4ECDC4;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.no-participants {
    text-align: center;
    padding: 30px;
    color: #999;
    font-style: italic;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid var(--team-color, #4ECDC4);
}

.participant-rank {
    width: 28px;
    height: 28px;
    background: var(--team-color, #4ECDC4);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
}

.participant-info {
    flex: 1;
}

.participant-name {
    font-weight: 500;
    color: #333;
}

.participant-score {
    font-size: 0.85rem;
    color: #666;
}

.participant-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.host-award-section {
    padding: 20px;
    background: #fff9e6;
    border-top: 1px solid #f0e6c8;
}

.host-award-section h3 {
    margin: 0 0 15px;
    font-size: 1rem;
    color: #333;
}

.award-points-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.award-points-input label {
    font-weight: 500;
    color: #666;
}

.award-points-input input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
}

.award-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.award-team-btn {
    padding: 10px 20px;
    background: var(--team-color, #4ECDC4);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.award-team-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ========================================
   DISPLAY MODE STYLES
   ======================================== */

body.quiz-display-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    overflow: hidden;
}

body.quiz-display-mode .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
}

.display-view-container {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    height: 100vh;
    color: white;
}

.display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 40px;
    background: rgba(0, 0, 0, 0.3);
}

.display-title {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Fredoka', sans-serif;
}

.display-controls {
    display: flex;
    gap: 10px;
}

.display-control-btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.display-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.display-control-btn.active {
    background: #4ECDC4;
    border-color: #4ECDC4;
}

.display-progress {
    font-size: 2.5rem;
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
}

.display-progress .progress-separator {
    opacity: 0.5;
    margin: 0 5px;
}

.display-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* QR Code Display Container */
.display-qr-container {
    text-align: center;
    padding: 40px;
}

.qr-instruction {
    margin-bottom: 30px;
}

.qr-instruction h2 {
    font-size: 2.5rem;
    font-weight: 600;
    margin: 0 0 10px;
    font-family: 'Fredoka', sans-serif;
}

.qr-instruction p {
    font-size: 1.2rem;
    opacity: 0.8;
    margin: 0;
}

.display-qr-image {
    width: 300px;
    height: 300px;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.display-qr-image.large {
    width: 400px;
    height: 400px;
}

.display-qr-container .qr-url {
    margin-top: 20px;
    font-size: 0.85rem;
    opacity: 0.6;
    word-break: break-all;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.display-qr-container .qr-fallback {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
}

.display-qr-container .qr-fallback p {
    margin: 10px 0;
}

.display-qr-container .participant-count {
    margin-top: 30px;
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Waiting for Game View */
.display-waiting-game {
    text-align: center;
}

.display-waiting-game h2 {
    font-size: 2rem;
    margin: 0 0 15px;
    font-family: 'Fredoka', sans-serif;
}

.display-waiting-game p {
    font-size: 1.2rem;
    opacity: 0.7;
}

/* Status footer */
.display-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    transition: background 0.3s;
}

.status-dot.connected {
    background: #4ECDC4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

.display-question-area {
    width: 100%;
    max-width: 1200px;
}

.display-question-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 60px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.display-question-card.question-entering {
    animation: questionEnter 0.5s ease-out;
}

.display-question-number {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0.7;
    margin-bottom: 30px;
}

.display-question-text {
    font-size: 3rem;
    font-weight: 500;
    line-height: 1.4;
    font-family: 'Fredoka', sans-serif;
}

.display-media-container {
    margin-top: 40px;
}

.display-media-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.display-media-video {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    border-radius: 20px;
}

/* Layout variations */
.display-question-card.layout-media-only .display-question-text {
    display: none;
}

.display-question-card.layout-text-top,
.display-question-card.layout-media-top {
    display: flex;
    flex-direction: column;
}

.display-question-card.layout-media-top {
    flex-direction: column-reverse;
}

.display-question-card.layout-text-left,
.display-question-card.layout-media-left {
    display: flex;
    align-items: center;
    gap: 40px;
    text-align: left;
}

.display-question-card.layout-media-left {
    flex-direction: row-reverse;
}

.display-scoreboard {
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.3);
}

.scoreboard-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.7;
    margin-bottom: 15px;
}

.scoreboard-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.scoreboard-empty {
    opacity: 0.5;
    font-style: italic;
}

.scoreboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border-left: 4px solid var(--team-color, #4ECDC4);
    min-width: 180px;
}

.scoreboard-item.rank-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
}

.scoreboard-item.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
}

.scoreboard-item.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
}

.scoreboard-rank {
    width: 32px;
    height: 32px;
    background: var(--team-color, #4ECDC4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
}

.scoreboard-name {
    flex: 1;
    font-weight: 500;
}

.scoreboard-score {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
}

.display-footer {
    padding: 20px 40px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}

.join-instruction {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    opacity: 0.7;
}

.join-icon {
    display: flex;
}

.join-text {
    font-size: 0.9rem;
}

/* ========================================
   PARTICIPANT MODE STYLES
   ======================================== */

body.quiz-participant-mode {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

body.quiz-participant-mode .container {
    max-width: 420px;
    padding: 20px;
}

/* Join Screen */
.participant-join-screen {
    background: white;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.join-header {
    padding: 40px 30px 30px;
    text-align: center;
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    color: white;
}

.join-header h1 {
    margin: 0 0 10px;
    font-size: 1.6rem;
    font-family: 'Fredoka', sans-serif;
}

.join-header p {
    margin: 0;
    opacity: 0.9;
}

.join-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #333;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #4ECDC4;
}

.form-group input.error {
    border-color: #FF6B6B;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.join-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #4ECDC4, #45B7D1);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.join-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.join-footer {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.join-footer p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

/* Game Screen */
.participant-game-screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: calc(100vh - 40px);
}

.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.team-badge {
    padding: 8px 20px;
    border-radius: 25px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.score-display {
    text-align: right;
}

.score-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
    color: #333;
    transition: transform 0.3s, color 0.3s;
}

.score-value.score-up {
    animation: scoreUp 0.5s ease;
}

.score-label {
    font-size: 0.8rem;
    color: #999;
    text-transform: uppercase;
}

.participant-question-preview {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s;
}

.participant-question-preview.question-changed {
    animation: questionEnter 0.5s ease-out;
}

.question-indicator {
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-preview-text {
    font-size: 1.15rem;
    color: #333;
    line-height: 1.5;
}

.buzzer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
}

.buzzer-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--team-color, #4ECDC4), color-mix(in srgb, var(--team-color, #4ECDC4) 80%, black));
    border: none;
    cursor: pointer;
    box-shadow:
        0 15px 35px rgba(0, 0, 0, 0.2),
        inset 0 -8px 20px rgba(0, 0, 0, 0.2),
        inset 0 8px 20px rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    animation: pulse 2s infinite;
}

.buzzer-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.buzzer-btn:active:not(:disabled),
.buzzer-btn.buzzing {
    transform: scale(0.95);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.2),
        inset 0 -4px 10px rgba(0, 0, 0, 0.2),
        inset 0 4px 10px rgba(255, 255, 255, 0.2);
    animation: none;
}

.buzzer-btn.buzzed {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    animation: none;
    cursor: default;
}

.buzzer-text {
    color: white;
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.buzzer-status {
    font-size: 1rem;
    color: #666;
    text-align: center;
    min-height: 24px;
}

.participant-ranking {
    background: white;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.ranking-title {
    font-size: 0.85rem;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.ranking-position {
    font-size: 3rem;
    font-weight: bold;
    font-family: 'Fredoka', sans-serif;
    color: var(--team-color, #4ECDC4);
}

.ranking-total {
    font-size: 0.9rem;
    color: #666;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .display-title {
        font-size: 1.4rem;
    }

    .display-progress {
        font-size: 1.8rem;
    }

    .display-question-text {
        font-size: 2rem;
    }

    .display-question-card {
        padding: 30px;
        border-radius: 20px;
    }

    .display-header,
    .display-scoreboard,
    .display-footer {
        padding: 15px 20px;
    }

    .scoreboard-item {
        min-width: 140px;
        padding: 10px 15px;
    }
}

@media (max-height: 600px) {
    .buzzer-btn {
        width: 150px;
        height: 150px;
    }

    .buzzer-text {
        font-size: 1.5rem;
    }
}
