@font-face {
    font-family: en;
    src: url(../client/public/fonts/inconsolata.woff);
}

@font-face {
    font-family: sym;
    src: url(../client/public/fonts/symmingliu.woff);
}

@font-face {
    font-family: huninn;/*    src: url(../font/jf-openhuninn-2.0.ttf);*/
    src: url(../font/huakang.ttc);
}

@font-face {
    font-family: zh;
    src: local("微軟正黑體"), local("Microsoft JhengHei"), local("Lantinghei TC"), local("MingLiU_HKSCS");
}

/* --- 1. 全高設定與邊距歸零 --- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: sans-serif;
    background-color: #e9ecef;
}

/* --- 2. Header 樣式 --- */
header {
    background-color: #343a40;
    color: white;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: 60px;
    box-sizing: border-box;
}

.header-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
}

#current-project-header {
    font-size: 1.1em;
    font-weight: bold;
    margin-right: 20px;
    padding: 5px 10px;
    background-color: #495057;
    border-radius: 4px;
}

.header-controls button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: bold;
}

#new-project-btn {
    background-color: #007bff;
    color: white;
}

#new-project-btn:hover {
    background-color: #0056b3;
}

#save-data {
    background-color: #ffc107;
    color: #333;
}

#save-data:hover {
    background-color: #e0a800;
}

#load-data {
    background-color: #17a2b8;
    color: white;
}

#load-data:hover {
    background-color: #138496;
}

#delete-project-btn {
    background-color: #dc3545;
    color: white;
}

#delete-project-btn:hover {
    background-color: #bd2130;
}

#export-lpc-btn {
    margin-left: 20px;
    background-color: #6f42c1;
    color: white;
}

#export-lpc-btn:hover {
    background-color: #5a3597;
}

#duplicate-project-btn {
    background-color: #fd7e14;
    color: white;
}

#duplicate-project-btn:hover {
    background-color: #cc650c;
}

/* --- 3. 主容器與欄位樣式 --- */
.container {
    display: flex;
    gap: 0;
    height: calc(100vh - 30px - 30px);
    max-width: 100%;
    background-color: #fff;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.column {
    padding: 15px;
    display: flex;
    flex-direction: column;
}

/* 左欄: Spritesheet 影格/圖層控制 */
.left-column {
    flex: 0 0 250px;
    background-color: #f8f9fa;
    gap: 10px;
    margin-right: 20px;
    overflow: hidden;
    padding-right: 5px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* 摺疊標題樣式 */
.collapsible-header {
    cursor: pointer;
    padding: 10px 0;
    margin-top: 5px;
    margin-bottom: 5px;
    border-bottom: 2px solid #ccc;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-header:hover {
    background-color: #e9ecef;
}

.collapsible-header h3 {
    margin: 0;
    padding: 0;
    font-size: 1.1em;
    display: flex;
    align-items: center;
}

.toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
}

.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.header-dynamic-text {
    font-weight: normal;
    font-size: 0.9em;
    margin-left: 8px;
    color: #6c757d;
}

/* 摺疊內容容器 */
.collapsible-content {
    overflow-x: hidden;
    overflow-y: auto;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    max-height: 50px;
    padding: 0 0 10px 0;
    box-sizing: border-box;
}

.collapsed .collapsible-content {
    max-height: 0 !important;
    padding: 0;
    overflow: hidden;
}

/* 圖層控制區塊 */
#layer-ui-wrapper, #frame-ui-wrapper {
    border: 1px solid #d4d4d4;
    padding: 0 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#frame-ui-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#layer-ui-wrapper.collapsed, #frame-ui-wrapper.collapsed {
    border-color: transparent;
    border-bottom: 1px solid #d4d4d4;
}

#frame-content-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}

#button-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
}

.controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ccc;
    margin-bottom: 10px;
    flex-shrink: 0;
}

/* 圖層/影格控制按鈕 */
#add-sprite, #add-layer {
    background-color: #28a745;
    color: white;
}

#add-sprite:hover, #add-layer:hover {
    background-color: #1e7e34;
}

.controls-row {
    display: flex;
    gap: 5px;
}

#remove-sprite, #remove-layer {
    background-color: #dc3545;
    color: white;
    flex-grow: 1;
}

