/**
 * WP Renai Chat Plugin Styles
 * Pairsのデザインを参考にしたスタイル
 */

/* コンテナ */
.wp-renai-chat-container {
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    color: #333;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* ヘッダー */
.wp-renai-chat-header {
    background-color: #ff82a9;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wp-renai-chat-username {
    font-weight: bold;
    font-size: 16px;
}

.wp-renai-chat-logout-button {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.wp-renai-chat-logout-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* タブ */
.wp-renai-chat-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background-color: #f8f8f8;
}

.wp-renai-chat-tab {
    padding: 15px 20px;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    transition: all 0.3s;
    text-align: center;
    flex: 1;
}

.wp-renai-chat-tab.active {
    color: #ff82a9;
    border-bottom: 3px solid #ff82a9;
    background-color: #fff;
}

.wp-renai-chat-tab:hover:not(.active) {
    background-color: #f0f0f0;
    color: #ff82a9;
}

.wp-renai-chat-tab.hidden {
    display: none;
}

/* タブコンテンツ */
.wp-renai-chat-tab-content {
    display: none !important; /* 強制的に非表示 */
    padding: 20px;
    height: 0; /* 高さも0に設定 */
    overflow: hidden; /* コンテンツのオーバーフローを隠す */
    opacity: 0; /* 透明にする */
    transition: opacity 0.2s ease; /* アニメーション効果 */
}

.wp-renai-chat-tab-content.active {
    display: block !important; /* 強制的に表示 */
    height: auto; /* 高さを自動調整 */
    overflow: visible; /* オーバーフローを表示 */
    opacity: 1; /* 不透明にする */
}

/* 認証フォーム */
.wp-renai-chat-auth {
    padding: 20px;
}

.wp-renai-chat-form-group {
    margin-bottom: 15px;
}

.wp-renai-chat-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.wp-renai-chat-form-group input,
.wp-renai-chat-form-group textarea,
.wp-renai-chat-form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.wp-renai-chat-button {
    background-color: #ff82a9;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    width: 100%;
}

.wp-renai-chat-button:hover {
    background-color: #ff5c90;
}

.wp-renai-chat-button-secondary {
    background-color: #f0f0f0;
    color: #666;
    border: 1px solid #ddd;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
}

.wp-renai-chat-button-secondary:hover {
    background-color: #e5e5e5;
}

.wp-renai-chat-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

.wp-renai-chat-message.success {
    background-color: #e6f7e6;
    color: #3c763d;
    border: 1px solid #d0e9c6;
    display: block;
}

.wp-renai-chat-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* チャット画面 */
.wp-renai-chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 4px;
    margin-bottom: 15px;
    scroll-behavior: smooth; /* スクロールをスムーズに */
}

.wp-renai-chat-welcome {
    text-align: center;
    color: #888;
    margin: 20px 0;
}

