/**
 * Unified Auth UI Stylesheet
 * Version: 1.0.0
 * Description: ログイン・登録統合UIのスタイル（digital-book-v07カラーテーマ対応）
 */

/* ========================================
   カラーテーマ（digital-book-v07と統一）
======================================== */
:root {
    --auth-primary-color: #8B7355;       /* ブラウン系の温かい色 */
    --auth-secondary-color: #F5F2E8;     /* ベージュ系の背景色 */
    --auth-text-color: #4A4A4A;          /* ソフトな黒 */
    --auth-border-color: #D4C5B9;        /* 優しいボーダー色 */
    --auth-shadow-color: rgba(139, 115, 85, 0.1);
    --auth-accent-color: #C9A876;        /* アクセントカラー */
    --auth-paper-color: #FFFEF9;         /* 紙のような背景色 */
    --auth-hover-color: #A38A6F;         /* ホバー時の色 */
}

/* ========================================
   全体コンテナ
======================================== */
.unified-auth-container {
    max-width: 1200px;
    margin: 0 auto;  /* 上下マージンを削除 */
    padding: 0;      /* パディングも削除 */
    font-family: 'Yu Gothic', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
}

.unified-auth-wrapper {
    /* シンプル表示：外枠なし */
    position: relative;
}

/* ログイン済みメッセージ */
.unified-auth-message {
    padding: 40px;
    text-align: center;
    color: var(--auth-text-color);
}

.unified-auth-message p {
    margin: 10px 0;
    font-size: 16px;
}

.unified-auth-message a {
    color: var(--auth-primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--auth-primary-color);
    transition: color 0.3s ease;
}

.unified-auth-message a:hover {
    color: var(--auth-hover-color);
}

/* ========================================
   パネルシステム（PC版）
======================================== */
.auth-panels {
    display: flex;
    gap: 20px;
    /* min-heightを削除して自然な高さに */
    align-items: flex-start;  /* 上揃えに変更 */
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* 登録モード時は左寄せに */
div.auth-panels.register-mode {
    justify-content: flex-start !important;
}

/* パスワードリセットモード時も左寄せに */
div.auth-panels.reset-mode {
    justify-content: flex-start !important;
}

/* ========================================
   各パネル
======================================== */
.auth-panel {
    padding: 0;  /* パディング削除で幅を最大化 */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;  /* 上揃えに変更 */
    /* 外枠削除：shadow、border-radius、背景色を削除 */
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ログインパネル */
.login-panel {
    /* 背景色も削除してシンプルに */
    flex: 0 0 47%;
    max-width: 47%;
}

/* 登録パネル - 初期状態では完全非表示 */
.register-panel {
    /* 背景色も削除してシンプルに */
    flex: 0 0 0;
    max-width: 0;
    width: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(30px);
    pointer-events: none;
    overflow: hidden;
    padding: 0;
}

/* パスワードリセットパネル - 初期状態では完全非表示 */
.reset-panel {
    /* 背景色も削除してシンプルに */
    flex: 0 0 0;
    max-width: 0;
    width: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(30px);
    pointer-events: none;
    overflow: hidden;
    padding: 0;
}

/* 登録モード時：登録パネルをフェードイン */
.auth-panels.register-mode .register-panel {
    flex: 0 0 47%;
    max-width: 47%;
    width: 47%;
    padding: 0;  /* パディング削除 */
    margin-left: 20px;  /* 対処療法：登録パネルのギャップを明示的に設定 */
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    overflow: visible;
    transition:
        flex 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        max-width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        opacity 0.3s ease-out 0.1s,
        transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1) 0.05s;
}

/* パスワードリセットモード時：リセットパネルをフェードイン */
.auth-panels.reset-mode .reset-panel {
    flex: 0 0 47%;
    max-width: 47%;
    width: 47%;
    padding: 0;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
    overflow: visible;
    transition:
        flex 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        max-width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
        opacity 0.3s ease-out 0.1s,
        transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1) 0.05s;
}

/* ========================================
   ログインパネルの非アクティブ化
======================================== */
/* 登録モードまたはリセットモード時：ログインパネルを非アクティブに */
.auth-panels.register-mode .login-panel,
.auth-panels.reset-mode .login-panel {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
    transition: opacity 0.3s ease;
}

