/**
 * Pharmacy Questionnaire - フロントエンドスタイル
 *
 * モバイルファースト設計でスマートフォン・タブレット対応。
 * SPA風のフォーム遷移とモダンなUI/UXを提供。
 */

/* ===== カスタムプロパティ (デザイントークン) ===== */
:root {
    --pq-primary: #2563eb;
    --pq-primary-dark: #1d4ed8;
    --pq-primary-light: #dbeafe;
    --pq-accent: #059669;
    --pq-accent-light: #d1fae5;
    --pq-danger: #dc2626;
    --pq-danger-light: #fee2e2;
    --pq-warning: #f59e0b;
    --pq-warning-light: #fef3c7;
    --pq-text: #1e293b;
    --pq-text-muted: #64748b;
    --pq-bg: #f8fafc;
    --pq-bg-white: #ffffff;
    --pq-border: #e2e8f0;
    --pq-border-focus: #93c5fd;
    --pq-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --pq-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --pq-radius: 12px;
    --pq-radius-sm: 8px;
    --pq-transition: 0.3s ease;
    --pq-font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    --pq-outpatient: #2563eb;
    --pq-web: #7c3aed;
}

/* ===== ベース ===== */
.pq-app {
    font-family: var(--pq-font);
    color: var(--pq-text);
    max-width: 680px;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
}

.pq-app *, .pq-app *::before, .pq-app *::after {
    box-sizing: border-box;
}

/* ===== 言語セレクタ ===== */
.pq-lang-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
}

.pq-lang-btn {
    padding: 6px 12px;
    border: 1.5px solid var(--pq-border);
    border-radius: 20px;
    background: var(--pq-bg-white);
    color: var(--pq-text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--pq-transition);
}

.pq-lang-btn:hover {
    border-color: var(--pq-primary);
    color: var(--pq-primary);
}

.pq-lang-btn.active {
    background: var(--pq-primary);
    border-color: var(--pq-primary);
    color: #fff;
}

/* ===== ヘッダー ===== */
.pq-header {
    text-align: center;
    margin-bottom: 24px;
}

.pq-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--pq-text);
    margin: 0 0 8px;
    letter-spacing: 0.02em;
}

.pq-subtitle {
    font-size: 14px;
    color: var(--pq-text-muted);
    margin: 0;
}

/* ===== プログレスバー ===== */
.pq-progress-container {
    margin-bottom: 28px;
}

.pq-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--pq-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.pq-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pq-primary), var(--pq-accent));
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.pq-progress-steps {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--pq-text-muted);
}

.pq-progress-step {
    text-align: center;
    flex: 1;
    position: relative;
    font-weight: 400;
    transition: all var(--pq-transition);
}

.pq-progress-step.active {
    color: var(--pq-primary);
    font-weight: 600;
}

.pq-progress-step.completed {
    color: var(--pq-accent);
}

/* ===== エラーバナー ===== */
.pq-error-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--pq-danger-light);
    border: 1px solid var(--pq-danger);
    border-radius: var(--pq-radius-sm);
    margin-bottom: 20px;
    animation: pq-shake 0.4s ease;
}

.pq-error-text {
    font-size: 14px;
    color: var(--pq-danger);
    font-weight: 500;
}

@keyframes pq-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ===== フォームセクション ===== */
.pq-section {
    background: var(--pq-bg-white);
    border-radius: var(--pq-radius);
    padding: 24px 20px;
    box-shadow: var(--pq-shadow);
    margin-bottom: 16px;
    animation: pq-fade-in 0.4s ease;
}

.pq-section[style*="display: none"] {
    animation: none;
}

.pq-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--pq-text);
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--pq-primary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pq-section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 20px;
    background: var(--pq-primary);
    border-radius: 2px;
}

@keyframes pq-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== フィールド ===== */
.pq-field {
    margin-bottom: 20px;
    animation: pq-field-in 0.3s ease;
}

