/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;600;700&family=Montserrat:wght@500;600;700&family=Nunito+Sans:wght@400;600;700&display=swap');

/* ===== Mobile-First Responsive Design (320px+) ===== */

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

:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --secondary-color: #95a5a6;
    --secondary-hover: #7f8c8d;
    --success-color: #27ae60;
    --danger-color: #ef4444;
    --warning-color: #ffc107;
    --header-bg: #2c3e50;
    --background: #f5f5f5;
    --surface: #ffffff;
    --surface-light: #ecf0f1;
    --border: #ddd;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(52, 152, 219, 0.3);
}

html {
    font-size: 16px;
}

@media (min-width: 768px) {
    html {
        font-size: 17px;
    }
}

@media (min-width: 1024px) {
    html {
        font-size: 18px;
    }
}

body {
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ===== Typography ===== */

h1, h2 {
    font-family: 'Lora', serif;
}

h3 {
    font-family: 'Montserrat', sans-serif;
}

h1 {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

@media (min-width: 768px) {
    h1 {
        font-size: 2.3em;
    }
}

@media (min-width: 1024px) {
    h1 {
        font-size: 2.6em;
    }
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== Layout ===== */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.content-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 0.75rem;
}

/* ===== Header ===== */

header {
    background-color: var(--header-bg);
    color: white;
    padding: 0;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
}

@media (min-width: 1024px) {
    header {
        margin-bottom: 40px;
    }
}

@media (min-width: 1440px) {
    header {
        margin-bottom: 50px;
    }
}

header h1 {
    font-size: 1.5rem;
    margin: 0;
    margin-bottom: 0.25rem;
}

header p {
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.95;
    color: white;
}

header a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Footer ===== */

footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1.5rem 1rem;
    text-align: center;
    margin-top: auto;
}

footer p {
    font-size: 0.875rem;
    margin: 0;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ===== Buttons ===== */

button,
.button,
input[type="submit"],
input[type="button"],
a.btn {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (min-width: 768px) {
    button,
    .button,
    input[type="submit"],
    input[type="button"],
    a.btn {
        padding: 14px;
        font-size: 17px;
    }
}

@media (min-width: 1024px) {
    button,
    .button,
    input[type="submit"],
    input[type="button"],
    a.btn {
        padding: 16px;
        font-size: 18px;
    }
}

button:focus,
.button:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
a.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:active,
.button:active,
input[type="submit"]:active,
input[type="button"]:active,
a.btn:active {
    transform: scale(0.98);
}

/* Primary Button */
.btn-primary,
.button-primary,
button:not([class]) {
    background-color: var(--primary-color);
    color: white;
    border: none;
}

.btn-primary:hover,
.button-primary:hover,
button:not([class]):hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Secondary Button */
.btn-secondary,
.button-secondary {
    background-color: var(--secondary-color);
    color: white;
    border: none;
}

.btn-secondary:hover,
.button-secondary:hover {
    background-color: var(--secondary-hover);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

/* Danger Button */
.btn-danger,
.button-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover,
.button-danger:hover {
    background-color: #dc2626;
}

/* Success Button */
.btn-success,
.button-success {
    background-color: var(--secondary-color);
    color: white;
}

.btn-success:hover,
.button-success:hover {
    background-color: #059669;
}

/* Button Group */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

/* ===== Form Elements ===== */

form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

label .required {
    color: var(--danger-color);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-color: white;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        padding: 14px;
        font-size: 17px;
    }
}

@media (min-width: 1024px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        padding: 16px;
        font-size: 18px;
    }
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

select {
    cursor: pointer;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

/* Checkbox & Radio Buttons */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
    padding: 14px;
    margin: 0;
    accent-color: var(--primary-color);
}

.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 48px;
    padding: 0.5rem;
}

.checkbox-item label,
.radio-item label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
    flex: 1;
}

/* Form Error States */
.form-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: -0.25rem;
}

input.error,
textarea.error,
select.error {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* ===== Cards & Sections ===== */

.card {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .card {
        padding: 35px;
        margin-bottom: 25px;
    }
}

@media (min-width: 1024px) {
    .card {
        padding: 40px;
        margin-bottom: 30px;
    }
}

.card-header {
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
}

.card-header h2 {
    margin: 0;
}

.section {
    margin-bottom: 2rem;
}

/* ===== Hero Section ===== */

.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 3rem 1rem;
    text-align: center;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

.hero h1 {
    color: white;
    margin-bottom: 1rem;
}

.hero p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.125rem;
}

/* ===== Grid for Actions ===== */

.actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-card {
    padding: 2rem 1.5rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    min-height: 300px;
}

@media (min-width: 768px) {
    .action-card {
        padding: 2.5rem 2rem;
        min-height: 320px;
    }
}

@media (min-width: 1024px) {
    .action-card {
        padding: 3rem 2.5rem;
        min-height: 340px;
    }
}

.action-card-link {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.02) 0%, rgba(52, 152, 219, 0.05) 100%);
}

