/* 
 * 共通フォームコントロール用CSS
 */

/* ============================================
   カスタムカラー定義
   ============================================ */
:root {
    --border-color: #999;
    --border-color-light: #ccc;
    --text-muted: #6c757d;
}

/* ============================================
   共通フォームコントロールスタイル
   ============================================ */
.form-control,
.form-select {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: white;
    font-size: 16px;
    padding: 8px 12px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--primary-color) 25%, transparent);
    outline: none;
}

.form-control:disabled,
.form-select:disabled {
    background-color: #e9ecef;
    opacity: 1;
    color: #333;
    cursor: not-allowed;
}

/* ============================================
   ラベル
   ============================================ */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #333;
    display: block;
}

.form-label .text-danger {
    color: var(--danger-color) !important;
    font-weight: bold;
}

/* ============================================
   説明文
   ============================================ */
.form-text {
    font-size: 16px;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================
   インラインメッセージ（アイコン付き）
   ============================================ */
.inline-message {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.inline-message-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

/* フィールド直下のインラインエラー */
.inline-error {
    color: var(--danger-color);
    margin-top: 0.25rem;
    font-weight: bold;
}

/* フィールド直下のインライン警告（確定操作はブロックしない） */
.inline-warning {
    color: var(--warning-color);
    margin-top: 0.25rem;
    font-weight: bold;
}

/* ============================================
   バリデーション状態
   ============================================ */
.input-validation-error {
    border-color: var(--danger-color) !important;
}

.input-validation-error:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.is-valid {
    border-color: #28a745 !important;
}

.is-valid:focus {
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* ============================================
   Text入力コントロール
   ============================================ */
.text-input-control .form-control {
    width: 100%;
}

/* 標準テキスト入力（クラス指定なしでも統一） */
input.form-control[type="text"],
input.form-control[type="search"],
input.form-control[type="number"],
input.form-control[type="tel"],
input.form-control[type="email"],
input.form-control[type="password"],
input.form-control:not([type]) {
    height: 36px;
    font-size: 15px;
}

/* ============================================
   Number入力コントロール（スピナー非表示）
   ============================================ */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* ============================================
   Date/Month入力コントロール（カレンダーアイコン）
   ============================================ */
input[type="date"],
input[type="month"] {
    position: relative;
    padding-right: 40px;
}

/* 標準日付入力（クラス指定なしでも統一） */
input.form-control[type="date"],
input.form-control[type="month"] {
    height: 36px;
    padding: 4px 8px;
    padding-right: 40px;
    font-size: 15px;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    opacity: 1;
    background-color: white;
    border-radius: 4px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' stroke='%2316a085' stroke-width='2' fill='white'/%3E%3Cline x1='16' y1='2' x2='16' y2='6' stroke='%2316a085' stroke-width='2' stroke-linecap='round'/%3E%3Cline x1='8' y1='2' x2='8' y2='6' stroke='%2316a085' stroke-width='2' stroke-linecap='round'/%3E%3Cline x1='3' y1='10' x2='21' y2='10' stroke='%2316a085' stroke-width='2'/%3E%3C/svg%3E");
    background-size: 20px 20px;
    background-position: center;
    background-repeat: no-repeat;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover {
    background-color: #f5f5f5;
}

/* ============================================
   Dropdownコントロール
   ============================================ */
.form-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 26px !important;
}

/* 標準ドロップダウン（クラス指定なしでも統一） */
select.form-select {
    height: 36px;
    font-size: 15px;
}

/* ============================================
   Radio/Checkboxボタングループ
   ============================================ */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
}

/* ラジオボタン（枠なし・インジケーター付き） */
.btn-radio {
    padding: 4px 12px 4px 30px;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    color: #555;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    font-weight: normal;
    line-height: 1.4;
    position: relative;
}

/* 円形インジケーター */
.btn-radio::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #999;
    border-radius: 50%;
    background-color: white;
    transition: border-color 0.15s, background-color 0.15s;
}

.btn-radio.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* 選択時 */
.btn-radio.active::before {
    border-color: var(--primary-color);
    background-color: white;
}

/* 選択時の中央ドット */
.btn-radio.active::after {
    content: '';
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary-color);
}

.btn-radio:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-radio:hover::before {
    border-color: var(--primary-color);
}

/* 選択テーブル内ラジオ（ラベルなし・アイコンのみ） */
.selectable-table .col-radio {
    width: 40px;
}

.selectable-table td.col-radio .btn-radio {
    width: 24px;
    height: 24px;
    min-width: 0;
    padding: 0;
    margin: 0 auto;
    display: block;
}

.selectable-table td.col-radio .btn-radio::before,
.selectable-table td.col-radio .btn-radio.active::after {
    left: 50%;
    transform: translate(-50%, -50%);
}

/* チェックボックス（枠なし・インジケーター付き） */
.btn-checkbox {
    padding: 4px 12px 4px 30px;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    color: #555;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    font-weight: normal;
    line-height: 1.4;
    position: relative;
}

/* 四角形インジケーター */
.btn-checkbox::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #999;
    border-radius: 3px;
    background-color: white;
    transition: border-color 0.15s, background-color 0.15s;
}

.btn-checkbox.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* 選択時: インジケーターを塗りつぶし */
.btn-checkbox.active::before {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

/* 選択時のチェックマーク（白抜き） */
.btn-checkbox.active::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 45%;
    transform: translateY(-50%) rotate(45deg);
    width: 8px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
}

.btn-checkbox:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.btn-checkbox:hover::before {
    border-color: var(--primary-color);
}

/* チェックボックス（大） */
.btn-checkbox-large {
  padding: 4px 12px 4px 36px;
}
 
.btn-checkbox-large::before {
  width: 22px;
  height: 22px;
}
 
.btn-checkbox-large.active::after {
  left: 12px;
  width: 9px;
  height: 11px;
}

/* チェックボックス（クラス指定なしでも統一） */
input.form-check-input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 0;
    border: 2px solid #aaa;
    border-radius: 3px;
}

input.form-check-input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input.form-check-input[type="checkbox"]:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--primary-color) 25%, transparent);
}

/* disabled状態 */
.btn-radio:disabled,
.btn-checkbox:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

/* 非活性時 */
.btn-radio:disabled::before,
.btn-checkbox:disabled::before {
    border-color: #ccc;
    background-color: #f0f0f0;
}

/* 非活性・選択済み */
.btn-checkbox.active:disabled::before {
    border-color: #888;
    background-color: #888;
}

.btn-radio.active:disabled::after {
    background-color: #888;
}

.btn-checkbox.active:disabled::after {
    border-color: white;
}

/* ============================================
   レスポンシブ調整
   ============================================ */
@media (max-width: 768px) {
    .form-select {
        font-size: 16px;
        padding: 6px 10px;
    }

    .form-label {
        font-size: 16px;
    }
}

/* ============================================
   パスワード表示切替（共通コンポーネント）
   ============================================ */
.password-toggle-wrapper {
    position: relative;
}

.password-toggle-wrapper .form-control {
    padding-right: 2.5rem;
}

.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 0.25rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    min-height: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    outline: none;
    box-shadow: none;
}

/* アイコンの字形余白による上寄りを補正 */
.password-toggle-btn i {
    transform: translateY(1px);
}

/* ブラウザ標準のパスワード表示アイコンを非表示にする */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}
