/* 全局樣式 */
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f0f4f8, #d9e7f3);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* 導航欄樣式 */
nav {
    background-color: #004a99;
    color: white;
    padding: 10px 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap; /* 允許換行 */
}

nav ul li a,
nav ul li button {
    text-decoration: none;
    color: white;
    font-size: 1rem;
    padding: 8px 15px;
    border-radius: 5px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

nav ul li a:hover,
nav ul li button:hover {
    background-color: #0056b3;
}

/* 頁眉樣式 */
header {
    text-align: center;
    padding: 20px 0;
    background-color: #0056b3;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header img {
    max-width: 100%;
    height: auto;
    max-height: 80px;
    margin-bottom: 10px;
}

header h1 {
    font-size: 2.5rem;
    margin: 0;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
}

/* 主內容區樣式 */
main {
    width: 90%;
    max-width: 800px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
    margin: 20px auto;
    word-wrap: break-word; /* 防止文字超出邊界 */
    overflow-wrap: break-word;
}

/* 分區標題樣式 */
h2 {
    font-size: 1.5rem;
    color: #333;
    border-bottom: 2px solid #ddd;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

/* 表單樣式 */
form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

textarea,
input,
select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    resize: none;
}

button {
    font-size: 1.1rem;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    background-color: #007BFF;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background-color: #0056b3;
    transform: scale(1.05);
}

/* 次要按鈕樣式 */
.secondary-button {
    margin-top: 20px;
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-button:hover {
    background-color: #218838;
    transform: scale(1.05);
}

/* 分區樣式 */
.options-group,
.text-overlay-group,
.button-group {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* 圖片結果區樣式 */
#output {
    margin-top: 30px;
    text-align: center;
    position: relative;
}

img {
    max-width: 100%;
    height: auto;
    margin-top: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#downloadButton {
    display: none;
    font-size: 1.2rem;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#downloadButton:hover {
    background-color: #218838;
}

/* 錯誤訊息樣式 */
#errorMessage {
    display: none;
    color: #d9534f;
    text-align: center;
    font-weight: bold;
    margin-top: 15px;
}

/* 頁腳樣式 */
footer {
    margin-top: auto;
    text-align: center;
    font-size: 0.9rem;
    color: #555;
    padding: 15px;
    background: #f8f9fa;
    width: 100%;
    border-top: 2px solid #ddd;
}

footer a {
    color: #007BFF;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

/* 響應式設計 */
@media (max-width: 768px) {
    nav ul {
        flex-direction: column;
    }

    nav ul li {
        margin-bottom: 10px;
    }

    header h1 {
        font-size: 2.2rem;
    }

    header img {
        max-height: 60px;
    }

    main {
        padding: 15px;
    }

    textarea,
    input,
    select {
        padding: 10px;
        font-size: 0.9rem;
    }

    button {
        font-size: 1rem;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }

    header img {
        max-height: 50px;
    }

    main {
        padding: 10px;
    }

    textarea,
    input,
    select {
        padding: 8px;
        font-size: 0.85rem;
    }

    button {
        font-size: 0.9rem;
        padding: 8px 15px;
    }
}
