/* ==========================================================================
   壁打ちくん - 3カラムモダンUIスタイルシート
   ========================================================================== */

:root {
  --font-main: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* カラーパレット */
  --bg-app: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #0f172a;
  --bg-editor: #ffffff;
  --bg-panel: #1e293b;
  
  --border-color: #334155;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #1e293b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* 開発者/クライアント用色識別ボタン */
  --color-dev: #2563eb;
  --color-client: #dc2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ヘッダーバー */
.app-header {
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.brand-icon {
  background: var(--primary-gradient);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* メイン3カラムレイアウト */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  height: calc(100vh - 56px);
  width: 100vw;
  overflow: hidden;
}

/* === 左カラム: プロジェクトサイドバー === */
.sidebar-projects {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.column-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.column-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-new-project {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-new-project:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.project-search-box {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}

.project-search-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.project-search-input:focus {
  border-color: var(--primary);
}

.project-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.project-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-left 0.15s ease;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.project-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: var(--primary);
}

.project-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.project-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.project-item:hover .project-item-actions {
  opacity: 1;
}

.btn-icon-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-action:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.btn-icon-action.delete-action:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.project-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}


/* === 中央カラム: エディタ === */
.main-editor-container {
  display: flex;
  flex-direction: column;
  background: #0b1120;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.editor-toolbar-top {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}

.active-project-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.active-project-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.active-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  width: fit-content;
}

.badge-latest {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-viewing {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.7);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-right: 8px;
}

.color-tool-label {
  font-size: 0.75rem;
  color: var(--text-muted);

}

.btn-color-preset {
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.btn-color-preset:hover {
  transform: scale(1.05);
}

.btn-color-dev {
  background: var(--color-dev);
}

.btn-color-client {
  background: var(--color-client);
}

.btn-save {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

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

.btn-reload-latest {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-reload-latest:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* 警告・通知バナー */
.alert-banner {
  padding: 10px 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.2s ease;
}

.alert-banner-warning {
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.editor-wrapper {
  flex: 1;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* TinyMCEラッパー領域 */
.tox-tinymce {
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-md) !important;
  flex: 1 !important;
}


/* === 右カラム: 履歴サイドバー === */
.sidebar-revisions {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.revision-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 12px;
}

.revision-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.revision-item:hover {
  border-color: var(--primary);
  transform: translateX(-2px);
}

.revision-item.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  box-shadow: 0 0 0 1px var(--primary);
}

.revision-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.revision-version-tag {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
}

.revision-latest-tag {
  font-size: 0.7rem;
  color: #34d399;
  font-weight: 600;
}

.revision-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-edit-from-this {
  margin-top: 8px;
  width: 100%;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  padding: 6px 0;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-edit-from-this:hover {
  background: var(--primary);
  color: white;
}


/* === モーダル UI === */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: 90vw;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: white;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-input {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: white;
  font-size: 0.9rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* スクロールバー装飾 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
