/* ============================================
   空間OSホワイトボード - 全体スタイル
   ============================================ */

/* ----- リセット & ベース ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5;
    color: #2d3748;
    overflow: hidden;
}

/* ----- スクロールバーカスタマイズ ----- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c7cd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ----- アプリケーションコンテナ ----- */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============================================
   ツールバー（ヘッダー）
   ============================================ */
#toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 6px 12px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    min-height: 48px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    z-index: 100;
}

/* ツールバーグループ */
#toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid #e2e8f0;
    flex-shrink: 0;
}

#toolbar .toolbar-group:last-child {
    border-right: none;
    margin-left: auto;
}

/* ツールボタン（汎用） */
#toolbar .tool-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #4a5568;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    height: 32px;
    min-width: 44px;
}

#toolbar .tool-btn:hover {
    background: #edf2f7;
    color: #2d3748;
}

#toolbar .tool-btn.active {
    background: #4A90D9;
    color: white;
}

#toolbar .tool-btn.active:hover {
    background: #357ABD;
}

/* 機能ボタン */
#toolbar .func-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #4a5568;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    height: 32px;
}

#toolbar .func-btn:hover {
    background: #edf2f7;
    color: #2d3748;
}

/* バッジ */
#toolbar .badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

#toolbar .badge.side {
    background: #6c757d;
    color: white;
}

#toolbar .badge.side.front {
    background: #4A90D9;
}

#toolbar .badge.side.back {
    background: #6f42c1;
}

#toolbar .badge.stats {
    background: #e9ecef;
    color: #495057;
}

/* ログアウトボタン */
#toolbar #logout-btn {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #e53e3e;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

#toolbar #logout-btn:hover {
    background: #fff5f5;
}

/* ============================================
   メインエリア（3カラム）
   ============================================ */
#main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ============================================
   左: 帯域ビュー（ノード一覧）
   ============================================ */
#band-view {
    width: 240px;
    min-width: 180px;
    background: white;
    border-right: 1px solid #e2e8f0;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

#band-view .band-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#band-view .band-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin: 0;
    letter-spacing: 0.3px;
}

#band-view .band-header .small-btn {
    padding: 2px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

#band-view .band-header .small-btn:hover {
    background: #f7fafc;
    border-color: #a0aec0;
}

#band-view h3 {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin: 16px 0 10px 0;
    letter-spacing: 0.3px;
}

#band-view h3:first-of-type {
    margin-top: 0;
}

/* ノード一覧 */
#node-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.node-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s;
}

.node-item:hover {
    background: #f7fafc;
}

.node-item.selected {
    background: #ebf8ff;
    border-left: 3px solid #4A90D9;
}

.node-item .node-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #4A90D9;
}

.node-item .node-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-item .node-content {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-item .node-tags {
    font-size: 10px;
    color: #a0aec0;
    flex-shrink: 0;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* タグフィルター */
#tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-filter-item {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: #edf2f7;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    user-select: none;
}

.tag-filter-item:hover {
    background: #e2e8f0;
}

.tag-filter-item.active {
    background: #4A90D9;
    color: white;
    border-color: #4A90D9;
}

/* ============================================
   中央: Canvasコンテナ
   ============================================ */
#canvas-container {
    flex: 1;
    position: relative;
    background: white;
    overflow: hidden;
    min-width: 0;
}

#whiteboard-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: default;
    background: #ffffff;
}

#debris-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: block;
}

/* ============================================
   右: チャネルビュー（プロパティ）
   ============================================ */
#channel-view {
    width: 280px;
    min-width: 220px;
    background: white;
    border-left: 1px solid #e2e8f0;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

#channel-view h3 {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin: 0 0 12px 0;
    letter-spacing: 0.3px;
}

/* アクションパネル */
#action-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.action-group label {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
}

#selected-count {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    text-align: center;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.action-btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.action-btn.primary-btn {
    background: #4A90D9;
    color: white;
}

.action-btn.primary-btn:not(:disabled):hover {
    background: #357ABD;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

.action-btn.danger-btn {
    background: #dc3545;
    color: white;
}

.action-btn.danger-btn:not(:disabled):hover {
    background: #c82333;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.action-btn.warning-btn {
    background: #f6ad55;
    color: white;
}

.action-btn.warning-btn:hover {
    background: #ed8936;
    box-shadow: 0 2px 8px rgba(246, 173, 85, 0.3);
}

.hint {
    font-size: 12px;
    color: #a0aec0;
    padding-left: 4px;
}

.hint.error {
    color: #dc3545;
}

/* プロパティ */
#properties {
    margin-top: 4px;
}

#properties label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #4a5568;
    margin-top: 10px;
    margin-bottom: 4px;
}

