/* リセット・ベース */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Yu Gothic', 'YuGothic', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* コンテナ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-sm {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #3498db;
}

/* メインコンテンツ */
.main-content {
    padding: 2rem 0;
    min-height: calc(100vh - 120px);
}

/* カード */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    margin: 0 0 1rem 0;
    color: #2c3e50;
}

/* フォーム */
.form-group {
    margin-bottom: 1.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.required {
    color: #e74c3c;
}

/* ラジオボタン・チェックボックス */
.radio-option,
.checkbox-option {
    margin-bottom: 0.5rem;
}

.radio-option input,
.checkbox-option input {
    margin-right: 0.5rem;
}

.radio-option label,
.checkbox-option label {
    display: inline;
    font-weight: normal;
    cursor: pointer;
}

/* ボタン（完全版） */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s;
    font-weight: 400;
    line-height: 1.5;
    vertical-align: middle;
    user-select: none;
}

.btn:hover {
    text-decoration: none;
}

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn-primary {
    background: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.btn-primary:hover {
    background: #0056b3;
    border-color: #0056b3;
}

.btn-success {
    background: #28a745;
    color: white;
    border: 1px solid #28a745;
}

.btn-success:hover {
    background: #218838;
    border-color: #1e7e34;
}

.btn-info {
    background: #17a2b8;
    color: white;
    border: 1px solid #17a2b8;
}

.btn-info:hover {
    background: #138496;
    border-color: #117a8b;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border: 1px solid #ffc107;
}

.btn-warning:hover {
    background: #e0a800;
    border-color: #d39e00;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

.btn-danger:hover {
    background: #c82333;
    border-color: #bd2130;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: 1px solid #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
    border-color: #545b62;
}

/* 小さなボタン */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    border-radius: 0.2rem;
}

/* テーブル */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

/* アラート */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ログインフォーム */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #2c3e50;
}