#remove-sprite:hover, #remove-layer:hover {
    background-color: #bd2130;
}

#layer-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
    margin-bottom: 10px;
    max-height: none;
}

/* Sprite 按鈕基礎樣式 (適用於 Layer和 Frame) */
.sprite-button {
    padding: 5px 10px;
    border: 1px solid #007bff;
    background-color: #fff;
    color: #007bff;
    cursor: grab;
    border-radius: 4px;
    text-align: left;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
    display: flex;
    flex-direction: column;
    outline: none;
    margin-bottom: 15px;
}

.sprite-button:last-child {
    margin-bottom: 0;
}

.sprite-button:hover, .sprite-button:focus {
    background-color: #007bff;
    color: #fff;
    outline: 1px solid #007bff;
}

.sprite-button.active {
    background-color: #28a745;
    color: #fff;
    border-color: #28a745;
}

.sprite-button.active .sprite-preview {
    background-color: #1e7e34;
}

.sprite-button.active .sprite-preview-content {
    color: #ffffff;
}

/* 拖曳時的樣式 */
.sprite-button.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.drag-over-top, .drag-over-bottom {
    border: 1px solid #007bff;
}

.drag-over-top {
    border-top: 3px solid #ffc107;
}

.drag-over-bottom {
    border-bottom: 3px solid #ffc107;
}

/* 縮放預覽容器 */
.sprite-preview {
    margin-top: 5px;
    padding: 3px;
    line-height: 1;
    background-color: #111111;
    color: #333;
    border-radius: 2px;
    width: 95%;
    height: 84px;
    overflow: hidden;
    position: relative;
}

/* 實際縮放的內容 */
.sprite-preview-content {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    font-size: 12px;
    white-space: pre;
    transform-origin: top left;            /* 移除預覽內容的固定顏色，讓它能繼承父級顏色或圖層顏色 */
    color: inherit;
    font-family: en, sym, huninn, zh !important;
}

.sprite-button:hover .sprite-preview {
    background-color: #0056b3;
    color: #fff;
}

.sprite-button:hover .sprite-preview-content {
    color: #fff;
}

/* 中欄: 編輯器 */
.center-column {
    flex: 1;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    margin-right: 15px;
    position: relative;
}

/* 圖層顏色設定區塊 (新位置在中欄) */
#color-settings {
    margin-top: 0;
    padding: 10px;
    background-color: #e9ecef;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
}

#color-settings label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.color-block {
    width: 25px;
    height: 25px;
    border-radius: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.color-block.selected {
    border-color: #ffc107;
    border-width: 5px;
    margin-top: -5px;
}

#textarea {
    width: 100%;
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    resize: none;
    font-size: 1.2em;
    font-family: en, sym, huninn, zh !important;
    line-height: 1;
}

#textarea:disabled {
    color: #cccccc;
}

#textarea::placeholder {
    color: #cccccc;
}

/* 影格延遲設定區塊 */
#frame-delay-setting {
    padding: 10px;
    background-color: #e9ecef;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 15px;
}

#frame-delay-setting label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#frame-delay-input {
    width: 100px;
    padding: 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.editor-info {
    display: none;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #6c757d;
}

#current-index-display-label {
    display: block;
    margin-top: 5px;
}

/* 預覽寬度調整器 (Resizer) 樣式 */
#resizer {
    width: 5px;
    cursor: ew-resize;
    background-color: #adb5bd;
    position: absolute;
    right: -15px;
    top: 0;
    height: 100%;
    z-index: 10;
}

/* 右欄: 預覽區 */
.right-column {
    background-color: #f8f9fa;
    color: #000; /* 整體背景顏色 */
    display: flex;
    flex-direction: column;
    text-align: left;
    min-width: 130px;
    box-sizing: border-box;
    width: 380px;
    flex-shrink: 0;
}

.right-column > h3, .right-column .setting-group {
    padding-left: 15px;
    padding-right: 15px;
}

/* 參數輸入區塊 */
.setting-group {
    margin-bottom: 15px;
    text-align: left;
    padding: 10px;
    background-color: #e9ecef;
    border: #ccc;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setting-group label {
    display: block;
    font-size: 0.9em;
    color: #000000;
    font-weight: bold;
}

