/* ========================================
   NKSS Claude Chatbot - フロントエンドスタイル
   ======================================== */

:root {
    --nkss-primary:    #1a5c8f;
    --nkss-primary-d:  #144a73;
    --nkss-accent:     #e67e22;
    --nkss-accent-d:   #d35400;
    --nkss-bg:         #f5f7fa;
    --nkss-white:      #ffffff;
    --nkss-text:       #2c3e50;
    --nkss-text-light: #7f8c8d;
    --nkss-border:     #dde3ea;
    --nkss-shadow:     0 8px 32px rgba(0,0,0,0.18);
    --nkss-radius:     16px;
}

/* ── ラッパー ── */
#nkss-chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
                 'Yu Gothic', Meiryo, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* ── トグルボタン ── */
#nkss-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--nkss-primary);
    color: var(--nkss-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(26,92,143,0.45);
    transition: transform 0.2s ease, background 0.2s ease;
    position: relative;
    margin-left: auto;
}
#nkss-chatbot-toggle:hover {
    background: var(--nkss-primary-d);
    transform: scale(1.08);
}
#nkss-chatbot-toggle:active {
    transform: scale(0.96);
}

/* 未読バッジ */
#nkss-chatbot-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--nkss-accent);
    border: 2px solid var(--nkss-white);
    display: none;
}
#nkss-chatbot-toggle.has-unread::after {
    display: block;
}

/* ── チャットウィンドウ ── */
#nkss-chatbot-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 520px;
    background: var(--nkss-white);
    border-radius: var(--nkss-radius);
    box-shadow: var(--nkss-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: nkss-fadein 0.25s ease;
}

@keyframes nkss-fadein {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── ヘッダー ── */
#nkss-chatbot-header {
    background: var(--nkss-primary);
    color: var(--nkss-white);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
#nkss-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
#nkss-chatbot-icon-header {
    font-size: 18px;
}
#nkss-chatbot-title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.02em;
}
#nkss-chatbot-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--nkss-white);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
#nkss-chatbot-close:hover {
    background: rgba(255,255,255,0.28);
}

/* ── メッセージエリア ── */
#nkss-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--nkss-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
#nkss-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}
#nkss-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
#nkss-chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--nkss-border);
    border-radius: 4px;
}

/* ── メッセージバブル ── */
.nkss-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 90%;
}
.nkss-msg.user  { align-self: flex-end;  flex-direction: row-reverse; }
.nkss-msg.bot   { align-self: flex-start; }

.nkss-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--nkss-primary);
    color: var(--nkss-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.nkss-msg.user .nkss-msg-avatar {
    background: var(--nkss-accent);
}

.nkss-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}
.nkss-msg.user .nkss-msg-bubble {
    background: var(--nkss-primary);
    color: var(--nkss-white);
    border-bottom-right-radius: 4px;
}
.nkss-msg.bot .nkss-msg-bubble {
    background: var(--nkss-white);
    color: var(--nkss-text);
    border: 1px solid var(--nkss-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── ローディングアニメーション ── */
.nkss-loading .nkss-msg-bubble {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    align-items: center;
}
.nkss-loading .nkss-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--nkss-text-light);
    animation: nkss-bounce 1.2s infinite ease-in-out;
}
.nkss-loading .nkss-dot:nth-child(2) { animation-delay: 0.18s; }
.nkss-loading .nkss-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes nkss-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ── 入力エリア ── */
#nkss-chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--nkss-border);
    background: var(--nkss-white);
    flex-shrink: 0;
}
#nkss-chatbot-input {
    flex: 1;
    border: 1.5px solid var(--nkss-border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13.5px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 110px;
    overflow-y: auto;
    color: var(--nkss-text);
    transition: border-color 0.2s;
    line-height: 1.5;
}
#nkss-chatbot-input:focus {
    border-color: var(--nkss-primary);
}
#nkss-chatbot-input::placeholder {
    color: var(--nkss-text-light);
}
#nkss-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--nkss-accent);
    color: var(--nkss-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
#nkss-chatbot-send:hover:not(:disabled) {
    background: var(--nkss-accent-d);
    transform: scale(1.06);
}
#nkss-chatbot-send:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* ── フッター ── */
#nkss-chatbot-footer {
    padding: 6px 14px;
    text-align: center;
    font-size: 11px;
    color: var(--nkss-text-light);
    border-top: 1px solid var(--nkss-border);
    background: var(--nkss-white);
}

/* ── エラー表示 ── */
.nkss-msg.error .nkss-msg-bubble {
    background: #fdecea;
    border-color: #f5c6cb;
    color: #c0392b;
}

/* ── モバイル対応 ── */
@media (max-width: 480px) {
    #nkss-chatbot-wrapper {
        bottom: 16px;
        right: 16px;
    }
    #nkss-chatbot-window {
        width: calc(100vw - 32px);
        max-height: 70vh;
        right: 0;
        bottom: 68px;
    }
}

