/**
 * components.css - 汎用UIコンポーネント
 */

/* ==================== ボタン ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px; /* タップしやすいサイズ */
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

.btn-edit {
    background: var(--info-color);
    color: white;
}

.btn-edit:hover:not(:disabled) {
    background: #138496;
}

.btn-small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-large {
    width: 100%;
    padding: var(--spacing-md);
    font-size: 1.1rem;
}

.btn-bulk-delete {
    background: var(--danger-color);
    color: white;
}

.btn-bulk-delete:hover:not(:disabled) {
    background: #c82333;
}

/* ==================== フォーム ==================== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-color);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select-small {
    width: auto;
    min-width: 150px;
}

/* チェックボックス */
.form-checkbox {
    margin-right: var(--spacing-xs);
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ラジオボタン */
.question-count-options {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
}

/* 今日のモードオプション */
.today-mode-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.today-mode-options .checkbox-label {
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

/* 先取り学習オプション */
.early-learning-label {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.early-learning-label:hover {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.15));
}

.radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    font-weight: 400;
}

.radio-label input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.radio-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.radio-options .radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    padding: var(--spacing-xs) 0;
}

.radio-options input[type="radio"] {
    margin: 0;
}

.radio-options.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
}

/* ==================== タグ ==================== */

.tag,
.tag-small {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
}

.tag-small {
    background: #e9ecef;
    color: var(--text-color);
}

.tag .tag-remove {
    background: none;
    border: none;
    color: white;
    margin-left: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

/* タグチェックボックス */
.tag-checkboxes {
    max-height: 200px;
    overflow-y: auto;
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    margin-top: var(--spacing-sm);
}

.tag-checkbox-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    border-radius: 4px;
    transition: background 0.2s;
}

.tag-checkbox-item:hover {
    background: #f8f9fa;
}

.tag-checkbox-item input[type="checkbox"] {
    margin-right: var(--spacing-sm);
    cursor: pointer;
}

.tag-checkbox-item label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    font-weight: 400;
}

.tag-checkboxes-empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--spacing-md);
    font-size: 0.9rem;
}

/* ==================== バッジ ==================== */

.completed-badge {
    display: inline-block;
    background: var(--success-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: var(--spacing-xs);
    font-weight: 600;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: var(--spacing-xs);
    font-weight: 600;
}

.type-badge.type-multiple-choice {
    background: #cce5ff;
    color: #004085;
}

.type-badge.type-typing {
    background: #fff3cd;
    color: #856404;
}

.type-badge.type-both {
    background: #d4edda;
    color: #155724;
}

.set-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #d4edda;
    color: #155724;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.no-set-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* ==================== モーダル ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
}

.modal.active {
    display: flex;
}

.modal img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.confirm-modal {
    background: rgba(0, 0, 0, 0.5);
}

.confirm-content {
    background: var(--card-bg);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 100%;
    text-align: center;
    max-height: 80vh;
    overflow-y: auto;
}

.confirm-content p {
    margin-bottom: var(--spacing-lg);
    font-size: 1.1rem;
}

.confirm-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

/* ==================== ローディング ==================== */

.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1001;
}

.loading.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    margin-top: var(--spacing-md);
    color: var(--text-muted);
}

/* ==================== トースト ==================== */

.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

.toast {
    background: var(--text-color);
    color: white;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--success-color);
}

.toast-error {
    background: var(--danger-color);
}

.toast-warning {
    background: var(--warning-color);
    color: var(--text-color);
}

.toast-info {
    background: var(--info-color);
}

/* ==================== 説明ボックス ==================== */

.info-box {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 4px;
}

.info-box p {
    margin: 4px 0;
    font-size: 14px;
    color: #333;
}

.info-box strong {
    color: #1976d2;
}

/* データ管理のヘルプテキスト */
.data-help {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-sm) var(--spacing-md);
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--info-color);
}

.data-help strong {
    color: var(--text-color);
}

/* ==================== 進捗バー ==================== */

.question-item-progress {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-xs) 0;
}

.progress-bar-mini {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    max-width: 100px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
    border-radius: 3px;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 35px;
    text-align: right;
}

/* ==================== スマホ向け調整 ==================== */

@media (max-width: 480px) {
    .form-group {
        margin-bottom: var(--spacing-sm);
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .form-input,
    .form-textarea,
    .form-select {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.95rem;
    }

    .data-help {
        font-size: 0.8rem;
        padding: var(--spacing-xs) var(--spacing-sm);
        margin: var(--spacing-xs) 0;
    }
}

.next-review-text {
    font-size: 0.75rem;
    color: var(--info-color);
    margin-left: var(--spacing-sm);
    padding: 2px 6px;
    background: #e7f3ff;
    border-radius: 4px;
    white-space: nowrap;
}
