/**
 * UACJ健康保険組合 - 拡張スタイル（アニメーション・状態管理）
 * @version 2.0.0
 */

/* ===================================
   ローディング状態
=================================== */
.loading {
    cursor: wait;
}

.loading .member-reservation-btn {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading .member-reservation-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================
   フォーム状態のスタイル
=================================== */
.form-group.focused .password-input {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    outline: none;
}

.form-group.success .password-input {
    border-color: #28a745;
    background-color: #f8fff9;
}

.form-group.success .password-label::after {
    content: '✓';
    color: #28a745;
    margin-left: 8px;
    font-weight: bold;
}

.form-group.error .password-input {
    border-color: #dc3545;
    background-color: #fff5f5;
    animation: shake 0.5s ease-in-out;
}

.form-group.error .password-label {
    color: #dc3545;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* ===================================
   エラーメッセージスタイル
=================================== */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    animation: slideDown 0.3s ease-out;
}

.error-message::before {
    content: '⚠';
    margin-right: 8px;
    font-size: 16px;
}

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

/* ===================================
   インタラクション改善
=================================== */
.member-reservation-btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.member-reservation-btn:hover {
    transform: translateY(-1px);
}

.member-reservation-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 102, 204, 0.2);
}

.member-reservation-btn:disabled {
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

/* ===================================
   電話リンクのフィードバック
=================================== */
.contact-phone a {
    transition: all 0.2s ease;
    position: relative;
}

.contact-phone a:active {
    transform: scale(0.98);
}

/* ===================================
   ヘルプアイコンの改善
=================================== */
.help-icon {
    transition: all 0.2s ease;
    cursor: pointer;
}

.help-icon:hover,
.help-icon:focus {
    transform: scale(1.1);
    color: #0066cc;
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 50%;
}

/* ===================================
   フォーカス表示の改善
=================================== */
.forgot-password:focus,
.footer__link:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===================================
   画像の読み込み状態
=================================== */
img {
    transition: opacity 0.3s ease;
}

img[aria-label*="失敗"] {
    filter: grayscale(100%);
    opacity: 0.5;
}

/* ===================================
   レスポンシブ改善
=================================== */
@media (max-width: 768px) {
    .loading .member-reservation-btn::before {
        width: 16px;
        height: 16px;
        margin: -8px 0 0 -8px;
    }
    
    .error-message {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .form-group.error .password-input {
        animation: shake-mobile 0.5s ease-in-out;
    }
    
    @keyframes shake-mobile {
        0%, 100% { transform: translateX(0); }
        25%, 75% { transform: translateX(-1px); }
        50% { transform: translateX(1px); }
    }
}

/* ===================================
   アクセシビリティ改善
=================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ハイコントラストモード対応 */
@media (prefers-contrast: high) {
    .form-group.success .password-input {
        border-width: 3px;
    }
    
    .form-group.error .password-input {
        border-width: 3px;
    }
    
    .member-reservation-btn {
        border: 2px solid #000;
    }
}

/* ===================================
   ダークモード対応準備
=================================== */
@media (prefers-color-scheme: dark) {
    .form-group.success .password-input {
        background-color: #1a3d2e;
        border-color: #28a745;
    }
    
    .form-group.error .password-input {
        background-color: #3d1a1a;
        border-color: #dc3545;
    }
    
    .error-message {
        background-color: #3d1a1a;
        color: #f8d7da;
        border-color: #dc3545;
    }
}

/* ===================================
   印刷対応
=================================== */
@media print {
    .member-reservation-btn,
    .contact-phone,
    .forgot-password {
        background: none !important;
        color: #000 !important;
        box-shadow: none !important;
    }
    
    .error-message {
        border: 1px solid #000 !important;
        background: none !important;
    }
}

/* ===================================
   パフォーマンス最適化
=================================== */
.login-section {
    will-change: opacity, transform;
}

.member-reservation-btn {
    will-change: transform, box-shadow;
}

/* GPU加速の有効化 */
.form-group.error .password-input {
    transform: translateZ(0);
}