.setting-group input[type="number"] {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Checkbox 樣式 */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* 預覽文字區塊 */
#preview {
    flex-grow: 1;
    font-size: 1.5em;
    display: block;
    overflow: hidden;
    background-color: #111111;
    padding: 10px;
    border-radius: 4px;
    box-sizing: border-box;
    line-height: 1;
    color: #ffffff;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    font-family: en, sym, huninn, zh !important;
}

#preview > span {
    display: inline-block;
    white-space: pre;
}

#preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    height: 100%;
    width: 100%;
}

.preview-line {
    line-height: 1;
    margin: 0;
    padding: 0;
    white-space: pre;
}

.column > h3 {
    margin-top: 0;
    border-bottom: 2px solid #ccc;
    padding-bottom: 5px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

#viewport-width-setting {
    display: none; /*隱藏 */
}

#selected-layer-color-display {
    display: none; /*隱藏 */
}

.layer-button {
    display: inline;
}

#static-frame-checkbox:disabled+span {
    color: #aaaaaa;
}

/* --- 載入專案 Modal Panel --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-panel {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 350px;
    max-width: 500px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
    background-color: #343a40;
    color: white;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2em;
}

.modal-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #ff6b6b;
}

.modal-body {
    padding: 15px 20px;
    overflow-y: auto;
    flex: 1;
}

.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-item-btn {
    display: block;
    width: 100%;
    padding: 12px 15px;
    text-align: left;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.project-item-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
    transform: translateX(5px);
}

.project-item-btn:active {
    background-color: #dee2e6;
}

.project-empty {
    text-align: center;
    color: #6c757d;
    padding: 30px;
    font-style: italic;
}

/* --- 新建專案 Panel 樣式 --- */
.modal-panel-small {
    min-width: 300px;
    max-width: 400px;
}

.modal-header-new {
    background-color: #fd7e14;
}

.new-warning {
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
}

.new-warning p {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.new-warning-detail {
    margin-top: 10px !important;
    font-size: 13px !important;
    font-weight: normal !important;
    color: #6c757d !important;
}

.new-button-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.new-cancel-btn {
    padding: 10px 25px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.new-cancel-btn:hover {
    background-color: #5a6268;
}

.new-confirm-btn {
    padding: 10px 25px;
    background-color: #fd7e14;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.new-confirm-btn:hover {
    background-color: #e96b02;
}

/* --- 複製專案 Panel 樣式 --- */
.modal-header-duplicate {
    background-color: #17a2b8;
}

.duplicate-info {
    color: #495057;
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #e7f5ff;
    border: 1px solid #b6d4fe;
    border-radius: 4px;
}

.duplicate-info span {
    font-weight: bold;
    color: #17a2b8;
}

.duplicate-confirm-btn {
    padding: 10px 20px;
    background-color: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.duplicate-confirm-btn:hover {
    background-color: #138496;
}

/* --- 儲存專案 Panel 樣式 --- */
.modal-header-save {
    background-color: #28a745;
}

.save-input-group {
    margin-bottom: 20px;
}

.save-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.save-input-row {
    display: flex;
    gap: 10px;
}

.save-input-row input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

.save-input-row input:focus {
    outline: none;
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}

.save-confirm-btn {
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.save-confirm-btn:hover {
    background-color: #218838;
}

.save-section-label {
    color: #6c757d;
    font-size: 13px;
    margin-bottom: 10px;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

.project-item-btn-save {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background-color: #f0fff4;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    color: #333;
}

.project-item-btn-save:hover {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
    transform: translateX(5px);
}

/* --- 刪除專案 Panel 樣式 --- */
.modal-header-danger {
    background-color: #dc3545;
}

.delete-warning {
    color: #dc3545;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #fff3f3;
    border: 1px solid #ffcccc;
    border-radius: 4px;
}

.project-item-btn-danger {
    display: block;
    width: 100%;
    padding: 12px 15px;
    text-align: left;
    background-color: #fff5f5;
    border: 1px solid #ffcccc;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    color: #333;
}

.project-item-btn-danger:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
    transform: translateX(5px);
}

.project-item-btn-danger:active {
    background-color: #c82333;
}