#properties textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
}

#properties textarea:focus {
    outline: none;
    border-color: #4A90D9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

#properties input[type="color"] {
    width: 48px;
    height: 36px;
    padding: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
}

#properties input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.2s;
}

#properties input[type="text"]:focus {
    outline: none;
    border-color: #4A90D9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

#tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 8px;
    min-height: 28px;
}

#tag-list .tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px 2px 12px;
    background: #edf2f7;
    border-radius: 12px;
    font-size: 12px;
    color: #2d3748;
}

#tag-list .tag-item .remove-tag {
    cursor: pointer;
    color: #a0aec0;
    font-weight: bold;
    font-size: 14px;
    transition: color 0.2s;
    line-height: 1;
}

#tag-list .tag-item .remove-tag:hover {
    color: #e53e3e;
}

.tag-input-group {
    display: flex;
    gap: 4px;
}

.tag-input-group input {
    flex: 1;
}

.tag-input-group button {
    padding: 6px 14px;
    background: #4A90D9;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.tag-input-group button:hover {
    background: #357ABD;
}

/* ============================================
   レスポンシブ
   ============================================ */
@media (max-width: 1024px) {
    #band-view {
        width: 180px;
        min-width: 140px;
    }
    #channel-view {
        width: 220px;
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    #band-view {
        display: none;
    }
    #channel-view {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }
    #main {
        flex-direction: column-reverse;
    }
    #canvas-container {
        flex: 1;
        min-height: 0;
    }
    #toolbar {
        padding: 4px 8px;
        gap: 3px 6px;
    }
    #toolbar .tool-btn {
        padding: 4px 10px;
        font-size: 12px;
        height: 28px;
        min-width: 36px;
    }
    #toolbar .func-btn {
        padding: 4px 8px;
        font-size: 12px;
        height: 28px;
    }
    #toolbar .badge {
        font-size: 10px;
        padding: 2px 8px;
    }
    #toolbar .toolbar-group {
        padding: 0 4px;
        gap: 2px;
    }
}

@media (max-width: 480px) {
    #toolbar {
        padding: 4px 6px;
        gap: 2px 4px;
        min-height: 40px;
    }
    #toolbar .tool-btn {
        padding: 3px 8px;
        font-size: 11px;
        height: 26px;
        min-width: 32px;
    }
    #toolbar .func-btn {
        padding: 3px 6px;
        font-size: 11px;
        height: 26px;
    }
    #toolbar .badge {
        font-size: 9px;
        padding: 2px 6px;
    }
    #toolbar .toolbar-group {
        padding: 0 2px;
        gap: 1px;
        border-right: none;
    }
    #channel-view {
        max-height: 50vh;
        padding: 12px;
    }
    .action-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ============================================
   アニメーション
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 1s ease-in-out infinite;
}

/* ============================================
   ツールチップ
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: #2d3748;
    color: white;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
}

/* ============================================
   ローディング
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #4A90D9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* カラーピッカー横のHEX表示 */
#color-hex {
    font-size: 13px;
    color: #6c757d;
    font-family: monospace;
    min-width: 70px;
}

/* ============================================
   全体共通スタイル（style.css に追加）
   ============================================ */

/* ----- プロパティパネル（全体共通） ----- */
#channel-view {
    width: 280px;
    min-width: 220px;
    background: white;
    border-left: 1px solid #e2e8f0;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

#channel-view h3 {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin: 0 0 12px 0;
    letter-spacing: 0.3px;
}

/* ----- カラーピッカーグループ（全体共通） ----- */
.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 70px;
}

.color-picker-group label {
    font-size: 10px;
    color: #6c757d;
    text-align: center;
}

.color-picker-group input[type="color"] {
    width: 100%;
    height: 32px;
    padding: 2px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
}

/* ----- 全更新ボタン（全体共通） ----- */
#update-all-btn {
    width: 100%;
    padding: 12px;
    background: #4A90D9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#update-all-btn:hover {
    background: #357ABD;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.4);
}

/* ----- エッジスタイル選択（全体共通） ----- */
#edge-style {
    width: 100%;
    padding: 4px 8px;
    margin-top: 4px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 13px;
}

/* ============================================
   Duplex機能用スタイル
   ============================================ */

   .duplex-group {
    border-top: 1px solid #e9ecef;
    padding-top: 12px;
    margin-top: 8px;
}

.duplex-group label {
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
}

.duplex-status {
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
}

.duplex-status.warning {
    background: #fffbeb;
    color: #92400e;
}

.duplex-status.ok {
    background: #f0fff4;
    color: #276749;
}

#duplex-btn {
    margin-top: 4px;
}

#duplex-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#duplex-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}