.pq-field.pq-hidden {
    display: none;
    animation: none;
}

.pq-field.pq-skipped {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(100%);
    transition: all var(--pq-transition);
}

.pq-field.pq-skipped .pq-input {
    background: var(--pq-bg);
}

@keyframes pq-field-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.pq-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--pq-text);
    margin-bottom: 6px;
}

.pq-required-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--pq-danger);
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.pq-optional-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--pq-text-muted);
    background: var(--pq-border);
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

/* テキスト・日付・電話入力 */
.pq-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--pq-border);
    border-radius: var(--pq-radius-sm);
    font-size: 16px; /* iOS ズーム防止のため16px以上 */
    font-family: var(--pq-font);
    color: var(--pq-text);
    background: var(--pq-bg-white);
    transition: border-color var(--pq-transition), box-shadow var(--pq-transition);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.pq-input:focus {
    border-color: var(--pq-border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pq-input.pq-error {
    border-color: var(--pq-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.pq-input::placeholder {
    color: var(--pq-text-muted);
    opacity: 0.6;
}

/* テキストエリア */
textarea.pq-input {
    resize: vertical;
    min-height: 80px;
}

/* ラジオ・チェックボックス */
.pq-options-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.pq-option-label {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border: 1.5px solid var(--pq-border);
    border-radius: var(--pq-radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--pq-text);
    background: var(--pq-bg-white);
    transition: all var(--pq-transition);
    flex: 1;
    min-width: 120px;
    user-select: none;
}

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

.pq-option-label.selected {
    border-color: var(--pq-primary);
    background: var(--pq-primary-light);
    color: var(--pq-primary-dark);
    font-weight: 600;
}

.pq-option-label input[type="radio"],
.pq-option-label input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--pq-primary);
    width: 18px;
    height: 18px;
}

.pq-options-group.pq-error .pq-option-label {
    border-color: var(--pq-danger);
}

/* ===== ナビゲーションボタン ===== */
.pq-nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding: 0 4px;
}

.pq-btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--pq-radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--pq-font);
    cursor: pointer;
    transition: all var(--pq-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
}

.pq-btn-prev {
    background: var(--pq-bg);
    color: var(--pq-text-muted);
    border: 1.5px solid var(--pq-border);
}

.pq-btn-prev:hover {
    background: var(--pq-border);
}

.pq-btn-next,
.pq-btn-confirm {
    background: var(--pq-primary);
    color: #fff;
    flex: 1;
}

.pq-btn-next:hover,
.pq-btn-confirm:hover {
    background: var(--pq-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pq-btn-back {
    background: var(--pq-bg);
    color: var(--pq-text-muted);
    border: 1.5px solid var(--pq-border);
}

.pq-btn-back:hover {
    background: var(--pq-border);
}

.pq-btn-submit {
    background: var(--pq-accent);
    color: #fff;
    flex: 1;
}

.pq-btn-submit:hover {
    background: #047857;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.pq-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===== 確認画面 ===== */
.pq-confirm-table {
    width: 100%;
    border-collapse: collapse;
}

.pq-confirm-table tr {
    border-bottom: 1px solid var(--pq-border);
}

.pq-confirm-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pq-text-muted);
    width: 35%;
    vertical-align: top;
    background: var(--pq-bg);
}

.pq-confirm-table td {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--pq-text);
}

/* ===== 完了画面 ===== */
.pq-complete {
    text-align: center;
    padding: 48px 24px;
}

.pq-complete-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: pq-bounce 0.6s ease;
}

@keyframes pq-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.pq-complete-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--pq-accent);
    margin: 0 0 12px;
}

.pq-complete-message {
    font-size: 14px;
    color: var(--pq-text-muted);
    line-height: 1.7;
    margin: 0;
}

/* ===== 一覧画面 ===== */
.pq-list-header {
    margin-bottom: 24px;
}

.pq-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-top: 16px;
}

.pq-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pq-filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--pq-text-muted);
}

