/* ========================================
   QUESTIONNAIRE PLATFORM - STYLES
   Design sobre et fonctionnel
   ======================================== */

/* === VARIABLES === */
:root {
    --primary: #0d9488;
    --primary-light: #e6f4f3;
    --primary-dark: #0f766e;

    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #ca8a04;
    --warning-light: #fefce8;
    --success: #16a34a;
    --success-light: #f0fdf4;

    --text: #1f2937;
    --text-light: #6b7280;
    --text-muted: #9ca3af;

    --bg: #f8f9fa;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-dark: #d1d5db;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* === LAYOUT === */
#app {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 20px;
}

/* === LOADING === */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* === HEADER === */
.header {
    text-align: center;
    margin-bottom: 28px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.header .subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* === PROGRESS BAR === */
.progress-container {
    margin-bottom: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* === CARD === */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 28px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

/* === FORM FIELDS === */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

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

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.15s ease;
}

.form-input:hover {
    border-color: var(--border-dark);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* === QUESTIONS === */
.question-subtitle {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.question-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.question-note {
    background: var(--warning-light);
    border-left: 3px solid var(--warning);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 0.9rem;
    color: #92400e;
    border-radius: 0 6px 6px 0;
}

.question-note strong {
    display: block;
    margin-bottom: 4px;
}

/* === OPTIONS === */
.options-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-label {
    display: flex;
    align-items: flex-start;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg-card);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.option-label:hover {
    border-color: var(--border-dark);
    background: #fafafa;
}

.option-label.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-input {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

.option-text {
    flex: 1;
    color: var(--text);
    line-height: 1.4;
}

.option-label.selected .option-text {
    font-weight: 500;
}

.option-extra-input {
    margin-top: 10px;
    margin-left: 30px;
}

.option-extra-input input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}

.option-extra-input input:focus {
    outline: none;
    border-color: var(--primary);
}

/* === NUMBER INPUT === */
.number-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.number-input {
    width: 100px;
    padding: 12px;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
}

.number-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.number-suffix {
    font-size: 1rem;
    color: var(--text-light);
}

/* === MATRIX TABLE === */
.matrix-container {
    overflow-x: auto;
    margin-top: 20px;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

.matrix-table th,
.matrix-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.matrix-table th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text);
    font-size: 0.8rem;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
    text-align: left;
    min-width: 180px;
}

.matrix-table tbody tr:hover {
    background: #fafafa;
}

.matrix-table tbody tr:last-child td {
    border-bottom: none;
}

.matrix-table input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* === HORAIRES === */
.horaires-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.horaire-btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.horaire-btn:hover {
    border-color: var(--border-dark);
    background: #fafafa;
}

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

/* === BUTTONS === */
.btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: center;
}

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

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

.btn-primary:disabled {
    background: var(--border-dark);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-light);
    margin-top: 12px;
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--border-dark);
}

/* === RESULT SCREENS === */
.result-screen {
    text-align: center;
    padding: 40px 20px;
}

.result-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2rem;
}

.result-icon.success {
    background: var(--success-light);
}

.result-icon.error {
    background: var(--danger-light);
}

.result-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.result-message {
    color: var(--text-light);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* === PARTICIPANT FOOTER === */
.participant-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 16px;
}

/* === SECTION TITLE === */
.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

/* === INFO MESSAGE === */
.info-message {
    padding: 14px 16px;
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    border-radius: 0 6px 6px 0;
    margin: 16px 0;
}

.info-message p {
    margin: 0;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* === ACCESS LOGIN === */
.access-login {
    text-align: center;
    padding: 24px 0;
}

.access-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

.access-login h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.access-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 16px;
    font-size: 0.9rem;
    border-left: 3px solid var(--danger);
    text-align: left;
}

/* === TEXTAREA === */
textarea.form-input {
    min-height: 100px;
    resize: vertical;
}

/* === RESPONSIVE === */
@media (max-width: 600px) {
    #app {
        padding: 20px 16px;
    }

    .card {
        padding: 20px 18px;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .question-title {
        font-size: 1.05rem;
    }

    .option-label {
        padding: 12px 14px;
    }

    .btn {
        padding: 12px 16px;
    }
}

/* === FOCUS STATES === */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
    outline: none;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* === IMAGE OPTIONS GRID (multiple_images) === */
.image-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.image-option-item {
    position: relative;
    cursor: pointer;
}

.image-option-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    transition: all 0.2s ease;
    text-align: center;
}

.image-option-label:hover {
    border-color: var(--border-dark);
    background: #fafafa;
}

.image-option-label.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.image-option-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.image-option-img {
    width: 100%;
    max-width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
}

.image-option-text {
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.3;
}

.image-option-label.selected .image-option-text {
    font-weight: 600;
    color: var(--primary-dark);
}

.image-option-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.image-option-label.selected .image-option-check {
    display: flex;
}

/* === BRAND GRID (brand_grid) === */
.brand-grid-container {
    margin-top: 20px;
}

.brand-grid-total {
    background: var(--primary-light);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 600;
    color: var(--text);
}

.brand-grid-total.valid {
    background: var(--success-light);
    color: var(--success);
}

.brand-grid-total.invalid {
    background: var(--danger-light);
    color: var(--danger);
}

.brand-grid-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.brand-grid-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.brand-grid-item:hover {
    border-color: var(--border-dark);
}

.brand-grid-label {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text);
}

.brand-grid-input {
    width: 70px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--text);
}

.brand-grid-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.brand-grid-input::-webkit-inner-spin-button,
.brand-grid-input::-webkit-outer-spin-button {
    opacity: 1;
}

/* Responsive pour la grille d'images */
@media (max-width: 500px) {
    .image-options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .image-option-img {
        max-width: 80px;
        height: 80px;
    }

    .image-option-text {
        font-size: 0.8rem;
    }
}

/* ========================================
   SLOTS - CRÉNEAUX HORAIRES AVEC QUOTAS
   ======================================== */

.slots-container {
    width: 100%;
}

.slots-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.slots-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.slots-waitlist {
    width: 100%;
}

.waitlist-message {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.waitlist-message p {
    margin: 8px 0;
    color: #92400e;
}

.waitlist-message strong {
    color: #78350f;
}

.slots-available,
.slots-preferences {
    width: 100%;
}

.slot-option {
    position: relative;
}

.slot-remaining {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-left: auto;
    white-space: nowrap;
}

.slot-option .option-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.slot-option .option-text {
    flex: 1;
    min-width: 200px;
}

/* Responsive slots */
@media (max-width: 500px) {
    .slot-option .option-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .slot-option .option-text {
        min-width: auto;
        font-size: 0.9rem;
    }

    .slot-remaining {
        align-self: flex-end;
        margin-left: 0;
    }

    .waitlist-message {
        padding: 16px;
        font-size: 0.9rem;
    }
}
