/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@400;500;700&display=swap');

/* --- CSS Variables (ปรับปรุงใหม่) --- */
:root {
    --primary-color: #005A9C;
    --primary-color-light: #4D9DE0;
    --primary-glow: rgba(0, 90, 156, 0.3);
    --accent-color: #E15554;
    --background-start: #F7F9FC;
    --background-end: #EBF2F9;
    --card-bg: #FFFFFF;
    --text-color: #2c3e50;
    --text-color-light: #8a95a5;
    --border-color: #EAECEF;
    --shadow: 0 4px 25px rgba(0, 90, 156, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 90, 156, 0.12);
}

/* --- Base Styles (ปรับปรุงใหม่) --- */
body {
    font-family: 'Poppins', 'Kanit', sans-serif;
    background-image: linear-gradient(135deg, var(--background-start), var(--background-end));
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
}
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--primary-color); }

/* --- Layout Containers (ปรับปรุงใหม่) --- */
.top-bar {
    background-color: var(--card-bg);
    padding: 12px 50px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    border-bottom: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
}
.top-bar h1 { font-size: 1.8em; margin: 0; display: flex; align-items: center; gap: 12px; }
.main-container { padding: 40px; display: flex; flex-direction: column; align-items: center; gap: 40px; }

/* --- Card Styles (ปรับปรุงใหม่) --- */
.card {
    background-color: var(--card-bg);
    border-radius: 16px; /* ทำให้โค้งมนมากขึ้น */
    padding: 35px 45px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 850px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease-in-out;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
.card h2 { font-size: 1.6em; margin-top: 0; margin-bottom: 25px; }

/* --- Form Elements --- */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 8px; font-size: 1.05em; }
input[type="text"], select {
    width: 100%; padding: 12px 18px; border: 1px solid var(--border-color);
    border-radius: 8px; font-size: 1em; font-family: 'Poppins', sans-serif;
    transition: all 0.2s ease; background-color: #FDFDFD;
}
input[type="text"]:focus, select:focus {
    outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px var(--primary-glow);
}

/* --- Buttons (ปรับปรุงใหม่) --- */
.main-btn, .secondary-btn, .icon-btn {
    font-family: 'Poppins', sans-serif; font-size: 1.05em; font-weight: 500;
    padding: 12px 28px; border-radius: 8px; border: none; cursor: pointer;
    transition: all 0.3s ease; display: inline-flex; align-items: center;
    justify-content: center; gap: 8px;
    text-decoration: none;
}
.main-btn {
    background: var(--primary-color); color: white;
    box-shadow: 0 2px 10px rgba(0, 90, 156, 0.2);
}
.main-btn:hover {
    background: #004578;
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 90, 156, 0.3);
}
.secondary-btn { background-color: var(--border-color); color: var(--text-color); }
.secondary-btn:hover { background-color: #DBE0E5; transform: translateY(-2px); }
.icon-btn { padding: 10px; width: 42px; height: 42px; border-radius: 50%; }

/* --- Option Creator --- */
#options-container .option-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#options-container .option-item .remove-option-btn { background: none; border: none; color: var(--accent-color); cursor: pointer; font-size: 1.3em; transition: color 0.2s; }
#options-container .option-item .remove-option-btn:hover { color: #c0392b; }

/* ที่เหลือเหมือนเดิม (ตั้งแต่ #live-display-card เป็นต้นไป) ... */
/* --- Live Display Card --- */
#live-display-card.hidden, .hidden { display: none !important; }
#live-display-card { position: relative; text-align: center; padding-top: 60px; }
#back-to-create-btn { position: absolute; top: 20px; left: 20px; background-color: #f0f3f6; }
#live-question-title { font-size: 2em; font-weight: 600; margin-bottom: 25px; color: var(--text-color); }
#response-counter-wrapper {
    display: flex; align-items: center; gap: 10px; position: absolute; top: 20px;
    right: 20px; background-color: #f0f3f6; padding: 8px 15px; border-radius: 20px;
}
#response-counter-wrapper .fas { font-size: 1.2em; color: var(--primary-color-light); }
#response-count { font-size: 1.3em; font-weight: 600; color: var(--primary-color); transition: transform 0.3s ease; }
#fullscreen-btn { position: absolute; bottom: 20px; right: 20px; background-color: #f0f3f6; }

/* --- Share Section --- */
.share-section {
    background-color: #f8f9fa; border-radius: 12px; padding: 20px;
    margin: 20px auto; text-align: center; max-width: 500px;
}
.share-header { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 10px; }
.icon-btn-small { padding: 6px; font-size: 0.8em; background: #e9ecef; border: none; border-radius: 50%; cursor: pointer; line-height: 1; }
.icon-btn-small:hover { background: #ced4da; }
#qrcode-container { display: inline-block; padding: 10px; background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
#link-wrapper { margin-top: 15px; }
.link-box {
    display: flex; align-items: center; border: 1px solid var(--border-color);
    border-radius: 8px; padding: 5px; background-color: #FFF; max-width: 400px; margin: 0 auto;
}
.link-box a {
    flex-grow: 1; padding: 5px 10px; font-size: 0.9em; color: var(--primary-color);
    text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
#copy-link-btn { border: none; background-color: var(--primary-color); color: white; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background-color 0.2s; }
#copy-link-btn:hover { background-color: #004578; }

/* --- QR Code Expansion Modal Styles --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.85); display: flex; justify-content: center;
    align-items: center; z-index: 2000; cursor: pointer; opacity: 0;
    transition: opacity 0.3s ease; pointer-events: none;
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-overlay img {
    max-width: 90vw; max-height: 90vh; width: auto; height: auto;
    background: white; padding: 20px; border-radius: 16px; cursor: default;
}

/* --- Word Cloud Layout Adjustments --- */
#live-display-card.wordcloud-mode { padding-top: 20px; padding-bottom: 20px; }
#live-display-card.wordcloud-mode #live-question-title { font-size: 1.5em; margin-bottom: 15px; }
#live-display-card.wordcloud-mode .share-section {
    position: absolute; top: 65px; left: 15px; width: 220px; padding: 15px;
    margin: 0; transform-origin: top left; transform: scale(0.9);
    z-index: 10;
}
#live-display-card.wordcloud-mode #back-to-create-btn { top: 15px; left: 15px; z-index: 10; }
#live-display-card.wordcloud-mode #response-counter-wrapper { top: 15px; right: 15px; z-index: 10;}
#live-display-card.wordcloud-mode .chart-container {
    width: 100%; height: 65vh;
    display: flex; justify-content: center; align-items: center;
}
#live-display-card.wordcloud-mode:fullscreen .chart-container { width: 95vw; height: 80vh; }

/* --- Student View Specifics --- */
.student-option-label {
    display: block; background: var(--card-bg); padding: 15px 20px; border-radius: 8px;
    border: 2px solid var(--border-color); cursor: pointer; transition: all 0.2s ease;
    margin: 0 auto 15px auto; max-width: 400px; text-align: left;
}
.student-option-label:hover { border-color: var(--primary-color-light); transform: translateY(-2px); }
input[type="radio"], input[type="checkbox"] { margin-right: 15px; transform: scale(1.3); accent-color: var(--primary-color); }
#thank-you-message h2, #error-message h2 { font-size: 2.5em; color: var(--primary-color); }

/* --- Animation for Word Cloud --- */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.canvas-pulse { animation: pulse 0.6s cubic-bezier(0.5, 0, 0.5, 1); }