/**
 * 備忘錄浮動 Widget 樣式
 * 20260213 renhao add 優化項目 #1
 */

/* ========== FAB 浮動按鈕 ========== */
#memo-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary, #417690);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    transition: background .2s, transform .15s;
}
#memo-fab:hover {
    background: #205067;
    transform: scale(1.08);
}

/* Badge */
#memo-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #c4170c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    padding: 0 5px;
}

/* ========== Panel ========== */
#memo-panel {
    position: fixed;
    bottom: 84px;
    right: 24px;
    width: 580px;
    max-height: 75vh;
    background: var(--body-bg, #fff);
    border: 1px solid var(--hairline-color, #ddd);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.memo-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline-color, #ddd);
    background: var(--darkened-bg, #f8f8f8);
}
.memo-panel-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--body-fg, #333);
}
.memo-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
a.memo-admin-link,
a.memo-admin-link:link,
a.memo-admin-link:visited {
    font-size: 12px;
    color: var(--body-quiet-color, #999);
    text-decoration: none;
}
a.memo-admin-link:hover {
    color: var(--body-fg, #333);
}
#memo-panel-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--body-quiet-color, #999);
    padding: 0 4px;
    line-height: 1;
}
#memo-panel-close:hover {
    color: var(--body-fg, #333);
}

/* ========== 新增表單區 ========== */
.memo-form-section {
    padding: 12px 16px;
}
.memo-form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.memo-form-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 13px;
    background: var(--body-bg, #fff);
    color: var(--body-fg, #333);
}
.memo-form-section textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
    margin-bottom: 8px;
    background: var(--body-bg, #fff);
    color: var(--body-fg, #333);
    box-sizing: border-box;
}
.memo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--body-fg, #333);
    cursor: pointer;
    margin-bottom: 8px;
}
.memo-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
#memo-submit-btn {
    width: 100%;
    padding: 8px;
    background: #1b4d6e;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background .2s;
}
#memo-submit-btn:hover {
    background: #0e3349;
}
#memo-submit-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ========== 分隔線 ========== */
.memo-divider {
    border: none;
    border-top: 1px solid var(--hairline-color, #ddd);
    margin: 0;
}

/* ========== 列表區 ========== */
.memo-list-section {
    overflow-y: auto;
    max-height: 40vh;
    padding: 0;
}
#memo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
#memo-table thead th {
    position: sticky;
    top: 0;
    background: var(--darkened-bg, #f8f8f8);
    padding: 8px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--hairline-color, #ddd);
    color: var(--body-quiet-color, #666);
    white-space: nowrap;
}
#memo-table tbody td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--hairline-color, #eee);
    vertical-align: top;
    color: var(--body-fg, #333);
}
#memo-table tbody tr:hover {
    background: var(--darkened-bg, #f5f5f5);
}
#memo-table tbody tr.memo-pending {
    background: rgba(255, 200, 50, 0.06);
}
.memo-time-cell {
    font-size: 11px;
    line-height: 1.4;
    white-space: nowrap;
    color: var(--body-quiet-color, #666);
}

.memo-content-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 操作按鈕 */
.memo-action-btn {
    padding: 3px 10px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    line-height: 1.6;
    transition: background .15s;
    box-sizing: border-box;  /* 20260708 renhao add 讓外框 1px 不額外佔寬 */
    min-width: 52px;         /* 建單/檢視 同寬，避免狀態切換時按鈕寬度跳動 */
    text-align: center;
}
a.memo-btn-convert,
a.memo-btn-convert:link,
a.memo-btn-convert:visited {
    background: #1b4d6e;
    color: #fff;
}
a.memo-btn-convert:hover {
    background: #0e3349;
    color: #fff;
}
a.memo-btn-view,
a.memo-btn-view:link,
a.memo-btn-view:visited {
    background: transparent;
    color: #1b4d6e;
    border: 1px solid #1b4d6e;
}
a.memo-btn-view:hover {
    background: #1b4d6e;
    color: #fff;
}

/* 空狀態 */
.memo-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--body-quiet-color, #999);
    font-size: 13px;
}

/* ========== 響應式 ========== */
@media (max-width: 640px) {
    #memo-panel {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 78px;
        max-height: 80vh;
    }
    .memo-form-row {
        flex-direction: column;
    }
}
