/* css/style.css v2.00 */

/* 全体設定 */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* bodyレベルでのスクロールを禁止 */
}

body {
    display: flex;
    flex-direction: column; 
    height: 100dvh; /* viewportの高さに合わせる */
    background-color: #f4f4f4;
}

/* app-container */
#app-container {
    display: flex;
    flex-grow: 1;
    gap: 0;
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* left-panel */
#left-panel {
    width: 40%;
    flex-shrink: 0;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* スクロールは子要素に任せる */
    position: relative;
}

#resizer {
    flex-basis: 5px;
    flex-shrink: 0;
    background-color: #e0e0e0;
    cursor: col-resize;
    transition: background-color: 0.2s;
}
#resizer:hover {
    background-color: #007bff;
}

#left-panel h2 {
    margin-top: 0;
    font-size: 1.1em;
    color: #333;
    padding-bottom: 3px;
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
    flex-shrink: 0;
}

/* ★★★ template-list のスタイルを更新 ★★★ */
#template-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 5px; /* 単位を追記 */
    /* padding-bottom: 5px; */
    border-bottom: 1px dashed #eee;
    overflow-y: auto;
    max-height: 162px;
    flex-shrink: 0;
}

/* canned-text-list */
#canned-text-list {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 100px;
}

#canned-text-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#canned-text-list li {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: grab;
    transition: background-color 0.2s;
    font-size: 1em;
    word-wrap: break-word;
}
#canned-text-list li:focus {
    outline: 2px solid #007bff;
    outline-offset: 1px;
}
#canned-text-list li:hover {
    background-color: #eef;
}

/* main-content */
#main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
    min-width: 300px;
    overflow: hidden;
    position: relative;
}

/* main-editor */
#main-editor {
    width: 100%;
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    line-height: 1.5;
    resize: both;
    box-sizing: border-box;
    overflow: auto;
    min-height: 0;
}

/* controls */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.controls button, .template-button {
    padding: 10px 10px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
    white-space: nowrap;
}

.template-button {
    width: 6.1em;
}

.template-button { background-color: #007bff; }
.template-button:hover { background-color: #0069d9; }
.template-button:nth-of-type(4n+2) { background-color: #364fc7; }
.template-button:nth-of-type(4n+2):hover { background-color: #3046b2; }
.template-button:nth-of-type(4n+3) { background-color: #17a2b8; }
.template-button:nth-of-type(4n+3):hover { background-color: #138496; }
.template-button:nth-of-type(4n+4) { background-color: #4dabf7; }
.template-button:nth-of-type(4n+4):hover { background-color: #2b99f5; }

.template-button.selected-template {
    box-shadow: inset 0 0 0 3px #dc3545;
}

#copy-to-clipboard-btn,
#clear-editor-btn,
#add-to-canned-text-btn,
#save-file-btn,
#send-json-btn {
    background-color: #6c757d; 
    border-bottom: 3px solid #4a4e53;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
}
#copy-to-clipboard-btn:hover,
#clear-editor-btn:hover,
#add-to-canned-text-btn:hover,
#save-file-btn:hover,
#send-json-btn:hover {
    background-color: #5a6268;
}
#copy-to-clipboard-btn:active,
#clear-editor-btn:active,
#add-to-canned-text-btn:active,
#save-file-btn:active,
#send-json-btn:active {
    transform: translateY(2px);
    border-bottom-width: 1px;
    box-shadow: none;
}

/* web-links */
#web-links-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding-bottom: 5px;
}
#web-links-container h2 {
    margin: 0;
    font-size: 1.1em;
    color: #333;
    padding-right: 10px;
    white-space: nowrap;
}
#web-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
#web-links a {
    padding: 5px 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    background-color: #f8f9fa;
    white-space: nowrap;
    box-shadow: 0 2px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}
#web-links a:hover {
    background-color: #e9ecef;
    border-color: #bbb;
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}
#web-links a:active {
    background-color: #dae0e5;
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* footer */
footer {
    width: 100%;
    padding: 10px 20px;
    text-align: center;
    background-color: #eee;
    color: #666;
    font-size: 0.8em;
    box-sizing: border-box;
    flex-shrink: 0;
    border-top: 1px solid #ddd;
    position: sticky;
    bottom: 0;
    z-index: 100;
}
footer a {
    color: inherit;
    text-decoration: none;
}
footer h1 {
    font-size: 10pt;
    margin: 0;
    padding: 0;
    line-height: 1;
}

/* delete-area */
#delete-area {
    display: none;
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 10;
    border: 2px dashed #f56565;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #f56565;
    transition: all 0.2s ease-in-out;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#delete-area.visible {
    display: flex;
}

#delete-area.drag-over {
    background-color: #fef2f2;
    border-style: solid;
    transform: scale(1.05);
}
#delete-area .delete-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

/* setup_link */
#setup_link {
    font-size: 0.8em;
    padding: 3px 8px;
    color: #495057;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    margin-left: auto;
    align-self: center;
    transition: background-color 0.2s;
}
#setup_link:hover {
    background-color: #e9ecef;
    color: #212529;
}

/* Media Queries */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        height: 100%;
    }
    #left-panel {
        display: contents;
    }
    #resizer {
        display: none;
    }

    /* ★★★ スマホ表示のtemplate-listのスタイルを更新 ★★★ */
    #template-list {
        order: 1;
        flex-shrink: 0;
        max-height: 100px;
    }

    #canned-text-list {
        order: 2;
        flex-grow: 1;
        min-height: 0;
    }
    #main-content {
        order: 3;
        flex-shrink: 0;
        width: 100%;
    }
    
    #main-editor {
        flex-grow: 0;
        min-height: 11em;
        /* max-height: 9em; */
        resize: vertical;
    }
    
    #web-links-container, #web-links-container h2 {
       /* display: none;*/
    }
}

@media (max-width: 768px) and (min-height: 800px) {
    #template-list {
        max-height: none;
    }
}

/* ドラッグ中のテキスト選択を無効化 */
body.is-dragging {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ドラッグ＆ドロップ中のスタイル */
li.dragging {
    opacity: 0.5;
    background-color: #cce5ff;
    z-index: 1000;
}

/* プレースホルダーのスタイル */
li.placeholder {
    background-color: #e9ecef;
    border: 2px dashed #6c757d;
}