/**
 * Event Comment Modal - スタイルシート
 * Version: 1.0.0
 */

/* =============================================================================
   モーダルオーバーレイ
   ============================================================================= */

.ecm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ecm-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* モーダルコンテナ */
.ecm-modal-container {
    background: #fff;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ecm-modal-overlay.active .ecm-modal-container {
    transform: scale(1);
}

/* =============================================================================
   モーダルヘッダー
   ============================================================================= */

.ecm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.ecm-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.ecm-modal-title .ecm-icon {
    color: #ff6b6b;
}

.ecm-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s ease;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ecm-modal-close:hover {
    background-color: #f5f5f5;
    color: #333;
}

/* =============================================================================
   モーダルボディ
   ============================================================================= */

.ecm-modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

/* コメント一覧エリア */
.ecm-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    min-height: 300px;
    max-height: calc(85vh - 280px);
}

/* スクロールバーのスタイリング */
.ecm-comments-list::-webkit-scrollbar {
    width: 8px;
}

.ecm-comments-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.ecm-comments-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.ecm-comments-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ローディング */
.ecm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
}

.ecm-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff6b6b;
    border-radius: 50%;
    animation: ecm-spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* コメントなし */
.ecm-no-comments {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #999;
}

.ecm-no-comments svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.ecm-no-comments p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
}

/* =============================================================================
   コメントアイテム
   ============================================================================= */

.ecm-comment-item {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: ecm-fadeIn 0.3s ease;
}

/* 他人のコメント（左側） */
.ecm-comment-item.ecm-comment-other {
    flex-direction: row;
    justify-content: flex-start;
}

/* 自分のコメント（右側） */
.ecm-comment-item.ecm-comment-own {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

@keyframes ecm-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ecm-comment-avatar {
    flex-shrink: 0;
}

.ecm-comment-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.ecm-comment-content-wrapper {
    flex: 1;
    max-width: 70%;
    border-radius: 12px;
    padding: 12px 16px;
}

/* 他人のコメントの吹き出し */
.ecm-comment-other .ecm-comment-content-wrapper {
    background-color: #f8f9fa;
}

/* 自分のコメントの吹き出し */
.ecm-comment-own .ecm-comment-content-wrapper {
    background-color: #e3f2fd;
}

.ecm-comment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.ecm-comment-author {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.ecm-comment-date {
    font-size: 12px;
    color: #999;
}

.ecm-comment-text {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    word-wrap: break-word;
}

.ecm-comment-text p {
    margin: 0 0 8px 0;
}

.ecm-comment-text p:last-child {
    margin-bottom: 0;
}

/* =============================================================================
   コメント投稿フォーム
   ============================================================================= */

.ecm-comment-form-wrapper {
    border-top: 1px solid #e0e0e0;
    padding: 20px 24px;
    background-color: #fafafa;
    flex-shrink: 0;
}

.ecm-comment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ecm-form-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ecm-user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.ecm-user-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

#ecm-comment-content {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 80px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: border-color 0.2s ease;
}

#ecm-comment-content:focus {
    outline: none;
    border-color: #ff6b6b;
}

.ecm-form-actions {
    display: flex;
    justify-content: flex-end;
}

.ecm-submit-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: #ff6b6b;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ecm-submit-btn:hover {
    background-color: #ff5252;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.ecm-submit-btn:active {
    transform: translateY(0);
}

.ecm-submit-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ecm-submit-btn svg {
    width: 16px;
    height: 16px;
}

/* ログイン通知 */
.ecm-login-notice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.ecm-login-notice svg {
    color: #ccc;
    margin-bottom: 16px;
}

.ecm-login-notice p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.ecm-login-notice a {
    color: #ff6b6b;
    text-decoration: none;
    font-weight: 600;
}

.ecm-login-notice a:hover {
    text-decoration: underline;
}

/* =============================================================================
   コメントボタンへのスタイル追加(single-event.php連携用)
   ============================================================================= */

/* 
 * テンプレート(single-event.php)のスタイルをそのまま使用
 * 追加のカスタムスタイルは不要
 * 
 * テンプレートの既存CSS:
 * .em-comment-action - フレックスコンテナ、縦並び
 * .em-comment-icon - アイコンのラッパー
 * .em-comment-count - 数字の表示（アイコンの下）
 */

.em-comment-action {
    cursor: pointer;
}


/* =============================================================================
   レスポンシブ対応
   ============================================================================= */

@media (max-width: 768px) {
    .ecm-modal-container {
        width: 95%;
        max-height: 90vh;
        border-radius: 12px;
    }
    
    .ecm-modal-header {
        padding: 16px 20px;
    }
    
    .ecm-modal-title {
        font-size: 18px;
    }
    
    .ecm-comments-list {
        padding: 16px 20px;
        max-height: calc(90vh - 260px);
    }
    
    .ecm-comment-form-wrapper {
        padding: 16px 20px;
    }
    
    .ecm-comment-item {
        gap: 10px;
    }
    
    .ecm-comment-content-wrapper {
        max-width: 80%;
    }
    
    .ecm-comment-avatar img {
        width: 36px;
        height: 36px;
    }
    
    .ecm-user-avatar img {
        width: 36px;
        height: 36px;
    }
    
    #ecm-comment-content {
        min-height: 70px;
        font-size: 13px;
    }
    
    .ecm-submit-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ecm-modal-container {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ecm-comments-list {
        max-height: calc(100vh - 260px);
    }
}

/* =============================================================================
   アニメーション
   ============================================================================= */

.ecm-comment-item.new-comment {
    animation: ecm-slideIn 0.4s ease;
}

@keyframes ecm-slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ボタンクリック時のフィードバック */
.em-comment-action.clicked {
    animation: ecm-buttonClick 0.3s ease;
}

@keyframes ecm-buttonClick {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* =============================================================================
   トーストメッセージ
   ============================================================================= */

.ecm-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #4caf50;
    color: #fff;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 600;
    z-index: 1000000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.ecm-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.ecm-toast-success {
    background-color: #4caf50;
}

.ecm-toast-error {
    background-color: #f44336;
}

@media (max-width: 768px) {
    .ecm-toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
        text-align: center;
    }
}