/* ==========================================================================
   poll-widget.css - アンケート・投票ウィジェット スタイル
   レスポンシブ・アクセシビリティ対応
   ========================================================================== */

.poll-widget-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    padding: 24px;
    margin: 28px 0;
    font-family: inherit;
    color: #1e293b;
    box-sizing: border-box;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.poll-widget-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.poll-widget-header {
    margin-bottom: 20px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 16px;
}

.poll-widget-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.poll-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 9999px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.poll-badge--type {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.poll-badge--status-open {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.poll-badge--status-closed {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

.poll-badge--voted {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.poll-widget-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 8px 0;
    line-height: 1.45;
    word-break: break-word;
}

.poll-widget-desc {
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --------------------------------------------------------------------------
   選択肢リスト (投票フォーム)
   -------------------------------------------------------------------------- */
.poll-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.poll-option-item {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    background: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 54px;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.poll-option-item:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.poll-option-item.is-selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #2563eb;
}

.poll-option-input-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.poll-option-input {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: #2563eb;
    margin: 0;
}

.poll-option-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.poll-option-body {
    flex: 1;
    min-width: 0;
}

.poll-option-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
    word-break: break-word;
    line-height: 1.4;
}

.poll-option-desc {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.45;
    word-break: break-word;
}

.poll-option-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #2563eb;
    text-decoration: underline;
    margin-top: 6px;
    cursor: pointer;
    font-weight: 500;
}

.poll-option-link:hover {
    color: #1d4ed8;
}

/* --------------------------------------------------------------------------
   自由記述エリア
   -------------------------------------------------------------------------- */
.poll-free-text-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #cbd5e1;
}

.poll-free-text-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
    display: block;
}

.poll-free-text-input {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 1rem; /* iOS自動ズーム防止 (16px) */
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.poll-free-text-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.poll-free-text-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: right;
    margin-top: 4px;
}

/* --------------------------------------------------------------------------
   アクションフッター (投票ボタン / 結果切り替え)
   -------------------------------------------------------------------------- */
.poll-widget-footer {
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.poll-vote-btn {
    background: #2563eb;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 28px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px; /* タップ領域 */
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.poll-vote-btn:hover:not(:disabled) {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.poll-vote-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.poll-toggle-results-btn {
    background: transparent;
    border: none;
    color: #475569;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 8px 12px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.poll-toggle-results-btn:hover {
    color: #0f172a;
}

.poll-info-note {
    font-size: 0.8rem;
    color: #64748b;
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   集計結果表示 (グラフ & ランキング)
   -------------------------------------------------------------------------- */
.poll-results-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 20px 0;
}

.poll-result-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.poll-result-item.is-user-choice {
    border-color: #3b82f6;
    background: #eff6ff;
}

.poll-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
}

.poll-result-label-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.poll-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.poll-rank-1 {
    background: #fef08a;
    color: #854d0e;
    border: 1px solid #facc15;
}

.poll-rank-2 {
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.poll-rank-3 {
    background: #fed7aa;
    color: #9a3412;
    border: 1px solid #fdba74;
}

.poll-rank-other {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.poll-result-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    word-break: break-word;
    line-height: 1.4;
}

.poll-your-vote-tag {
    display: inline-block;
    font-size: 0.7rem;
    background: #2563eb;
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    font-weight: 700;
    white-space: nowrap;
}

.poll-result-numbers {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

.poll-result-pct {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
}

.poll-result-count {
    font-size: 0.8rem;
    color: #64748b;
}

/* プログレスバー */
.poll-progress-track {
    width: 100%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 8px;
}

.poll-progress-bar {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    width: 0%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.poll-result-item.is-user-choice .poll-progress-bar {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.poll-result-details {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.poll-result-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
}

.poll-total-votes-summary {
    text-align: right;
    font-size: 0.9rem;
    color: #475569;
    margin-top: 16px;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   メッセージ・ローディング
   -------------------------------------------------------------------------- */
.poll-widget-loading {
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
}

.poll-alert-msg {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 14px;
    line-height: 1.5;
}

.poll-alert-msg--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.poll-alert-msg--success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* --------------------------------------------------------------------------
   モバイル対応 (max-width: 640px)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .poll-widget-card {
        padding: 16px;
        margin: 20px 0;
        border-radius: 10px;
    }
    .poll-widget-title {
        font-size: 1.15rem;
    }
    .poll-option-item {
        padding: 12px 14px;
        gap: 12px;
    }
    .poll-option-thumb {
        width: 52px;
        height: 52px;
    }
    .poll-option-label {
        font-size: 0.95rem;
    }
    .poll-option-desc {
        font-size: 0.8rem;
    }
    .poll-widget-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .poll-vote-btn {
        width: 100%;
    }
    .poll-toggle-results-btn {
        justify-content: center;
        width: 100%;
    }
    .poll-info-note {
        text-align: center;
        margin-left: 0;
        margin-top: 4px;
    }
    .poll-result-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .poll-result-numbers {
        margin-left: auto;
    }
    .poll-result-pct {
        font-size: 1.1rem;
    }
    .poll-total-votes-summary {
        text-align: center;
    }
}
