/* Global Styles */
:root {
    --primary-color: #6a5acd;
    --primary-dark: #4b3d8f;
    --secondary-color: #ff6b6b;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --border-color: #ddd;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* iOS / 모바일 뷰포트에서는 max-width 기반 가운데 정렬 대신 전체 폭 사용 */
@media (max-width: 1080px) {
    .mobile-container {
        width: 100%;
        max-width: 100% !important;
        margin: 0 !important;
    }
}

/* Mobile container */
.mobile-container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;  /* 가로 스크롤만 막고 */
    overflow-y: auto;    /* 세로 스크롤은 허용해서 푸터까지 도달 가능하게 */
}

/* Mobile viewport */
@media (min-width: 1080px) {
    body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background-color: #f0f2f5;
        padding: 20px;
    }
    
    .mobile-container {
        height: 1920px;
        max-height: 100vh;
        aspect-ratio: 9/16;
    }
}

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

html {
    width: 100% !important;
    max-width: 100%;
    overflow-x: hidden !important;
    position: relative;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

body {
    font-family: 'Gowun Batang', 'Malgun Gothic', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f9f9f9;
    margin: 0;
    padding: 0;
    width: 100% !important;
    min-height: 100vh;
    overflow-x: hidden !important;
    position: relative;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: 100%;
    padding-top: 64px; /* 고정 헤더 높이만큼 본문을 아래로 내려 겹치지 않도록 */
}

.app-footer {
    margin-top: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}
.app-footer small {
    display: inline-block;
}

.app-footer {
    margin-top: auto;
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    background-color: #f9fafb;
}
.app-footer small {
    display: inline-block;
}

/* Header Styles */
.app-header {
    background-color: white;
    box-shadow: var(--box-shadow);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-left: calc(1rem + env(safe-area-inset-left, 0));
    padding-right: calc(1rem + env(safe-area-inset-right, 0));
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), #9b59b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    white-space: nowrap;
}

.logo-icon-desktop {
    width: 24px;
    height: 24px;
}

.logo-text {
    display: inline-block;
}

.Main_icon {
    width: 24px;
    height: 24px;
    margin-right: 0.4rem;
}

.app-header nav {
    display: flex;
    align-items: center;
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-radius: 4px;
}

.nav-btn:hover {
    background-color: var(--light-gray);
}

@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        /* 모바일에서는 로고 + 내비게이션을 한 줄에 유지하면서도 폭을 최소화 */
        flex-wrap: nowrap;
        row-gap: 0;
    }
    .mobile-container {
        width: 100% !important;
        max-width: 100%;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        overflow-x: hidden !important;
    }
    .app-header nav {
        flex-wrap: nowrap;
        margin-left: auto; /* 로고 오른쪽 끝에 내비게이션 정렬 */
    }
    .logo {
        font-size: 1.1rem;
        white-space: nowrap;
    }
    .logo-icon-desktop {
        display: none;
    }
    .nav-btn {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
}

/* Dashboard Styles */
.dashboard {
    flex: 1;
    padding: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden; /* 가로 스크롤이 생기지 않도록 강제 */
    -webkit-overflow-scrolling: touch;
}

.dashboard h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-dark);
    font-size: 2rem;
}