/* 非アクティブ時のフォーム要素をグレーアウト */
.auth-panels.register-mode .login-panel input,
.auth-panels.register-mode .login-panel button,
.auth-panels.reset-mode .login-panel input,
.auth-panels.reset-mode .login-panel button {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* 非アクティブ時の送信ボタン */
.auth-panels.register-mode .login-panel input[type="submit"],
.auth-panels.register-mode .login-panel button[type="submit"],
.auth-panels.reset-mode .login-panel input[type="submit"],
.auth-panels.reset-mode .login-panel button[type="submit"] {
    background-color: #ccc;
}

/* 非アクティブ時のパネルフッター（切り替えボタン）も無効化 */
.auth-panels.register-mode .login-panel .panel-footer,
.auth-panels.reset-mode .login-panel .panel-footer {
    opacity: 0.5;
    pointer-events: none;
}

/* ========================================
   パネルヘッダー
======================================== */
.panel-header {
    display: none;  /* パネルヘッダーを非表示 */
}

.panel-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--auth-primary-color);
    margin: 0 0 10px 0;
    letter-spacing: 0.05em;
}

.panel-subtitle {
    font-size: 14px;
    color: var(--auth-text-color);
    margin: 0;
    opacity: 0.8;
}

/* ========================================
   パネルコンテンツ（フォームエリア）
======================================== */
.panel-content {
    margin-bottom: 30px;
}

/* Simple WP Membershipフォームのスタイル調整 */
.panel-content form {
    margin: 0;
}

/* 登録フォームを中央配置 - より汎用的なセレクタ */
.swpm-registration-widget-form,
#swpm-registration-form,
.register-panel form,
#registerPanel form {
    max-width: 100% !important;
    margin: 0 auto !important;
    display: block !important;
}

/* パスワードリセットフォームも中央配置（登録フォームと同じ幅） */
.reset-panel form,
#resetPanel form,
#password-reset-form {
    max-width: 100% !important;
    margin: 0 auto !important;
    display: block !important;
}

/* ログインフォームも念のため中央配置 */
.swpm-login-widget-form,
#swpm-login-form,
.login-panel form,
#loginPanel form {
    max-width: 100% !important;
    margin: 0 auto !important;
    display: block !important;
}

/* SWPMの「パスワードを忘れた」リンクを非表示（カスタムボタンを使用） */
.login-panel a[href*="reset"],
.login-panel a[href*="password"],
#loginPanel a[href*="reset"],
#loginPanel a[href*="password"] {
    display: none !important;
}

.panel-content input[type="text"],
.panel-content input[type="email"],
.panel-content input[type="password"] {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 16px;
    border: 1px solid #e0e0e0;  /* 薄いグレーのボーダーに変更 */
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
    background-color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.panel-content input[type="text"]:focus,
.panel-content input[type="email"]:focus,
.panel-content input[type="password"]:focus {
    outline: none;
    border-color: #999;  /* フォーカス時も薄いグレー */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);  /* シャドウを1pxに縮小 */
}

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

/* チェックボックス */
.panel-content input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--auth-primary-color);
}

/* 送信ボタン */
.panel-content input[type="submit"],
.panel-content button[type="submit"] {
    width: 100%;
    padding: 14px 24px;
    background-color: var(--auth-primary-color);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    margin-top: 10px;
}

.panel-content input[type="submit"]:hover,
.panel-content button[type="submit"]:hover {
    background-color: var(--auth-hover-color);
    transform: translateY(-2px);
}

.panel-content input[type="submit"]:active,
.panel-content button[type="submit"]:active {
    transform: translateY(0);
}