.pq-filter-input {
    padding: 8px 12px;
    border: 1.5px solid var(--pq-border);
    border-radius: var(--pq-radius-sm);
    font-size: 14px;
    font-family: var(--pq-font);
    background: var(--pq-bg-white);
    color: var(--pq-text);
    outline: none;
    -webkit-appearance: none;
}

.pq-filter-input:focus {
    border-color: var(--pq-border-focus);
}

.pq-btn-search {
    background: var(--pq-primary);
    color: #fff;
    padding: 8px 20px;
    min-height: 38px;
}

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

/* テーブル */
.pq-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--pq-bg-white);
    border-radius: var(--pq-radius);
    overflow: hidden;
    box-shadow: var(--pq-shadow);
    font-size: 13px;
}

.pq-table thead {
    background: var(--pq-bg);
}

.pq-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--pq-text-muted);
    font-size: 12px;
    border-bottom: 2px solid var(--pq-border);
    white-space: nowrap;
}

.pq-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--pq-border);
    color: var(--pq-text);
}

.pq-table tbody tr:hover {
    background: var(--pq-primary-light);
}

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

/* チャンネルバッジ */
.pq-channel-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.pq-channel-badge.outpatient {
    background: var(--pq-primary-light);
    color: var(--pq-outpatient);
}

.pq-channel-badge.web {
    background: #ede9fe;
    color: var(--pq-web);
}

.pq-btn-detail {
    padding: 6px 14px;
    font-size: 12px;
    background: var(--pq-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--pq-font);
    transition: all var(--pq-transition);
}

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

/* ===== モーダル ===== */
.pq-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: pq-overlay-in 0.2s ease;
}

@keyframes pq-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pq-modal {
    background: var(--pq-bg-white);
    border-radius: var(--pq-radius);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--pq-shadow-lg);
    animation: pq-modal-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pq-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pq-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--pq-border);
}

.pq-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.pq-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pq-btn-print {
    padding: 6px 14px;
    background: var(--pq-bg);
    border: 1.5px solid var(--pq-border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--pq-font);
    cursor: pointer;
    color: var(--pq-text);
    transition: all var(--pq-transition);
}

.pq-btn-print:hover {
    background: var(--pq-border);
}

.pq-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--pq-bg);
    border-radius: 50%;
    font-size: 20px;
    color: var(--pq-text-muted);
    cursor: pointer;
    transition: all var(--pq-transition);
}

.pq-modal-close:hover {
    background: var(--pq-border);
    color: var(--pq-text);
}

.pq-modal-body {
    padding: 24px;
}

/* ===== ローディング ===== */
.pq-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--pq-text-muted);
    font-size: 14px;
}

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

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

/* ===== 空メッセージ ===== */
.pq-empty-message {
    text-align: center;
    padding: 48px 24px;
    color: var(--pq-text-muted);
    font-size: 14px;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
    .pq-app {
        padding: 12px;
    }

    .pq-section {
        padding: 20px 16px;
    }

    .pq-options-group {
        flex-direction: column;
    }

    .pq-option-label {
        min-width: 100%;
    }

    .pq-nav-buttons {
        flex-direction: column-reverse;
    }

    .pq-btn {
        width: 100%;
    }

    .pq-filters {
        flex-direction: column;
    }

    .pq-filter-input {
        width: 100%;
    }

    .pq-table {
        font-size: 12px;
    }

    .pq-table th,
    .pq-table td {
        padding: 8px 6px;
    }

    .pq-modal {
        max-height: 92vh;
    }

    .pq-confirm-table th,
    .pq-confirm-table td {
        display: block;
        width: 100%;
    }

    .pq-confirm-table th {
        border-bottom: none;
        padding-bottom: 2px;
    }

    .pq-confirm-table td {
        padding-top: 2px;
    }
}

/* ===== 印刷用非表示 (画面) ===== */
.pq-print-only {
    display: none;
}