.action-card-link:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(52, 152, 219, 0.25);
    transform: translateY(-8px);
}

.action-card-link:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(52, 152, 219, 0.25);
}

.action-card-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.action-card h3 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

@media (min-width: 768px) {
    .action-card h3 {
        font-size: 1.75rem;
    }
}

.action-card p {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.action-card-button {
    display: inline-block;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: auto;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
    font-size: 1rem;
}

@media (min-width: 768px) {
    .action-card-button {
        padding: 14px 32px;
        font-size: 1.05rem;
    }
}

.action-card-link:hover .action-card-button {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* ===== Features Grid ===== */

.features-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}

@media (min-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.feature-card {
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card strong {
    display: block;
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.feature-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
    transform: translateY(-4px);
}

/* ===== QR Code Display ===== */

.qr-code-container {
    text-align: center;
    padding: 1rem;
    background-color: var(--surface);
    border-radius: 0.5rem;
    margin: 0.75rem 0;
}

.qr-code-container img {
    width: 140px;
    height: 140px;
    display: block;
    margin: 0 auto;
}

.numeric-code {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.25em;
    margin: 1rem 0;
    user-select: all;
    -webkit-user-select: all;
    padding: 0.75rem;
    background-color: white;
    border-radius: 0.375rem;
    border: 2px solid var(--border);
}

/* ===== Poll Questions ===== */

.question {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background-color: var(--surface);
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
}

.question-text {
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.question-type {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ===== Multiple Choice ===== */

.multiple-choice-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    gap: 0.75rem;
}

.choice-option:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.choice-option input {
    margin: 0;
    flex-shrink: 0;
}

.choice-option label {
    margin: 0;
    flex: 1;
    font-weight: 400;
    cursor: pointer;
}

/* ===== Rating Scale ===== */

.rating-scale {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rating-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
    gap: 0.5rem;
}

.rating-option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 600;
    background-color: white;
    transition: all 0.2s ease;
}

.rating-option:focus-within {
    border-color: var(--primary-color);
}

.rating-option input {
    display: none;
}

.rating-option input:checked ~ span {
    background-color: var(--primary-color);
    color: white;
}

.rating-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* ===== Word Cloud Input ===== */

.word-cloud-input {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.word-input {
    min-height: 48px;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

/* ===== Ranking (Drag & Drop) ===== */

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: white;
    border: 2px solid var(--border);
    border-radius: 0.375rem;
    cursor: grab;
    min-height: 48px;
    transition: all 0.2s ease;
    touch-action: none;
}

.ranking-item:active {
    cursor: grabbing;
    opacity: 0.8;
    box-shadow: var(--shadow-md);
}

.ranking-item.dragging {
    opacity: 0.5;
}

.ranking-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.ranking-text {
    flex: 1;
    font-weight: 500;
}

.ranking-handle {
    color: var(--text-light);
    font-size: 1.5rem;
    padding: 0 0.5rem;
    flex-shrink: 0;
}

/* ===== Results Display ===== */

.results-container {
    margin-top: 2rem;
}

.result-question {
    margin-bottom: 2rem;
    padding: 1.25rem;
    background-color: var(--surface);
    border-radius: 0.5rem;
}

.result-title {
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.result-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.result-stat:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 500;
    flex: 1;
}

.result-value {
    font-weight: 700;
    color: var(--primary-color);
}

.progress-bar {
    background-color: var(--border);
    border-radius: 0.25rem;
    height: 24px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    background-color: var(--primary-color);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.3s ease;
}

/* ===== Error Pages ===== */

.error-container {
    text-align: center;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.error-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 400px;
}

.error-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 300px;
}

/* ===== Loading & Transitions ===== */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Toast/Alert Messages ===== */

.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--secondary-color);
}

.alert-error {
    background-color: #fee2e2;
    color: #7f1d1d;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-info {
    background-color: #dbeafe;
    color: #0c2340;
    border-left: 4px solid var(--primary-color);
}

/* ===== Utilities ===== */

.text-center {
    text-align: center;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== Tablet Breakpoint (768px+) ===== */

@media (min-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    main {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2.25rem;
    }

    h2 {
        font-size: 1.875rem;
    }

    button,
    .button,
    input[type="submit"],
    input[type="button"] {
        width: auto;
    }

    .button-group {
        flex-direction: row;
    }

    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero {
        padding: 4rem 2rem;
    }

    .error-container {
        min-height: 60vh;
    }

    .rating-options {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===== Desktop Breakpoint (1024px+) ===== */

@media (min-width: 1024px) {
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-stat {
        display: grid;
        grid-template-columns: 200px 1fr 100px;
        gap: 1rem;
    }

    .result-label {
        border-bottom: none;
    }
}

/* ===== Print Styles ===== */

@media print {
    header,
    footer,
    .no-print {
        display: none;
    }

    body {
        background-color: white;
    }

    .button-group,
    button,
    .button {
        display: none;
    }
}
