/* ============================================================
   表示制御ユーティリティ
============================================================ */
.hidden       { display: none !important; }
.visible      { display: block !important; }
.flex-visible { display: flex !important; }

/* ============================================================
   基本スタイル
============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #FFE4C4 0%, #FFD7A8 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ============================================================
   ログイン画面
============================================================ */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.login-container h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 30px;
    text-align: center;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: #00809E;
    box-shadow: 0 0 0 3px rgba(0, 128, 158, 0.1);
}

.login-form .btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #00809E 0%, #005f7a 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.login-form .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 128, 158, 0.4);
}

.login-form .btn-login:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.change-password-note {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
}

.error-message {
    background: #fee;
    color: #c00;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid #fcc;
}

/* ============================================================
   メインコンテナ
============================================================ */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: white;
    color: #333;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #333;
}

.subtitle {
    color: #666;
    font-size: 14px;
}

.user-info {
    text-align: right;
}

.user-email {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.btn-logout {
    padding: 8px 20px;
    background: #f5f7fa;
    color: #333;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #e1e8ed;
}

/* ============================================================
   検索パネル
============================================================ */
.search-panel {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.date-range-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.search-buttons {
    display: flex;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

input {
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

input:focus {
    outline: none;
    border-color: #00809E;
    box-shadow: 0 0 0 3px rgba(0, 128, 158, 0.1);
}

input[type="text"]#conversationNumber {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================================
   ボタン
============================================================ */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-secondary {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-primary {
    background: linear-gradient(135deg, #00809E 0%, #005f7a 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 128, 158, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f5f7fa;
    color: #333;
}

.btn-secondary:hover {
    background: #e1e8ed;
}

/* ============================================================
   検索結果
============================================================ */
.results {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-height: 200px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.results-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.conversation-card {
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    transition: all 0.3s;
    background: #fafbfc;
}

.conversation-card:hover {
    border-color: #00809E;
    box-shadow: 0 4px 12px rgba(0, 128, 158, 0.15);
    transform: translateY(-2px);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e1e8ed;
}

.conversation-number {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #555;
    letter-spacing: 1px;
}

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.badge-escalated {
    background: #fee;
    color: #c00;
}

.badge-normal {
    background: #efe;
    color: #060;
}

.conversation-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.meta-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

/* ============================================================
   メッセージ
============================================================ */
.message-list {
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.message {
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}

.message-user {
    background: linear-gradient(135deg, #CCE6EC 0%, #a8d5dd 100%);
    margin-left: 40px;
    border-bottom-right-radius: 4px;
}

.message-bot {
    background: linear-gradient(135deg, #FBE7D0 0%, #f5d9ba 100%);
    margin-right: 40px;
    border-bottom-left-radius: 4px;
}

.message-system {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    text-align: center;
    font-weight: 500;
}

.message-meta {
    font-size: 11px;
    color: #666;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-time {
    opacity: 0.7;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e8ed;
}

.summary-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.summary-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 24px;
    font-weight: bold;
    color: #555;
}

/* ============================================================
   ローディング・エラー・空状態
============================================================ */
.loading {
    text-align: center;
    padding: 60px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #00809E;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.error {
    background: linear-gradient(135deg, #fee 0%, #fcc 100%);
    color: #c00;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #faa;
}

.empty {
    text-align: center;
    padding: 60px;
    color: #999;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* ============================================================
   スクロールバー
============================================================ */
.message-list::-webkit-scrollbar       { width: 8px; }
.message-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.message-list::-webkit-scrollbar-thumb { background: #00809E; border-radius: 4px; }
.message-list::-webkit-scrollbar-thumb:hover { background: #005f7a; }

/* ============================================================
   モーダル
============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 500px;
    text-align: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.modal-icon    { font-size: 48px; margin-bottom: 20px; }
.modal-title   { font-size: 24px; margin-bottom: 15px; color: #333; }
.modal-message { font-size: 16px; color: #666; margin-bottom: 30px; line-height: 1.6; }
.modal-buttons { display: flex; gap: 15px; justify-content: center; }
.modal-note    { font-size: 13px; color: #999; margin-top: 20px; }

/* ============================================================
   トースト通知
============================================================ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 9999;
    font-size: 14px;
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s;
}

@keyframes slideInRight {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.toast-success { background: #060; color: white; }
.toast-error   { background: #c00; color: white; }
.toast-info    { background: #007bff; color: white; }

/* ============================================================
   ページネーション
============================================================ */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 2px solid #f0f0f0;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 20px;
    background: #fafbfc;
}

.pagination-info { font-size: 14px; color: #666; }

.pagination-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pagination-buttons { display: flex; gap: 5px; }

.page-button {
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    background: white;
    color: #333;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 40px;
}

.page-button:hover:not(:disabled) {
    background: #f5f7fa;
    border-color: #00809E;
}

.page-button:disabled { opacity: 0.3; cursor: not-allowed; }

.page-button.active {
    background: linear-gradient(135deg, #00809E 0%, #005f7a 100%);
    color: white;
    border-color: #00809E;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #666;
}

.page-size-selector select {
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    background: white;
}

.page-size-selector select:focus {
    outline: none;
    border-color: #00809E;
}

/* ============================================================
   レスポンシブ
============================================================ */
@media (max-width: 768px) {
    .search-form          { grid-template-columns: 1fr; }
    .conversation-number  { font-size: 18px; }
    .message-user         { margin-left: 10px; }
    .message-bot          { margin-right: 10px; }
}