/* ============================================================
   NSC Hotel Chatbot - Knowledge Admin Stylesheet
   knowledge-admin.html 用のスタイルシート
   ============================================================ */

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background: #f0f2f5;
}

/* ============================================================
   Layout
   ============================================================ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1a365d 0%, #2d4a7a 100%);
  color: #fff;
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.app-header .header-sub {
  font-size: 12px;
  opacity: 0.8;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-right .nav-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}
.header-right .nav-link:hover {
  color: #fff;
}

/* --- Toolbar --- */
.toolbar {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #dde1e6;
  padding: 12px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-input {
  height: 36px;
  width: 280px;
  padding: 0 12px 0 36px;
  border: 1px solid #c4cad3;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238892a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") 10px center no-repeat;
  transition: border-color 0.2s;
}
.search-input:focus {
  outline: none;
  border-color: #2d4a7a;
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.12);
}

/* --- Buttons --- */
.btn {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary {
  background: #1a365d;
  color: #fff;
}
.btn-primary:hover {
  background: #2d4a7a;
  box-shadow: 0 2px 6px rgba(26, 54, 93, 0.3);
}
.btn-success {
  background: #2b7a3e;
  color: #fff;
}
.btn-success:hover {
  background: #226331;
  box-shadow: 0 2px 6px rgba(43, 122, 62, 0.3);
}
.btn-danger {
  background: #c53030;
  color: #fff;
}
.btn-danger:hover {
  background: #9b2c2c;
}
.btn-secondary {
  background: #e8ecf1;
  color: #5a6474;
}
.btn-secondary:hover {
  background: #dde1e6;
}
.btn-outline {
  background: transparent;
  color: #2d4a7a;
  border: 1px solid #c4cad3;
}
.btn-outline:hover {
  background: #f0f4f9;
  border-color: #2d4a7a;
}
.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Main Content (Split View) --- */
.main-content {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 16px 24px 24px;
  gap: 16px;
}

/* --- Left: Q&A List --- */
.list-panel {
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8ecf1;
  background: #fafbfc;
}
.list-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #1a365d;
}
.list-count {
  font-size: 12px;
  color: #8892a0;
}
.qa-list-wrapper {
  flex: 1;
  overflow-y: auto;
}
.qa-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
  transition: background 0.15s;
}
.qa-item:hover {
  background: #edf2f9;
}
.qa-item.selected {
  background: #dbe5f3;
  border-left: 3px solid #1a365d;
}
.qa-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.qa-item-id {
  font-size: 11px;
  font-weight: 600;
  color: #8892a0;
  font-family: 'Consolas', 'Monaco', monospace;
}
.qa-item-question {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.qa-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 11px;
  color: #a0a8b4;
}

/* --- Right: Detail / Editor --- */
.detail-panel {
  flex: 0 0 58%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8ecf1;
  background: #fafbfc;
}
.detail-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #1a365d;
}
.detail-header-actions {
  display: flex;
  gap: 8px;
}
.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* --- Editor Form --- */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #5a6474;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-group label .required {
  color: #c53030;
  margin-left: 2px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c4cad3;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #333;
  background: #fff;
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: #2d4a7a;
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.12);
}
textarea.form-control {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}
.form-hint {
  font-size: 11px;
  color: #a0a8b4;
  margin-top: 4px;
}

/* --- Placeholder --- */
.detail-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #a0a8b4;
  gap: 12px;
}
.detail-placeholder .ph-icon {
  font-size: 48px;
  opacity: 0.4;
}
.detail-placeholder p {
  font-size: 14px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
  z-index: 1000;
  pointer-events: none;
  color: #fff;
}
.toast.toast-success { background: #2b7a3e; }
.toast.toast-error { background: #c53030; }
.toast.toast-info { background: #2d4a7a; }
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 900;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1a365d;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #8892a0;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e8ecf1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Import Preview Table --- */
.import-preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}
.import-preview th {
  background: #f0f2f5;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: #5a6474;
  border-bottom: 2px solid #dde1e6;
}
.import-preview td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f2f5;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Drag & Drop Area --- */
.drop-area {
  border: 2px dashed #c4cad3;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  color: #8892a0;
  transition: all 0.2s;
  cursor: pointer;
}
.drop-area:hover,
.drop-area.dragover {
  border-color: #2d4a7a;
  background: #f0f4f9;
  color: #2d4a7a;
}
.drop-area .drop-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.drop-area p {
  font-size: 13px;
}
.drop-area .drop-hint {
  font-size: 11px;
  margin-top: 6px;
}

/* --- Index / S3 不一致アラート --- */
.index-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0;
  background: #fff3cd;
  border-bottom: 1px solid #f0d78c;
  color: #856404;
  font-size: 12px;
  line-height: 1.5;
  flex-shrink: 0;
}
.index-alert-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.index-alert-text {
  flex: 1;
}
.index-alert .btn-warning {
  background: #e0a800;
  color: #fff;
  border: none;
  padding: 3px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.index-alert .btn-warning:hover {
  background: #c69500;
}

/* --- S3 Sync Section --- */
.sync-section {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid #e8ecf1;
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sync-info {
  font-size: 12px;
  color: #5a6474;
}
.sync-info .sync-time {
  font-weight: 600;
  color: #333;
}
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38a169;
}
.sync-dot.syncing {
  background: #ecc94b;
  animation: pulse 1s infinite;
}
.sync-dot.error {
  background: #c53030;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Loading overlay --- */
.loading-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 10;
  align-items: center;
  justify-content: center;
}
.loading-overlay.active {
  display: flex;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e8ecf1;
  border-top-color: #2d4a7a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- S3 File Info --- */
.s3-file-info {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f7f8fa;
  border: 1px solid #e8ecf1;
  border-radius: 6px;
  font-size: 12px;
  color: #5a6474;
}
.s3-file-info code {
  font-family: 'Consolas', 'Monaco', monospace;
  color: #1a365d;
  background: #edf2f9;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* --- Footer --- */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #a0a8b4;
  background: #f0f2f5;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cad3; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8b4; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
    padding: 12px 16px 16px;
  }
  .list-panel, .detail-panel {
    flex: none;
    height: 50%;
  }
}
