/* ========================================
   シンプルブロックエディタ CSS - Notion風デザイン
   ======================================== */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background-color: #ffffff;
    color: #37352f;
    overflow: hidden;
}

/* Editor Wrapper */
#editor-wrapper {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Top Bar - Notion風
   ======================================== */
#top-bar {
    background: #ffffff;
    border-bottom: 1px solid #e9e9e7;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-title {
    font-size: 14px;
    font-weight: 600;
    color: #37352f;
    margin-left: 4px;
}

/* Device Buttons - Notion風 */
.device-buttons {
    display: flex;
    gap: 2px;
    background: transparent;
    padding: 0;
}

.device-btn {
    background: transparent;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    color: #9b9a97;
    transition: all 0.15s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.device-btn:hover {
    background: rgba(55, 53, 47, 0.08);
    color: #37352f;
}

.device-btn.active {
    background: rgba(35, 131, 226, 0.1);
    color: #2383e2;
}

/* Action Buttons - Notion風 */
.action-btn {
    background: transparent;
    border: 1px solid #e9e9e7;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #37352f;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease-out;
}

.action-btn:hover {
    background: rgba(55, 53, 47, 0.08);
}

.action-btn.primary {
    background: #2383e2;
    border-color: #2383e2;
    color: #ffffff;
}

.action-btn.primary:hover {
    background: #1a6ec7;
    border-color: #1a6ec7;
}

.action-btn svg {
    flex-shrink: 0;
}

/* ========================================
   GrapesJS Editor - Notion風
   ======================================== */
#gjs {
    flex: 1;
    position: relative;
}

/* サイドバー - Notion風 */
.gjs-pn-panel {
    background: #f7f6f3 !important;
}

.gjs-pn-views-container {
    background: #f7f6f3 !important;
    border-right: 1px solid #e9e9e7;
    width: 260px !important;
    min-width: 260px !important;
    transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

/* 右側のパネル幅を調整 */
.gjs-pn-commands,
.gjs-pn-options {
    width: 240px !important;
    min-width: 240px !important;
}

.gjs-pn-options {
    right: calc(var(--gjs-left-width) + 100px) !important;
}

.gjs-pn-views-container.sidebar-hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* サイドバーが閉じている時、アイコンも非表示 */
.sidebar-hidden .gjs-pn-views {
    display: none !important;
}

.sidebar-hidden .gjs-pn-btn {
    display: none !important;
}

.gjs-pn-views {
    border-bottom: 1px solid #e9e9e7;
}

.gjs-pn-btn {
    color: #37352f !important;
    transition: all 0.15s ease-out;
    font-size: 14px !important;
    padding: 8px 12px !important;
    font-weight: 500 !important;
}

.gjs-pn-btn:hover {
    background: rgba(55, 53, 47, 0.08) !important;
}

.gjs-pn-btn.gjs-pn-active {
    color: #2383e2 !important;
    background: rgba(35, 131, 226, 0.1) !important;
}

/* Block Manager - Notion風 */
.gjs-blocks-c {
    background: #f7f6f3 !important;
    padding: 12px !important;
}

.gjs-block {
    background: #ffffff !important;
    border: 1px solid #e9e9e7 !important;
    border-radius: 4px !important;
    color: #37352f !important;
    transition: all 0.15s ease-out;
    padding: 10px !important;
    margin-bottom: 8px !important;
    word-wrap: break-word !important;
    overflow: hidden !important;
}

.gjs-block:hover {
    background: #ffffff !important;
    border-color: #d3d3d1 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
}

.gjs-block-label {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
}

/* Canvas - Notion風 */
.gjs-cv-canvas {
    background: #ffffff !important;
    transition: all 0.2s ease-out;
    width: calc(100% - 260px) !important;
}

/* サイドバーが閉じている時、全幅に */
#gjs.canvas-full-width .gjs-cv-canvas {
    width: 100% !important;
}