/* 質問エディタ */
.question-editor {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.question-controls {
    display: flex;
    gap: 0.5rem;
}

.option-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.option-input input {
    flex: 1;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .container,
    .container-sm {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .question-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .question-controls {
        justify-content: center;
    }
}

/* ユーティリティ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* テキストカラー */
.text-success { color: #27ae60; }
.text-secondary { color: #6c757d; }
.text-danger { color: #e74c3c; }

/* 統計カードのレスポンシブ対応 */
@media (max-width: 768px) {
    .d-flex.gap-2 {
        flex-direction: column;
    }
    
    .d-flex.gap-2 > * {
        flex: none !important;
    }
}

/* 回答管理画面用スタイル */
.stat-item {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    flex: 1;
}

.response-item {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.response-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.response-content {
    padding: 1rem;
}

.response-question {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.response-question:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.question-text {
    margin-bottom: 0.5rem;
}

.question-type {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: normal;
}

.answer-text {
    padding-left: 1rem;
    color: #495057;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.pagination-info {
    font-size: 0.875rem;
    color: #6c757d;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .response-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stat-item h3 {
        font-size: 1.5rem;
    }
}

/* ユーザー設定画面用スタイル */
.row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.col-md-6 {
    flex: 1;
    min-width: 300px;
}

.form-control-static {
    padding: 0.75rem 0;
    margin: 0;
    color: #495057;
    background: transparent;
    border: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .col-md-6 {
        min-width: auto;
    }
}

/* グループ機能用スタイル */
.question-group {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 2rem;
    background: #fdfdfd;
}

.group-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
}

.group-title h3 {
    margin: 0;
    color: #495057;
    font-size: 1.2rem;
}

.group-title small {
    display: block;
    margin-top: 0.2rem;
}

.group-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.group-questions {
    padding: 1rem;
}

.ungrouped-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px dashed #dee2e6;
}

.ungrouped-section h4 {
    color: #6c757d;
    margin-bottom: 1rem;
}

.ungrouped-container {
    min-height: 100px;
    border: 1px dashed #dee2e6;
    border-radius: 4px;
    padding: 1rem;
    background: #f8f9fa;
}

.question-editor {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.question-header h4 {
    margin: 0;
    color: #495057;
    font-size: 1rem;
}

.question-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.question-controls {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.question-controls .btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .group-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .group-controls {
        justify-content: center;
    }
    
    .question-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .question-header-left {
        justify-content: space-between;
    }
    
    .question-controls {
        justify-content: center;
    }
}

/* フォーム表示用グループスタイル */
.question-group-display {
    margin-bottom: 2rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.question-group-display .group-header {
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.question-group-display .group-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.question-group-display .group-questions {
    padding: 1.5rem;
}

.ungrouped-questions {
    margin-bottom: 2rem;
}

.custom-header-section,
.custom-footer-section {
    margin-bottom: 2rem;
}

.custom-header-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.custom-footer-section {
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    margin-top: 2rem;
}

/* カスタムカラー適用時の調整 */
.question-group-display .group-header {
    transition: all 0.3s ease;
}

/* 拡張設定用スタイル */
.advanced-section {
    margin-bottom: 2rem;
}

.section-title {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.section-divider {
    margin: 2rem 0;
    border-color: #e9ecef;
}

/* 折りたたみボタン */
#advancedToggleIcon {
    transition: transform 0.3s ease;
    display: inline-block;
    margin-left: 0.5rem;
}

#advancedToggleIcon.rotated {
    transform: rotate(180deg);
}

/* 拡張設定エリアのアニメーション */
#advancedSettings {
    transition: all 0.3s ease;
}

/* プレビューエリアの調整 */
.color-preview h6 {
    margin-bottom: 0.5rem;
    color: #6c757d;
}

.preview-container {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 4px;
    background: #fff;
}

.preview-heading {
    font-weight: bold;
    font-size: 1.1rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.preview-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding: 0.25rem;
}

.preview-input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* カラープレビュー用スタイル */
.preview-container {
    border: 1px solid #ddd;
    padding: 1rem;
    border-radius: 4px;
    background: #fff;
}

.preview-heading {
    font-weight: bold;
    font-size: 1.2rem;
}

.preview-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.preview-input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
}

/* カラー入力フィールド */
input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* 確認画面用スタイル */
.confirmation-screen {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.confirmation-title {
    color: #495057;
    margin-bottom: 1rem;
    text-align: center;
}

.confirmation-item {
    display: flex;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.confirmation-label {
    font-weight: 600;
    width: 30%;
    color: #495057;
}

.confirmation-value {
    width: 70%;
    color: #212529;
}

.confirmation-buttons {
    text-align: center;
    margin-top: 2rem;
}

.confirmation-buttons .btn {
    margin: 0 0.5rem;
}

/* バッジスタイル（改良版） */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    color: white;
    min-width: 60px;
}

.badge-primary {
    background-color: #007bff;
}

.badge-success {
    background-color: #28a745 !important;
    color: white !important;
}

.badge-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

.badge-warning {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.badge-info {
    background-color: #17a2b8 !important;
    color: white !important;
}

.badge-secondary {
    background-color: #6c757d;
}

/* テーブル内のバッジ調整 */
.table td .badge {
    vertical-align: middle;
}

.status-success {
    color: #28a745;
    font-weight: 600;
}

.status-error {
    color: #dc3545;
    font-weight: 600;
}

.status-pending {
    color: #ffc107;
    font-weight: 600;
}

.table-responsive {
    overflow-x: auto;
}

.col-md-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
}

@media (max-width: 768px) {
    .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }
}

/* メールアドレス確認用のスタイル */
.email-error-msg {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

.email-success-msg {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

/* 入力フィールドの状態表示 */
input[type="email"].email-valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.15);
}

input[type="email"].email-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

/* アニメーション */
.email-error-msg,
.email-success-msg {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 非表示質問のスタイル */
.question-editor.hidden-question {
    opacity: 0.6;
    border-left: 4px solid #ffc107;
}

.question-editor.hidden-question .question-header h4::after {
    content: " (非表示)";
    color: #ffc107;
    font-size: 0.8em;
}

/* ヘルプテキスト用スタイル */
.form-help-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.4;
}

.form-help-text strong {
    color: #495057;
}

/* 並び替えボタン用スタイル（横並び版） */
.sort-buttons {
    display: flex;
    flex-direction: row;
    gap: 4px;
    margin-left: 10px;
}

.sort-buttons .btn {
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* レスポンシブ対応（並び替えボタン） */
@media (max-width: 768px) {
    .sort-buttons {
        flex-direction: row;
        margin-left: 0;
        gap: 2px;
    }
    
    .sort-buttons .btn {
        min-width: 24px;
        height: 24px;
        padding: 2px 4px;
    }
}

/* 操作ボタンを小さくして常に横並びにする */
.table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-width: 45px;
    white-space: nowrap;
}

/* 操作列の幅を固定 */
.table th:last-child,
.table td:last-child {
    width: 280px;
    min-width: 280px;
}

/* モバイルでもボタンを横並びに保つ */
@media (max-width: 768px) {
    .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }
    
    .table .btn-sm {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
        min-width: 40px;
    }
}

/* ページヘッダーのレイアウト */
.page-header {
    margin-bottom: 1.5rem;
}

.page-title-section {
    margin-bottom: 1rem;
}

.page-title-section h1 {
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
}

.page-title-section .form-title {
    margin: 0;
    color: #666;
    font-size: 1rem;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.page-actions .btn {
    white-space: nowrap;
}

/* レスポンシブ対応 */
@media (min-width: 768px) {
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 1.5rem;
    }
    
    .page-title-section {
        margin-bottom: 0;
        flex: 1;
    }
    
    .page-actions {
        margin-left: 1rem;
        justify-content: flex-end;
    }
}