/* ========================================
   パネルフッター
======================================== */
.panel-footer {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* パネル切り替えボタン */
.switch-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: transparent;
    color: var(--auth-primary-color);
    border: 2px solid var(--auth-primary-color);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.switch-panel-btn:hover {
    background-color: var(--auth-primary-color);
    color: #ffffff;
    transform: translateX(4px);
}

.switch-panel-btn.back-btn:hover {
    transform: translateX(-4px);
}

.btn-arrow {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.switch-panel-btn:hover .btn-arrow {
    transform: scale(1.2);
}

/* パネルリンク */
.panel-links {
    display: block;  /* パスワードリセットボタンを表示 */
    margin-top: 15px;
}

.forgot-password-btn {
    background: none;
    border: none;
    color: var(--auth-primary-color);
    font-size: 14px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
    transition: color 0.3s ease;
}

.forgot-password-btn:hover {
    color: var(--auth-hover-color);
}

/* ========================================
   レスポンシブ: タブレット
======================================== */
@media (max-width: 1024px) {
    .auth-panel {
        padding: 0;  /* パディング削除 */
    }

    .auth-panels.register-mode .register-panel {
        padding: 0;  /* パディング削除 */
    }

    .panel-title {
        font-size: 28px;
    }
}

/* ========================================
   レスポンシブ: モバイル（縦スライド）
======================================== */
@media (max-width: 768px) {
    .unified-auth-container {
        margin: 20px auto;
        padding: 10px;
    }

    /* モバイルでは縦方向に配置 */
    .auth-panels {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
        justify-content: flex-start;
    }

    /* 各パネル */
    .auth-panel {
        width: 100%;
        max-width: 100%;
        padding: 0;  /* パディング削除 */
        flex: 0 0 auto;
    }

    /* ログインパネル */
    .login-panel {
        flex: 0 0 auto;
        max-width: 100%;
    }

    /* 登録パネル - 初期状態では完全非表示 */
    .register-panel {
        flex: 0 0 0;
        max-width: 100%;
        width: 100%;
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
        max-height: 0;
        overflow: hidden;
        padding: 0;
        margin: 0;
    }

    /* 登録モード時：登録パネルをフェードイン */
    .auth-panels.register-mode .register-panel {
        flex: 0 0 auto;
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        max-height: 5000px;
        padding: 0;  /* パディング削除 */
        margin-top: 20px;
        transition:
            flex 0.6s ease,
            opacity 0.5s ease 0.2s,
            transform 0.5s ease 0.2s,
            max-height 0.6s ease;
    }

    .panel-title {
        font-size: 24px;
    }

    .panel-subtitle {
        font-size: 13px;
    }

    /* モバイルではボタンを横幅いっぱいに */
    .switch-panel-btn {
        width: 100%;
        justify-content: center;
    }

    /* 入力フィールドのサイズ調整 */
    .panel-content input[type="text"],
    .panel-content input[type="email"],
    .panel-content input[type="password"] {
        padding: 12px 16px;
        font-size: 16px; /* iOSのズーム防止 */
    }

    .panel-content input[type="submit"],
    .panel-content button[type="submit"] {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* ========================================
   エラーメッセージ・通知
======================================== */
.swpm-login-form-message,
.swpm-registration-form-message {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-size: 14px;
}

/* エラー */
.swpm-login-form-message.swpm-error,
.swpm-registration-form-message.swpm-error {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* 成功 */
.swpm-login-form-message.swpm-success,
.swpm-registration-form-message.swpm-success {
    background-color: #efe;
    color: #3a3;
    border: 1px solid #cfc;
}

/* ========================================
   アクセシビリティ対応
======================================== */
.auth-panel:focus-within {
    outline: none;  /* フォーカス時の茶色枠線を非表示 */
}

/* スクリーンリーダー用テキスト */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   アニメーション用キーフレーム
======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-panel.active {
    animation: fadeIn 0.6s ease forwards;
}

/* ========================================
   パスワードリセットページのスタイル統一
======================================== */
/* パスワードリセットページのフォームを中央配置 */
.swpm-reset-pw-form,
#swpm-resetpass-form {
    max-width: 500px;
    margin: 0 auto;
}

/* パスワードリセットのボタンを中央配置（ログインフォームと同じに） */
.swpm-reset-pw-form input[type="submit"],
#swpm-resetpass-form input[type="submit"] {
    display: block;
    margin: 0 auto !important;
    text-align: center;
}

/* ========================================
   成功メッセージのスタイル
======================================== */
.swpm-reset-success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 60px 40px;
}

.success-icon-wrapper {
    margin-bottom: 30px;
}

.success-icon {
    filter: drop-shadow(0 4px 12px rgba(76, 175, 80, 0.3));
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-title {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.success-subtitle {
    font-size: 16px;
    color: #666;
    margin: 0;
    line-height: 1.6;
}

/* ========================================
   プリント用スタイル
======================================== */
@media print {
    .unified-auth-container {
        display: none;
    }
}
