/* 基本レイアウト */
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* ハンバーガーメニューボタン */
.hamburger-btn {
    display: none;
    background: #2c3e50;
    border: none;
    padding: 0.5rem 0.6rem;
    cursor: pointer;
    margin-right: 0;
    border-radius: 4px;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: #34495e;
}

.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    margin: 5px 0;
    transition: 0.3s;
    border-radius: 2px;
}

/* サイドバー */
.sidebar {
    width: 230px;
    min-width: 180px;
    max-width: 400px;
    background: #2c3e50;
    color: white;
    padding: 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    background: #34495e;
    padding: 1rem;
    border-bottom: 1px solid #4a5f7a;
}

.sidebar-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: #ecf0f1;
    text-decoration: none;
    border-bottom: 1px solid #34495e;
    cursor: pointer;
    transition: background-color 0.3s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.menu-item:hover {
    background-color: #34495e;
}

.menu-item.active {
    background-color: #16a085;
    border-left: 4px solid #1abc9c;
}

/* サイドバーメニューセクション */
.menu-section {
    border-bottom: 1px solid #34495e;
}

.menu-section-title {
    padding: 0.75rem 1rem;
    background: #34495e;
    color: #ecf0f1;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.menu-section-title:hover {
    background: #4a5f7a;
}

/* メニューアイコン */
.menu-icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
    opacity: 0.8;
}

.menu-item:hover .menu-icon,
.menu-item.active .menu-icon {
    opacity: 1;
}

.arrow {
    font-size: 1.4rem;
    font-weight: bold;
    transition: all 0.3s;
    margin-left: auto;
    line-height: 1;
}

.arrow.expanded {
    /* 回転なし、キャレットの向きで表現 */
}

.menu-subsection {
    background: #2c3e50;
    border-left: 3px solid #007acc;
}

.menu-subsection .menu-item {
    padding-left: 2rem;
    border-bottom: 1px solid #34495e;
    font-size: 0.9rem;
}

.menu-item.app-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ecf0f1;
    text-decoration: none;
    white-space: nowrap;
}

.app-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 230px; /* サイドバー分のマージン */
}

.content-header {
    background: #16a085;
    padding: 0.75rem 1rem 0.75rem 0.75rem;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 0.75rem;
}

.content-title {
    margin: 0;
    color: white;
    font-size: 1.25rem;
    margin-right: auto;
}

.admin-env-badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}

.env-switch-link {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    display: none;
    transition: background 0.2s;
}
.env-switch-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    font-weight: 500;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* プライマリ（実行系）: 保存、検索、絞り込み、アップロード等 */
.btn-primary {
    background: #0891b2;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0e7490;
}

/* 成功/確定 */
.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

/* 危険/削除 */
.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* セカンダリ（キャンセル、閉じる等） */
.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

/* コンテンツエリア */
.content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    align-items: stretch;
}

.content-left {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 1000px;
}

.content-right {
    width: 300px;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* FAQ機能用の内部コンテンツ */
#leftContent {
    width: 100%;
}

/* FAQ編集時のみleftContentを伸ばす */
#leftContent.faq-editing {
    min-height: 100%;
}

#rightContent {
    width: 100%;
    height: 100%;
}

/* 分析レイアウト */
.analytics-layout {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.analytics-content {
    width: 100%;
    height: 100%;
    flex: 1;
}

/* 分析専用フルワイドレイアウト */
.analytics-fullwidth {
    width: 100%;
    height: 100%;
    padding: 0;
    overflow-y: auto;
}

/* 分析機能使用時のcontent-left余白リセット */
.content-left:has(.analytics-fullwidth) {
    padding: 1rem;
}

/* ウェルカム画面 */
.welcome-screen {
    padding: 2rem;
    text-align: center;
}

.welcome-screen h1 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.welcome-screen p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

/* ユーティリティ */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .content-area {
        flex-direction: column;
    }
    
    .content-right {
        width: 100%;
    }
}
/* サイドバーフッター */
.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid #34495e;
}

.signout-btn {
    width: 100%;
    padding: 0.75rem;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.signout-btn:hover {
    background: #4b5563;
}


/* タブレット・スマホ対応 */
@media (max-width: 1024px) {
    .hamburger-btn {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

/* HOME以外：サイドバーをハンバーガーに切り替え */
body.sidebar-collapsed .hamburger-btn {
    display: block;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .sidebar.active {
    transform: translateX(0);
}

body.sidebar-collapsed .main-content {
    margin-left: 0 !important;
}

body.sidebar-collapsed .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

body.sidebar-collapsed .sidebar-overlay.active {
    display: block;
}

/* Tabulator: カスタムスタイル */
#usageTabulator, #feedbackTabulator, [id^="csvTable_"] {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
}
#usageTabulator .tabulator-table,
#feedbackTabulator .tabulator-table,
[id^="csvTable_"] .tabulator-table {
    width: 100% !important;
}
.tabulator-cell .app-badge,
.tabulator-cell .type-badge {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%;
    font-size: 11px;
}

/* Quill箇条書き・番号リスト互換 */
li[data-list="bullet"] { list-style-type: disc !important; }
li[data-list="ordered"] { list-style-type: decimal !important; }
li[data-list] .ql-ui { display: none; }
ol:has(li[data-list="bullet"]) { list-style-type: disc !important; padding-left: 1.5em; }

/* Driver.js ガイドポップオーバー拡大 */
.driver-popover { max-width: 420px !important; }
.driver-popover .driver-popover-title { font-size: 1.15rem !important; }
.driver-popover .driver-popover-description { font-size: 1rem !important; line-height: 1.6 !important; }


/* Quillエディタ左右配置 */
.editor-wrap {
    display: flex;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    min-height: 500px;
}

#quillToolbar {
    width: 100px;
    background: #f8f9fa;
    border-right: 2px solid #e0e0e0;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

#quillToolbar button {
    width: 80px !important;
    height: 60px !important;
    border-radius: 8px;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: white;
    border: 2px solid #e0e0e0 !important;
    margin: 0 !important;
    transition: all 0.2s;
    padding: 0 !important;
    cursor: pointer;
}

#quillToolbar button:hover {
    background: #e3f2fd;
    border-color: #2196f3 !important;
    transform: translateX(4px);
}

#quillToolbar button.ql-active {
    background: #2196f3 !important;
    border-color: #1976d2 !important;
}

#quillToolbar button.ql-active svg {
    stroke: white !important;
    fill: white !important;
}

#quillToolbar button svg {
    width: 22px;
    height: 22px;
}

#quillToolbar button::after {
    content: attr(data-label);
    font-size: 10px;
    color: #333;
    font-weight: 600;
}

#quillToolbar button.ql-active::after {
    color: white !important;
}

.editor-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-header {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.editor-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 20px;
    color: #666;
}

.editor-action-btn:hover {
    background: #2196f3;
    border-color: #2196f3;
    color: white;
}

.editor-wrap .ql-container {
    flex: 1;
    font-size: 15px;
    border: none !important;
}

.editor-wrap .ql-editor {
    padding: 20px;
    min-height: 400px;
}

#colorPickerModal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2000;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-reset {
    background: white;
    border: 2px solid #e74c3c;
    position: relative;
}

.color-reset::before,
.color-reset::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #e74c3c;
    top: 50%;
    left: 50%;
}

.color-reset::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.color-reset::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.color-option:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* フィードバック新着バッジ */
.notify-badge {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 6px;
    display: inline-block;
    vertical-align: middle;
}