.gjs-frame {
    border: 1px solid #e9e9e7 !important;
    border-radius: 3px !important;
    margin: 8px;
    background: #ffffff !important;
    width: calc(100% - 20px) !important;
}

/* Style Manager - Notion風 */
.gjs-sm-sector {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #e9e9e7 !important;
    margin-bottom: 0 !important;
    padding: 16px 12px !important;
}

.gjs-sm-sector .gjs-sm-title {
    background: transparent !important;
    color: #1a1a1a !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    padding: 0 0 12px 0 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    border-bottom: none !important;
}

.gjs-sm-properties {
    background: transparent !important;
    padding: 0 !important;
}

.gjs-sm-property {
    background: transparent !important;
    color: #37352f !important;
    padding: 8px 0 !important;
    margin-bottom: 0 !important;
    border-bottom: none !important;
}

.gjs-sm-label {
    color: #5a5a5a !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    margin-bottom: 6px !important;
    display: block !important;
}

/* Input Fields - Notion風 */
.gjs-field,
.gjs-field-integer,
.gjs-field-select,
.gjs-field-color,
.gjs-field-slider {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

.gjs-field input,
.gjs-field select,
.gjs-field-integer input,
.gjs-field-select select,
.gjs-field-color input,
input[type="text"],
input[type="number"],
select {
    background: #ffffff !important;
    border: 1px solid #e9e9e7 !important;
    border-radius: 3px !important;
    color: #37352f !important;
    padding: 6px 8px !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    width: 100% !important;
    transition: all 0.15s ease-out;
}

.gjs-field input:hover,
.gjs-field select:hover,
.gjs-field-integer input:hover,
.gjs-field-select select:hover,
input[type="text"]:hover,
input[type="number"]:hover,
select:hover {
    border-color: #d3d3d1 !important;
    background: #ffffff !important;
}

.gjs-field input:focus,
.gjs-field select:focus,
.gjs-field-integer input:focus,
.gjs-field-select select:focus,
.gjs-field-color input:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: #2383e2 !important;
    outline: none !important;
    box-shadow: 0 0 0 1px #2383e2 !important;
    background: #ffffff !important;
}

select {
    background-color: #ffffff !important;
    cursor: pointer !important;
}

.gjs-input-holder {
    background: transparent !important;
}

/* Right Panel - Notion風 */
.gjs-pn-views,
.gjs-pn-panel.gjs-pn-views-container,
.gjs-pn-panel.gjs-pn-commands,
.gjs-pn-panel.gjs-pn-options,
#gjs-pn-views,
#gjs-pn-options,
#gjs-pn-commands {
    background: #f7f6f3 !important;
}

.gjs-sm-clear,
.gjs-sm-composite,
.gjs-clm-tags {
    background: transparent !important;
    color: #37352f !important;
}

/* 右側パネル全体の背景を強制的に適用 */
.gjs-two-color,
.gjs-one-bg,
.gjs-two-color .gjs-layer-vis,
.gjs-sm-sector-title,
.gjs-sm-properties,
.gjs-clm-tags,
.gjs-blocks-c,
div[class*="gjs-sm"],
div[class*="gjs-pn"],
.gjs-pn-options,
.gjs-pn-commands,
#gjs-pn-options,
#gjs-pn-commands,
.gjs-sm-sectors,
.gjs-trt-traits,
.gjs-layers,
.gjs-pn-panel:not(.gjs-pn-commands):not(.gjs-pn-options) {
    background: #f7f6f3 !important;
    color: #000000;
}

.gjs-sm-sector-title {
    padding-left: 5px !important;
}

/* GrapesJSのデフォルトの灰色背景を完全に上書き */
#gjs .gjs-pn-panel,
#gjs .gjs-one-bg,
#gjs .gjs-two-color {
    background-color: #f7f6f3 !important;
    background: #f7f6f3 !important;
}

