/* 基本重設 */
body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f9;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 30px auto;
    padding: 20px;
}

/* 標題與段落 */
header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    color: #007bff;
    margin-bottom: 5px;
}

h2 {
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 0;
    font-size: 1.5em;
}

h3 {
    margin-top: 0;
    color: #555;
    font-size: 1.1em;
}

p.subtitle {
    color: #6c757d;
}

/* 卡片容器 */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 20px;
    margin-bottom: 25px;
}

/* 輸入與選擇元件 */
input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

textarea {
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace; /* 代碼字體 */
}

/* 按鈕樣式 */
button {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-size: 1em;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}
.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}
.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}
.btn-danger:hover {
    background-color: #c82333;
}

.full-width {
    width: 100%;
    margin-top: 10px;
}

/* 佈局幫助類 */
.api-key-group {
    display: flex;
    gap: 10px;
    align-items: center;
}
.api-key-group input {
    margin-bottom: 0;
}

.header-with-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-with-button h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.control-grid {
    display: grid;
    /* 這裡原本是 1fr 1fr 1fr 1fr，現在只有兩個控制項是並排 */
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.control-item {
    display: flex;
    flex-direction: column;
}
.control-item label {
    font-weight: bold;
    margin-bottom: 5px;
}
.control-item.full-row {
    grid-column: span 2;
}


/* 貼圖與預覽 */
.paste-area {
    border: 2px dashed #007bff;
    padding: 15px;
    text-align: center;
    margin-top: 10px;
    min-height: 50px;
    cursor: pointer;
    background: #e9f5ff;
    outline: none;
    border-radius: 4px;
    color: #007bff;
    font-style: italic;
    transition: background 0.2s;
}
.paste-area:focus {
    background: #d4e8ff;
}

.image-preview {
    max-width: 100%;
    max-height: 200px;
    margin-top: 10px;
    display: none;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* 輸出區塊 */
.output-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.output-box {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    min-height: 200px;
    overflow-x: auto;
    background: #fff;
    font-size: 0.95em;
}

.output-rendered {
    background: #f9f9f9;
}

.output-raw {
    background: #333;
    color: #fff;
}
.output-raw pre {
    margin: 0;
    white-space: pre-wrap; /* 允許換行 */
    font-family: 'Consolas', 'Monaco', monospace;
}

/* 狀態訊息 */
.status-message {
    padding: 5px 0;
    font-size: 0.9em;
    color: #6c757d;
}

.warning-text {
    color: #856404;
    font-style: italic;
    background: #fff3cd;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ffeeba;
    font-size: 0.9em;
}

.format-tip {
    color: #dc3545; /* 警告色 */
    font-weight: bold;
    margin-top: 10px;
}


/* 歷史記錄 */
.history-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px; /* 留出滾動條空間 */
}

.history-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9em;
}
.history-item:hover {
    background: #f0f0f0;
}
.history-item span {
    color: #007bff;
    font-weight: bold;
    margin-right: 5px;
}

/* =============================================== */
/* 自訂提示框 (Modal) 樣式 */
/* =============================================== */

.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-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px; 
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(1);
    transition: transform 0.2s ease-in-out;
}

.modal-content p {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
    word-wrap: break-word; 
}

/* 提示框中的按鈕 */
.modal-content .btn-primary {
    width: 100px;
    padding: 10px;
}


/* RWD 調整 */
@media (max-width: 768px) {
    .output-container,
    .control-grid {
        grid-template-columns: 1fr;
    }
    .header-with-button {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-with-button div {
        margin-top: 10px;
    }
    .api-key-group {
        flex-direction: column;
        align-items: stretch;
    }
    .api-key-group label {
        margin-right: 0;
        margin-bottom: 5px;
    }
}