/* style.css */

body {
    font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    margin: 0;
    padding: 0;
    display: flex;
    color: #31333f;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 左側邊欄 */
.st-sidebar {
    width: 320px;
    background-color: #f0f2f6; 
    padding: 60px 20px 20px 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e6e9ef;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #31333f;
    margin-bottom: 15px;
    border-bottom: 1px solid #d6d6d6;
    padding-bottom: 8px;
}

/* 右側主內容區 */
.st-main {
    flex: 1;
    margin-left: 320px; 
    padding: 60px 40px;
    box-sizing: border-box;
    transition: margin-left 0.3s ease;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1280px;
    position: relative;
}

/* Streamlit 紅線 */
.container::before {
    content: "";
    position: absolute;
    top: -30px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff4b4b 0%, #ff7e7e 100%);
    border-radius: 2px;
}

/* 側邊欄開關 */
.st-sidebar-toggle {
    position: fixed;
    top: 15px;
    left: 15px;
    background: #ffffff;
    color: #31333f;
    border: 1px solid #d6d6d6;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 16px;
    cursor: pointer;
    z-index: 110;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.st-sidebar-toggle:hover {
    border-color: #ff4b4b;
    color: #ff4b4b;
}

.st-sidebar-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: #7d808e;
    font-size: 16px;
    cursor: pointer;
}
.st-sidebar-close:hover {
    color: #ff4b4b;
}

body.sidebar-collapsed .st-sidebar {
    transform: translateX(-320px);
}
body.sidebar-collapsed .st-main {
    margin-left: 0;
}

.form-group {
    margin-bottom: 24px;
}
.section-label {
    font-size: 14px;
    font-weight: 600;
    color: #31333f;
    margin-bottom: 10px;
    display: block;
}

/* 下拉選單 */
.st-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: #31333f;
    background-color: #ffffff;
    border: 1px solid #d6d6d6;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.2s;
}
.st-select:focus, .st-select:hover {
    border-color: #ff4b4b;
}

/* Radio 按鈕 */
.st-radio-group {
    display: flex;
    flex-direction: row;
    gap: 24px;
}
.st-radio-label {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #31333f;
    cursor: pointer;
}
.st-radio-input {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #d6d6d6;
    border-radius: 50%;
    margin-right: 8px;
    outline: none;
    background-color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.st-radio-input:checked {
    border-color: #ff4b4b;
}
.st-radio-input:checked::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ff4b4b;
}

#imageInput {
    display: none;
}

/* Browse 次要按鈕樣式 */
.upload-btn {
    display: inline-block;
    width: auto;
    background-color: #ffffff;
    color: #31333f;
    text-align: center;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid #d6d6d6;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.2s;
    text-decoration: none;
}
.upload-btn:hover {
    border-color: #ff4b4b;
    color: #ff4b4b;
}

/* Streamlit 紅色主要按鈕 */
.st-submit-btn {
    display: inline-flex;  /* 🌟 改為 inline-flex，確保按鈕內的圈圈跟文字能橫向完美並排 */
    align-items: center;  /* 🌟 垂直居中對齊 */
    justify-content: center;
    gap: 10px;            /* 🌟 圈圈與文字之間的精緻間距 */
    width: auto;
    background-color: #ff4b4b;
    color: white;
    text-align: center;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid #ff4b4b;
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.2s ease;
    margin-top: 10px;
}
.st-submit-btn:hover {
    background-color: #e03e3e;
    border-color: #e03e3e;
}
/* 當按鈕被禁用（正在生成中）時的灰色防重複點擊樣式 */
.st-submit-btn:disabled {
    background-color: #eff1f5;
    border-color: #d6d6d6;
    color: #31333f; /* 🌟 讓字體顏色稍微明顯一點，方便閱讀 Running... */
    cursor: not-allowed;
}

/* 圖片預覽 */
.upload-section {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}
#previewContainer {
    display: none;
}
#previewImage {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #d6d6d6;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px;
}

/* 故事輸出區 */
#resultContainer {
    margin-top: 30px;
    padding: 25px;
    background-color: #f0f2f6; 
    border-radius: 6px;
    display: none;
    line-height: 1.75;
    color: #11141c;
    font-size: 16px;
    white-space: pre-wrap;
    border: 1px solid #e6e9ef;
}

/* 底部按鈕群組 */
.st-action-group {
    margin-top: 20px;
    display: none; 
    gap: 15px;
    align-items: center;
}

/* 載入中文字區（保持隱藏，功能已移入按鈕） */
.loading {
    margin-top: 25px;
    display: none; 
}

/* 🌟 【全新美化】：Streamlit 經典招牌紅橘色旋轉小圓圈 */
.spinner-circle {
    width: 14px;
    height: 14px;
    border: 2px solid #d6d6d6;     /* 底部軌道灰色 */
    border-top: 2px solid #ff4b4b; /* 旋轉點為 Streamlit 招牌紅 */
    border-radius: 50%;
    animation: stSpin 0.6s linear infinite; /* 無限流暢高速旋轉 */
    display: inline-block;
}

/* 旋轉動畫定義 */
@keyframes stSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .st-sidebar {
        transform: translateX(-320px);
    }
    .st-main {
        margin-left: 0;
        padding: 60px 20px;
    }
    body.sidebar-open .st-sidebar {
        transform: translateX(0);
    }
}
