/* ============================================
   학년말 설문 - 우리 반 이야기 스타일시트
   ============================================ */

:root {
    /* 색상 팔레트 */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f472b6;
    --accent: #22d3ee;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* 배경 그라데이션 */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.15);
    
    /* 텍스트 */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #ffffff;
    
    /* 그림자 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
    
    /* 폰트 */
    --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   메인 페이지 - 역할 선택
   ============================================ */

.welcome-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 48px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo {
    font-size: 72px;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-card h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.role-selection {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.role-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 32px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-width: 140px;
}

.role-btn .icon {
    font-size: 36px;
}

.role-btn .label {
    font-size: 1rem;
    font-weight: 600;
}

.teacher-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.student-btn {
    background: linear-gradient(135deg, var(--secondary) 0%, #ec4899 100%);
    color: white;
}

.role-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.role-btn:active {
    transform: translateY(0);
}

/* 학생 이름 입력 */
.student-input-area {
    margin-top: 24px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.student-input-area input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-family: inherit;
    transition: border-color 0.3s ease;
    margin-bottom: 12px;
}

.student-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.submit-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.hidden {
    display: none !important;
}

/* ============================================
   교사 페이지
   ============================================ */

.teacher-container {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    min-height: calc(100vh - 40px);
}

.control-panel {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-header {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 2px solid #f3f4f6;
}

.panel-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.panel-header .status {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.question-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 8px;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.question-item:hover {
    background: #f3f4f6;
}

.question-item.active {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border-color: var(--primary-dark);
}

.question-item.completed {
    background: #ecfdf5;
    border-color: var(--success);
}

.question-item.completed::after {
    content: '✓';
    margin-left: auto;
    color: var(--success);
    font-weight: bold;
}

.q-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.question-item.active .q-number {
    background: white;
    color: var(--primary);
}

.q-title {
    font-size: 0.95rem;
    font-weight: 500;
}

.q-type {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    margin-left: auto;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.control-btn {
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.start-btn {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.stop-btn {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.next-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.reset-btn {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 결과 패널 */
.result-panel {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px solid #f3f4f6;
    margin-bottom: 20px;
}

.current-question {
    flex: 1;
}

.current-question h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.current-question .type-badge {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.response-count {
    text-align: right;
}

.response-count .count {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
}

.response-count .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.result-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.chart-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.waiting-message {
    text-align: center;
    color: var(--text-secondary);
}

.waiting-message .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* 워드클라우드 컨테이너 */
#wordcloud-canvas {
    width: 100%;
    height: 400px;
}

/* 점수 리스트 */
.score-list {
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.score-item .name {
    font-weight: 500;
}

.score-item .score {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.average-score {
    margin-top: 16px;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    text-align: center;
    color: white;
}

.average-score .label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.average-score .value {
    font-size: 2.5rem;
    font-weight: 900;
}

/* ============================================
   학생 페이지
   ============================================ */

.student-container {
    max-width: 600px;
    margin: 0 auto;
}

.student-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.student-header {
    margin-bottom: 24px;
}

.student-header h2 {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.student-header .student-name {
    font-size: 1rem;
    color: var(--text-secondary);
}

.question-display {
    margin-bottom: 32px;
}

.question-number {
    display: inline-block;
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

/* 객관식 선택 (이름 선택) */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.choice-btn {
    padding: 16px 12px;
    font-size: 1rem;
    font-weight: 500;
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.choice-btn:hover {
    background: #e5e7eb;
    border-color: var(--primary-light);
}

.choice-btn.selected {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary-dark);
}

/* 점수 슬라이더 */
.score-selector {
    margin-bottom: 24px;
}

.score-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.score-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
    font-weight: 600;
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.score-btn:hover {
    background: #e5e7eb;
    border-color: var(--primary-light);
}

.score-btn.selected {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: var(--primary-dark);
}

/* 텍스트 입력 */
.text-input-area {
    margin-bottom: 24px;
}

.text-input-area input {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.2rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-family: inherit;
    text-align: center;
    transition: border-color 0.3s ease;
}

.text-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}

.submit-answer-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}

.submit-answer-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-answer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 대기 화면 */
.waiting-screen {
    padding: 48px 24px;
}

.waiting-screen .icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.waiting-screen h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.waiting-screen p {
    color: var(--text-secondary);
}

/* 제출 완료 화면 */
.submitted-screen {
    padding: 48px 24px;
}

.submitted-screen .icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.submitted-screen h3 {
    font-size: 1.5rem;
    color: var(--success);
    margin-bottom: 8px;
}

/* ============================================
   반응형 디자인
   ============================================ */

@media (max-width: 900px) {
    .teacher-container {
        grid-template-columns: 1fr;
    }
    
    .question-list {
        max-height: 200px;
    }
}

@media (max-width: 600px) {
    .welcome-card {
        padding: 32px 24px;
    }
    
    .welcome-card h1 {
        font-size: 2rem;
    }
    
    .role-selection {
        flex-direction: column;
    }
    
    .role-btn {
        width: 100%;
    }
    
    .student-card {
        padding: 24px 16px;
    }
    
    .question-text {
        font-size: 1.2rem;
    }
    
    .choice-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .score-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* 스크롤바 스타일 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 학생 목록 입력 */
.student-list-input {
    margin-top: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
}

.student-list-input label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.student-list-input textarea {
    width: 100%;
    height: 100px;
    padding: 12px;
    font-size: 0.95rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

.student-list-input textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.student-list-input .hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
