/* panel.css */

/* =================================================
   1. 側邊面板基礎邏輯 (支援瀏覽與編輯模式切換)
   ================================================= */
#overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    transition: background-color 0.3s ease;
}

#overlay.is-editing {
    pointer-events: auto !important;
    cursor: not-allowed;
    background-color: rgba(0, 0, 0, 0.02);
}

#panelWrapper {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    display: flex;
    align-items: stretch;
    transform: translateX(100%);
    transition: transform 0.4s ease;
    background: #fff;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    cursor: default;
}

#overlay.active #panelWrapper {
    transform: translateX(0);
}

/* 側邊把手按鈕 */
#handleBtn {
    width: 28px;
    height: 64px;
    background: #ffffff;
    border: 1px solid #4A90E2;
    border-right: none;
    cursor: pointer;
    border-radius: 8px 0 0 8px;
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#overlay.active #handleBtn {
    opacity: 1;
    visibility: visible;
}

#overlay.is-editing #handleBtn {
    pointer-events: none !important;
    opacity: 0.5;
    cursor: not-allowed;
}

/* =================================================
   2. 頂部佈局、框框與資訊區
   ================================================= */
#panel {
    width: 550px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    /* 改為彈性佈局 */
    flex-direction: column;
    /* 垂直排列子元素 */
    position: relative;
    background: #ffffff;
    border-left: 1px solid #4A90E2;
}

#panelTop {
    flex: 1;
    /* 【關鍵】讓內容區自動撐開，將按鈕推至底部 */
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 20px;
    padding: 25px;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    /* 當內容超過高度時顯示捲軸 */
}

/* 左側垂直容器：包含圖片框與分析結果 */
#panelLeftSection {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#panelBox {
    width: 180px;
    height: 240px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    border: 2px solid #4A90E2;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 2px 4px 10px rgba(74, 144, 226, 0.1);
}

.boxInsideImg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    box-sizing: border-box;
}

/* 右側資訊區 */
#panelInfo {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
    row-gap: 10px;
}

.idRow {
    grid-column: 1 / -1;
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    padding-bottom: 5px;
}

#panelInfo label {
    color: #4A90E2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-weight: bold;
    font-size: 14px;
}

#panelInfo input {
    width: 100%;
    height: 18px;
    font-size: 14px;
    margin-top: 2px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0 5px;
    transition: all 0.2s;
    background-color: #fff;
}

#panelInfo input:disabled {
    background-color: transparent !important;
    border-color: transparent !important;
    color: #333;
    cursor: default;
    padding-left: 0 !important;
}

#panelInfo input:not(:disabled) {
    border-color: #4A90E2 !important;
    padding-left: 6px !important;
}

/* =================================================
   3. 分析結果顯示區塊
   ================================================= */
#analysisResultArea {
    display: none;
    flex-direction: column;
    gap: 15px;
    padding: 0;
    margin-top: 5px;
    box-sizing: border-box;
}

.analysis-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analysis-label {
    font-size: 13px;
    font-weight: 700;
    color: #4A90E2;
    display: block;
    text-transform: uppercase;
}

/* 分數顯示窗格 */
.score-display-box {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    min-height: 18px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

#analysisScore {
    font-size: 18px;
    font-weight: 900;
    color: #E67E22;
    display: block;
    line-height: 1;
}

#analysisScore2 {
    font-size: 18px;
    font-weight: 900;
    color: #ba55d3;
    display: block;
    line-height: 1;
}

/* 理由顯示窗格 */
.reason-display-box {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    min-height: 120px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

#analysisReason {
    font-size: 14px;
    color: #444;
    line-height: 1.6;
    word-break: break-all;
    white-space: pre-wrap;
}

/* =================================================
   4. 按鈕組樣式 (固定於最下方，無分隔線)
   ================================================= */
.panelButtonGroup {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 15px 25px 25px 25px;
    background: #ffffff;
    flex-shrink: 0;
    /* 【關鍵】確保按鈕區塊不被內容壓縮縮小 */
}

#editPanelBtn,
#saveBtn {
    width: 65px;
    height: 38px;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#editPanelBtn {
    background: #fff;
    border: 1px solid #bbb;
    color: #333;
}

#saveBtn {
    background: #4A90E2;
    color: white;
    border: none;
}

#editPanelBtn:disabled,
#saveBtn:disabled {
    background: #e0e0e0 !important;
    color: #888 !important;
    border: 1px solid #ccc !important;
    cursor: not-allowed;
}