.dashboard-grid {
    display: grid;
    /* 왼쪽: 설문 관리 1, 오른쪽: 설문 통계 2 (합쳐서 3 비율) */
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.new-survey {
    grid-column: 1 / -1;
    text-align: center;
    background: linear-gradient(135deg, #f6f8ff, #f0f4ff);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    position: relative;
}

.new-survey::before {
    content: "";
    position: absolute;
    inset: 12px;
    border: none;
    outline: 2px dashed var(--primary-color);
    outline-offset: -10px;
    box-sizing: border-box;
    pointer-events: none;
}

/* iOS Safari 전용: outline-offset 음수 버그 회피를 위해 border 기반으로 대체 */
@supports (-webkit-touch-callout: none) {
    .new-survey::before {
        outline: none !important;
        border: 2px dashed var(--primary-color);
        inset: 10px;
    }
}

.new-survey h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 1rem;
    font-family: 'Gowun Batang', sans-serif;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(106, 90, 205, 0.2);
    max-width: 100%;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
    display: inline-block;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(106, 90, 205, 0.3);
}

/* Quest Item Styles */
.quest-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quest-item:hover {
    transform: translateY(-3px) scale(1.02);
    background-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.quest-avatar {
    font-size: 2rem;
    margin-right: 1rem;
    width: 50px;
    height: 50px;
    background-color: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quest-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-dark);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #9b59b6);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Stats Styles */
.stat-item {
    text-align: center;
    padding: 1rem;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background-color: white;
    margin: 2rem auto;
    max-width: 800px;
    width: 90%;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: modalFadeIn 0.3s ease-out;
}

/* AI Generation Modal */
.ai-modal {
    padding: 2rem 2.5rem;
}

.ai-modal h2 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.ai-modal-desc {
    margin: 0 0 1.5rem 0;
    color: #666;
    font-size: 1rem;
}

.ai-modal-body {
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.ai-actions {
    margin-top: 1.5rem;
}

/* AI topic preset buttons (example topics) */
.ai-topic-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ai-topic-btn {
    flex: 0 0 auto;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    color: #444;
    transition: all 0.2s ease;
}

.ai-topic-btn:hover {
    background-color: #f5f5ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(106, 90, 205, 0.12);
}

/* AI question count buttons */
.ai-count-buttons {
    display: flex;
    gap: 0.75rem;
}

.ai-count-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.ai-count-btn.selected {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(106, 90, 205, 0.15);
}

.ai-count-btn:not(.selected):hover {
    background-color: #f5f5ff;
}

/* AI question count slider */
.ai-count-range {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-count-range input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    outline: none;
}

.ai-count-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(106, 90, 205, 0.25);
}

.ai-count-range input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(106, 90, 205, 0.25);
}

.ai-count-display {
    min-width: 4rem;
    text-align: right;
    font-size: 0.9rem;
    color: #555;
}

/* AI Preview & Edit Modal */
.ai-preview-modal {
    padding: 2rem 2.5rem;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.ai-preview-modal h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.ai-preview-meta {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    background: #f8f9ff;
    border-radius: 8px;
    border: 1px solid #e0e0ff;
}

.ai-preview-meta h3 {
    margin: 0 0 0.25rem 0;
    color: var(--primary-dark);
}

.ai-preview-meta p {
    margin: 0;
    color: #666;
    font-size: 1rem;
}

.ai-preview-questions {
    padding-right: 0.5rem;
    margin-top: 0.5rem;
}

.ai-preview-question {
    background-color: #f9f9ff;
    border: 1px solid #e0e0ff;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.ai-preview-question .form-group {
    margin-bottom: 0.75rem;
}

.ai-preview-question .form-group label {
    font-size: 1rem;
}

.ai-preview-question .ai-q-options {
    font-size: 1rem;
}

.ai-preview-question .ai-q-required {
    width: 16px;
    height: 16px;
}

.ai-preview-actions {
    margin-top: 1.5rem;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.ai-preview-tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.ai-preview-tab {
    flex: 0 0 auto;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid #ddd;
    background: #fafafa;
    font-size: 0.85rem;
    cursor: pointer;
}

.ai-preview-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.ai-preview-body {
    flex: 1;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.ai-preview-edit-panel {
    display: block;
}

.ai-preview-live-panel {
    padding: 0.75rem 0.25rem 0;
}

.ai-preview-add-question {
    margin-top: 0.5rem;
    text-align: center;
}

.ai-preview-add-question .btn {
    font-size: 0.9rem;
}

.ai-q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.ai-q-header-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.ai-q-handle {
    cursor: grab;
    font-size: 1rem;
}

.ai-q-header-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ai-q-body {
    margin-top: 0.25rem;
}

.ai-option-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.ai-option-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ai-option-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-option-handle {
    cursor: grab;
    font-size: 0.9rem;
}

.ai-option-input {
    flex: 1;
}

.ai-bulk-editor {
    margin-top: 0.5rem;
}

.ai-bulk-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ai-live-question {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
}

.ai-live-q-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.ai-live-options {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-live-options li {
    margin-bottom: 0.25rem;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 1.8rem;
    color: #999;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--danger-color);
}

.ai-preview-modal .close {
    font-size: 2.2rem;
    padding: 0.4rem 0.6rem;
    border-radius: 999px;
    color: #555;
}

.ai-preview-modal .close:hover {
    color: #fff;
    background-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.25);
}

/* Step Navigation */
.creation-steps {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}

.step {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    color: #999;
    font-weight: bold;
    position: relative;
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -50%;
    width: 100%;
    height: 2px;
    background-color: #ddd;
    z-index: 1;
}

.step.active {
    color: var(--primary-color);
}

.step.active::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background-color: var(--primary-color);
    border-radius: 50%;
    z-index: 2;
    opacity: 0.1;
}

/* Form Styles */
.step-content {
    padding: 2rem;
    display: none;
}

.step-content.active {
    display: block;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 10px 6px;
    padding-right: 2.5rem;
    cursor: pointer;
}

select.form-control::-ms-expand {
    display: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(106, 90, 205, 0.1);
    box-shadow: 0 0 0 3px rgba(106, 90, 205, 0.1);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Avatar Selection */
.avatar-selection, .theme-selection {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.avatar-option, .theme-option {
    text-align: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.avatar-option:hover, .theme-option:hover {
    background-color: #f5f5ff;
}

.avatar-option.selected, .theme-option.selected {
    border-color: var(--primary-color);
    background-color: #f0f0ff;
}

.avatar-option img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5rem;
    border: 2px solid #eee;
}

.theme-preview {
    width: 120px;
    height: 80px;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background-size: cover;
    background-position: center;
    border: 1px solid #eee;
}

.forest { background-image: url('https://images.unsplash.com/photo-1448375240586-882707db888b?ixlib=rb-1.2.1&auto=format&fit=crop&w=200&q=80'); }
.castle { background-image: url('https://images.unsplash.com/photo-1541411438265-4cb4687110f2?ixlib=rb-1.2.1&auto=format&fit=crop&w=200&q=80'); }
.dungeon { background-image: url('https://images.unsplash.com/photo-1506318137071-a8e06380a7b1?ixlib=rb-1.2.1&auto=format&fit=crop&w=200&q=80'); }

/* Question Block */
.question-block {
    background-color: #f9f9ff;
    border: 1px solid #e0e0ff;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0ff;
}

.question-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background-color: #f0f0f0;
}

/* Answer Options */
.answer-options {
    margin-top: 1rem;
}

.answer-option {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.answer-option .form-control {
    margin-right: 0.5rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-text:hover {
    background-color: #f0f0ff;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

.btn-secondary {
    background-color: #f0f0f0;
    color: #555;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

.btn-outline {
    background: none;
    border: 1px dashed var(--border-color);
    width: 100%;
    padding: 1rem;
    color: #666;
    margin-top: 1rem;
}

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

/* Reward Card */
.reward-card {
    display: flex;
    gap: 1rem;
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #eee;
}

.reward-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.reward-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Completion Modal */
.completion {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.completion h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.completion p {
    margin-bottom: 1.5rem;
    color: #555;
}

.share-link {
    display: flex;
    margin: 1.5rem 0;
}

.share-link input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px 0 0 6px;
    font-family: monospace;
}

.share-link button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 1rem;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.share-link button:hover {
    background-color: var(--primary-dark);
}

.share-link button.share-link-icon-btn {
    background-color: #4a6baf; /* 설문관리 파란색으로 강제 */
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    padding: 0 0.9rem;
}

.share-link button.share-link-icon-btn:hover {
    background-color: #3a5a9a; /* hover 시도 동일 계열 */
}

.qr-code {
    margin: 2rem 0;
    padding: 1rem;
    background-color: white;
    border-radius: 8px;
    display: inline-block;
    border: 1px solid #eee;
}

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

.qr-code p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #666;
}

.completion-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}
/* Dashboard stats + latest survey donut (index.html) */
.dashboard-stats-grid {
    display: flex;
    flex-direction: column; /* 위: 통계 한 줄, 아래: 도넛 카드 */
    gap: 24px;
    width: 100%;
}

.dashboard-stats-left {
    display: flex;
    flex-direction: row;   /* 설문 개수 / 총 응답 / 평균 질문 개수를 가로로 */
    gap: 24px;
    width: 100%;
}

/* 통계 아이템이 가로 공간을 고르게 나누도록 */
.stat-item {
    flex: 1;
}

.latest-survey-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: none;
    margin: 0;
}

.latest-survey-donut-wrap {
    width: 100%;
    height: 260px;
    margin-top: 8px;       /* 통계와의 간격만 약간 주기 */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem;
    }

    .nav-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    .dashboard {
        /* 모바일에서 메인 콘텐츠 좌우 여백을 대칭으로 맞춰 레이아웃이 한쪽으로 치우쳐 보이지 않도록 조정 */
        padding: 1rem;
        overflow-x: hidden !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        /* 뷰포트 기준으로 좌우 20px 여백을 항상 유지 (680px 여부와 무관하게 동작) */
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        min-width: 0; /* 콘텐츠의 최소 너비에 막히지 않고 더 작게 줄어들 수 있도록 허용 */
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto; /* 가운데 정렬 → 좌우 여백 대칭 유지 */
    }

    .new-survey {
        min-height: 200px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .dashboard-card {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .modal-content {
        width: 95%;
        margin: 1.5rem auto;
    }

    .ai-modal,
    .ai-preview-modal {
        padding: 1.25rem 1.5rem;
    }

    .ai-modal-body {
        max-height: 60vh;
    }

    .ai-preview-modal {
        font-size: 0.95rem;
    }

    .ai-preview-question {
        padding: 1rem;
    }

    .ai-preview-question .form-group label {
        font-size: 0.9rem;
    }

    .ai-preview-meta h3 {
        font-size: 1rem;
    }

    .ai-preview-meta p {
        font-size: 0.9rem;
    }

    /* 설문 실행 페이지(survey.html) 모바일 글꼴/레이아웃 조정 */
    #questionContainer p {
        font-size: 0.95rem;
        line-height: 1.4;
        word-break: keep-all;
    }

    .option-btn {
        font-size: 0.9rem;
        padding: 0.55rem 0.75rem;
        line-height: 1.3;
        white-space: normal;
    }

    .text-input {
        font-size: 0.95rem;
        padding: 0.5rem 0.75rem;
    }

    .submit-btn {
        font-size: 0.9rem;
        padding: 0.55rem 1rem;
    }

    /* 메인 페이지 새 설문조사 버튼: 긴 텍스트도 줄바꿈 허용, 카드 폭을 넘지 않도록 */
    .primary-btn {
        font-size: 1rem;
        padding: 0.7rem 1.5rem;
        max-width: 100%;
        white-space: normal;
        text-align: center;
        box-sizing: border-box;
    }

    /* analytics.html 모바일 차트 영역 조정 */
    .analytics-content {
        padding: 0.75rem 0.75rem 1rem;
    }

    .chart-card,
    .analytics-chart-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-card canvas,
    .analytics-chart-card canvas,
    #chart2 {
        max-width: 100%;
        height: auto !important;
    }

    /* Creation wizard (index.html) mobile layout fixes to prevent horizontal overflow */
    .creation-steps {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 1rem;
        row-gap: 0.5rem;
    }
    .creation-steps .step {
        text-align: left;
        padding: 0.4rem 0;
    }
    /* 모바일에서는 상단 진행선은 과감히 숨겨서 폭을 안정화 */
    .creation-steps .step:not(:last-child)::after {
        display: none;
    }
    .step-content {
        padding: 1rem;
    }

    .ai-preview-modal {
        padding: 1.25rem 1rem;
        max-width: 100%;
        box-sizing: border-box;
    }
    .ai-preview-question {
        padding: 1rem 0.9rem;
    }

    .avatar-selection,
    .theme-selection {
        justify-content: flex-start;
    }
    .avatar-option,
    .theme-option {
        flex: 0 0 calc(33.333% - 0.75rem);
        max-width: calc(33.333% - 0.75rem);
        box-sizing: border-box;
    }
    .avatar-option img {
        width: 100%;
        height: auto;
        max-width: 80px;
    }
    .theme-preview {
        width: 100%;
        max-width: 120px;
    }

    .answer-option {
        flex-wrap: nowrap;
    }
    .answer-option .form-control {
        flex: 1 1 auto;
        min-width: 0;
    }
    .answer-option .btn-icon {
        flex: 0 0 auto;
    }

    /* 모바일에서 quest-item hover 시 scale로 인해 가로 폭이 커지는 현상을 방지 */
    .quest-item {
        max-width: 100%;
        box-sizing: border-box;
    }

    .quest-item:hover {
        transform: translateY(-3px); /* scale(1.02) 제거: 세로만 살짝 띄우기 */
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}