/* Layer Manager - Notion風 */
.gjs-layer {
    background: transparent !important;
    color: #1a1a1a !important;
    border-radius: 3px !important;
    margin: 2px 0 !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
    transition: all 0.15s ease-out;
    font-weight: 500 !important;
}

.gjs-layer.gjs-selected {
    background: rgba(35, 131, 226, 0.1) !important;
    color: #2383e2 !important;
}

.gjs-layer:hover {
    background: rgba(55, 53, 47, 0.08) !important;
}

/* Toolbar - Notion風 */
.gjs-toolbar {
    background: #ffffff !important;
    border: 1px solid #e9e9e7 !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.gjs-toolbar-item {
    color: #37352f !important;
    transition: all 0.15s ease-out;
}

.gjs-toolbar-item:hover {
    color: #2383e2 !important;
    background: rgba(55, 53, 47, 0.08) !important;
}

/* Traits Panel - Notion風 */
.gjs-trt-trait {
    background: transparent !important;
    color: #37352f !important;
    padding: 8px 0 !important;
}

.gjs-trt-trait__label {
    color: #5a5a5a !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

/* Category Title - Notion風 */
.gjs-block-category .gjs-title {
    background: transparent !important;
    color: #1a1a1a !important;
    border-bottom: none !important;
    border-left: none !important;
    font-weight: 700 !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    transition: all 0.15s ease-out;
    margin-bottom: 4px !important;
    border-radius: 0 !important;
}

.gjs-block-category .gjs-title:hover {
    color: #000000 !important;
}

.gjs-block-category.gjs-open {
    border-bottom: none !important;
}

.gjs-block-category.gjs-open .gjs-title {
    color: #000000 !important;
}

/* Textarea - Notion風 */
textarea {
    background: #ffffff !important;
    border: 1px solid #e9e9e7 !important;
    color: #37352f !important;
    border-radius: 3px !important;
    padding: 8px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    transition: all 0.15s ease-out;
}

textarea:focus {
    border-color: #2383e2 !important;
    outline: none !important;
    box-shadow: 0 0 0 1px #2383e2 !important;
    background: #ffffff !important;
}

/* Icons */
.gjs-pn-btn svg,
.gjs-toolbar-item svg,
.gjs-block svg {
    fill: currentColor !important;
}

/* ========================================
   Modal - Notion風
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 15, 15, 0.6);
    animation: fadeIn 0.15s ease-out;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 4px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    animation: slideUp 0.15s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e9e9e7;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #37352f;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #9b9a97;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.15s ease-out;
}

.modal-close:hover {
    background: rgba(55, 53, 47, 0.08);
    color: #37352f;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

#export-code {
    width: 100%;
    min-height: 400px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #e9e9e7;
    border-radius: 3px;
    background: #f7f6f3;
    color: #37352f;
    resize: vertical;
    margin-bottom: 16px;
}

.full-width {
    width: 100%;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    #top-bar {
        flex-wrap: wrap;
        padding: 10px;
    }

    .top-bar-left,
    .top-bar-center,
    .top-bar-right {
        gap: 6px;
    }

    .editor-title {
        font-size: 14px;
    }

    .action-btn {
        padding: 5px 10px;
        font-size: 13px;
    }

    .device-btn {
        padding: 5px 8px;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .gjs-pn-views-container {
        width: 240px !important;
        min-width: 240px !important;
    }
}

/* ========================================
   Custom Component Styles
   ======================================== */
.gjs-dashed *[data-gjs-type="wrapper"] {
    min-height: 100px !important;
}

/* スクロールバー - Notion風 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(55, 53, 47, 0.16);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(55, 53, 47, 0.24);
}

.gjs-clm-tags {
    padding: 10px !important;
}

.gjs-sm-composite {
    border: none !important;
}

.gjs-traits-cs {
    padding: 10px !important;
}

.gjs-device-label {
    white-space: nowrap;
}