.wp-renai-chat-message-container {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.wp-renai-chat-message-user {
    align-self: flex-end;
    background-color: #e9f5ff;
    border-radius: 10px 0 10px 10px;
    padding: 10px 15px;
    max-width: 80%;
    margin-bottom: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wp-renai-chat-message-bot {
    align-self: flex-start;
    background-color: #fff;
    border-radius: 0 10px 10px 10px;
    padding: 10px 15px;
    max-width: 80%;
    margin-bottom: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wp-renai-chat-time {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
    align-self: flex-end;
}

.wp-renai-chat-input-area {
    display: flex;
}

.wp-renai-chat-input-area textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    height: 60px;
    font-size: 14px;
}

.wp-renai-chat-send-button {
    background-color: #ff82a9;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 20px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.wp-renai-chat-send-button:hover {
    background-color: #ff5c90;
}

.wp-renai-chat-send-button:disabled {
    background-color: #ddd;
    cursor: not-allowed;
}

/* 情報設定画面 */
.wp-renai-chat-section {
    margin-bottom: 20px;
}

.wp-renai-chat-section h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

/* 記念日画面 */
.wp-renai-chat-anniversary-list {
    margin-bottom: 30px;
}

.wp-renai-chat-anniversary-item {
    background-color: #f9f9f9;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 3px solid #ff82a9;
    position: relative;
}

.wp-renai-chat-anniversary-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.wp-renai-chat-anniversary-date {
    color: #666;
    font-size: 14px;
}

.wp-renai-chat-anniversary-actions {
    position: absolute;
    right: 15px;
    top: 15px;
}

.wp-renai-chat-anniversary-edit,
.wp-renai-chat-anniversary-delete {
    background-color: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    margin-left: 5px;
    font-size: 14px;
}

.wp-renai-chat-anniversary-edit:hover {
    color: #007bff;
}

.wp-renai-chat-anniversary-delete:hover {
    color: #dc3545;
}

/* レスポンシブ対応 */
@media (max-width: 767px) {
    body {
        overflow: hidden; /* スクロールを防止 */
    }
    
    /* レイアウト関連の設定 */
    .wp-renai-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        z-index: 99999;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        display: flex; /* 初期状態から表示 */
        flex-direction: column;
        overflow: hidden;
    }
    
    .wp-renai-chat-app {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden; /* コンテナのオーバーフローを防止 */
    }

    .wp-renai-chat-tab {
        padding: 10px;
        font-size: 13px;
        flex-shrink: 0; /* フレックスアイテムの縮小を防止 */
    }
    
    .wp-renai-chat-tabs {
        flex-shrink: 0; /* フレックスアイテムの縮小を防止 */
    }
    
    .wp-renai-chat-header {
        flex-shrink: 0; /* フレックスアイテムの縮小を防止 */
    }
    
    /* タブコンテンツのスタイル - 表示・非表示の基本設定は変更しない */
    .wp-renai-chat-tab-content.active {
        display: flex !important; /* モバイルではフレックス表示 */
        flex: 1;
        flex-direction: column;
        overflow-y: auto !important; /* スクロール可能に */
        -webkit-overflow-scrolling: touch; /* iOSでのスムーズなスクロール */
        padding-bottom: 20px;
        height: auto !important; /* 高さを自動調整 */
    }
    
    /* チャット画面のレイアウト調整 */
    #chat-tab {
        padding: 10px;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .wp-renai-chat-messages {
        flex: 1;
        height: auto;
        min-height: 200px;
        max-height: calc(100vh - 180px); /* ビューポート高さから他の要素の高さを引く */
    }
    
    .wp-renai-chat-input-area {
        margin-top: 10px;
        flex-shrink: 0; /* フレックスアイテムの縮小を防止 */
        padding-bottom: env(safe-area-inset-bottom); /* iPhoneXなどのホームバー対応 */
    }
    
    /* プロフィール・記念日・インポート画面の調整 */
    #profile-tab, #anniversary-tab, #import-tab {
        padding: 10px;
        overflow-y: auto !important;
        height: auto !important;
    }

    .wp-renai-chat-message-user,
    .wp-renai-chat-message-bot {
        max-width: 90%;
    }
    
    /* フォームのスタイル調整 */
    .wp-renai-chat-form-group input,
    .wp-renai-chat-form-group textarea,
    .wp-renai-chat-form-group select {
        font-size: 16px; /* モバイルでフォーム入力時のズームを防止 */
    }
    
    /* WordPressテーマのモバイルメニューを非表示 */
    .mobile-footer-menu-buttons,
    .mobile-menu-buttons {
        display: none !important;
    }
}

/* ローディング表示 */
.wp-renai-chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.wp-renai-chat-loading-dots {
    display: flex;
}

.wp-renai-chat-loading-dot {
    width: 10px;
    height: 10px;
    margin: 0 5px;
    background-color: #ff82a9;
    border-radius: 50%;
    animation: wp-renai-chat-loading 1.5s infinite ease-in-out;
}

.wp-renai-chat-loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wp-renai-chat-loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wp-renai-chat-loading {
    0%, 100% {
        transform: scale(0.7);
        opacity: 0.7;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
}

/* モバイル表示用スタイル */
.wp-renai-chat-mobile-back {
    display: none !important; /* 完全に非表示 */
    background-color: transparent;
    border: none;
    color: white;
    padding: 5px 10px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 10px;
    align-items: center;
}

.wp-renai-chat-mobile-back::before {
    content: "←";
    margin-right: 5px;
}

/* モバイル表示時の本体コンテンツ */
body.wp-renai-chat-mobile-active {
    overflow: hidden; /* スクロールを防止 */
}

/* デフォルトでモバイルアクティブ状態に */
body {
    overflow-x: hidden; /* 横スクロール防止 */
}

/* チャット起動ボタン */
.wp-renai-chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #ff82a9;
    border-radius: 50%;
    display: none; /* デフォルトで非表示に変更 */
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s;
}

.wp-renai-chat-launcher:hover {
    transform: scale(1.05);
    background-color: #ff5c90;
}

.wp-renai-chat-launcher::before {
    content: "💬";
    font-size: 24px;
    color: white;
}

/* マークダウン表示のスタイル */
.wp-renai-chat-message-bot h1,
.wp-renai-chat-message-bot h2,
.wp-renai-chat-message-bot h3 {
    margin: 10px 0;
    padding: 0;
    font-weight: bold;
}

.wp-renai-chat-message-bot h1 {
    font-size: 1.5em;
}

.wp-renai-chat-message-bot h2 {
    font-size: 1.3em;
}

.wp-renai-chat-message-bot h3 {
    font-size: 1.1em;
}

.wp-renai-chat-message-bot ul,
.wp-renai-chat-message-bot ol {
    padding-left: 20px;
    margin: 8px 0;
}

.wp-renai-chat-message-bot ul li,
.wp-renai-chat-message-bot ol li {
    margin-bottom: 5px;
}

.wp-renai-chat-message-bot hr {
    margin: 10px 0;
    border: 0;
    height: 1px;
    background-color: #e0e0e0;
}

.wp-renai-chat-message-bot strong {
    font-weight: bold;
}

.wp-renai-chat-message-bot em {
    font-style: italic;
} 