/* ========================================
   管理画面スタイル
   ======================================== */

.nkss-admin-wrap h1 {
    margin-bottom: 20px;
}
.nkss-section {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.nkss-section h2 {
    margin-top: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e4e7;
    font-size: 16px;
    color: #1d2327;
}
.nkss-faq-item {
    border: 1px solid #dde3ea;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}
.nkss-faq-header {
    background: #f5f7fa;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}
.nkss-faq-body {
    padding: 12px 14px;
    display: grid;
    gap: 6px;
}
.nkss-faq-body label {
    font-weight: 600;
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}
.nkss-faq-body input,
.nkss-faq-body textarea {
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
}
#nkss-faq-status {
    font-weight: 600;
}
#nkss-faq-status.success { color: #0a7f1f; }
#nkss-faq-status.error   { color: #c0392b; }
#nkss-test-result.success {
    background: #eafaf1;
    border: 1px solid #a9dfbf;
    color: #1e8449;
}
#nkss-test-result.error {
    background: #fdecea;
    border: 1px solid #f5c6cb;
    color: #c0392b;
}

/* ═══════════════════════════════════════════════════════
   チャット履歴 管理画面スタイル (v1.1.0)
═══════════════════════════════════════════════════════ */

/* 統計カード行 */
.nkss-stats-row {
    display: flex;
    gap: 16px;
    margin: 20px 0 24px;
    flex-wrap: wrap;
}
.nkss-stat-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 18px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 110px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.nkss-stat-number {
    font-size: 32px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1;
    margin-bottom: 6px;
}
.nkss-stat-label {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}
.nkss-stat-line   { border-top: 3px solid #00b900; }
.nkss-stat-web    { border-top: 3px solid #0073aa; }
.nkss-stat-today  { border-top: 3px solid #f39c12; }

/* フィルター行 */
.nkss-filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.nkss-tab-filter {
    display: flex;
    gap: 4px;
}
.nkss-tab-btn {
    display: inline-block;
    padding: 6px 14px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #f6f7f7;
    color: #2c3338;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    transition: background .15s;
}
.nkss-tab-btn:hover   { background: #e5e5e5; color: #2c3338; }
.nkss-tab-active,
.nkss-tab-active:hover {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}
.nkss-search-form {
    display: flex;
    gap: 6px;
    align-items: center;
}
.nkss-search-form input[type=search] {
    width: 220px;
    padding: 5px 10px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    font-size: 13px;
}
.nkss-action-btns {
    margin-left: auto;
}

/* テーブル */
.nkss-chatlog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}
.nkss-chatlog-table th {
    background: #f6f7f7;
    border-bottom: 2px solid #e0e0e0;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3338;
    white-space: nowrap;
}
.nkss-chatlog-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
    color: #2c3338;
}
.nkss-log-row:hover td { background: #f9f9f9; }
.col-id      { width: 48px; color: #888; text-align: center; }
.col-source  { width: 80px; text-align: center; }
.col-user    { width: 120px; font-size: 12px; color: #555; }
.col-message { width: 28%; }
.col-reply   { width: 28%; }
.col-date    { width: 110px; font-size: 12px; color: #666; white-space: nowrap; }
.col-action  { width: 48px; text-align: center; }

/* セル内テキスト（クリックで全文表示） */
.nkss-cell-expand {
    max-height: 60px;
    overflow: hidden;
    line-height: 1.5;
    cursor: pointer;
    position: relative;
}
.nkss-cell-expand::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 20px;
    background: linear-gradient(transparent, rgba(249,249,249,.9));
}
.nkss-log-row:hover .nkss-cell-expand::after {
    background: linear-gradient(transparent, rgba(249,249,249,.95));
}

/* バッジ */
.nkss-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.nkss-badge-line { background: #e8f9e8; color: #1a7f1a; border: 1px solid #b2e0b2; }
.nkss-badge-web  { background: #e8f0ff; color: #1a4fb0; border: 1px solid #b2c8f5; }

/* 削除ボタン */
.nkss-delete-btn {
    color: #c0392b;
    text-decoration: none;
    font-size: 12px;
    opacity: .7;
}
.nkss-delete-btn:hover { opacity: 1; color: #922b21; }

/* ページネーション */
.nkss-pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
}
.nkss-pagination a,
.nkss-pagination .current {
    display: inline-block;
    padding: 5px 11px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    background: #f6f7f7;
    color: #2c3338;
    min-width: 32px;
    text-align: center;
}
.nkss-pagination .current {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    font-weight: 600;
}

/* ── LINE QR画像 ── */
.nkss-line-qr-link {
    display: inline-block;
    margin-top: 8px;
}
.nkss-line-qr {
    display: block;
    width: 160px;
    height: 160px;
    border-radius: 8px;
}
.nkss-pagination a:hover { background: #e5e5e5; }
