/* 狗狗 FB 貼文 AI 產生器 — 樣式 */

* { box-sizing: border-box; }

a { text-decoration: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* ===== 登入頁 ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #ffd89b 0%, #ff9a8b 100%);
}

.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 {
    margin: 0 0 8px;
    font-size: 22px;
}

.login-hint {
    margin: 0 0 24px;
    color: #888;
    font-size: 14px;
}

.login-error {
    background: #fff0f0;
    color: #c53030;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input[type="password"]:focus {
    border-color: #ff9a8b;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: #ff7a59;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #ff5a3a;
}

/* ===== 主頁 ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;
    font-size: 24px;
}

.logout-link {
    color: #999;
    font-size: 13px;
}

.logout-link:hover {
    color: #666;
}

/* 控制區 */
.controls {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.input-row label {
    font-weight: 600;
    flex-shrink: 0;
}

.input-row input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}

.input-row input:focus {
    border-color: #ff9a8b;
}

/* 品種搜尋紀錄下拉 */
.breed-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.breed-wrap input {
    width: 100%;
}

.breed-history {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.breed-history li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.breed-history li:hover {
    background: #fff5f1;
}

.breed-history li span {
    flex: 1;
}

.hist-del {
    background: transparent;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 6px;
    margin-left: 8px;
}

.hist-del:hover {
    color: #c53030;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-primary {
    padding: 12px 24px;
    background: #ff7a59;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #ff5a3a;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 12px 24px;
    background: #fff;
    color: #ff7a59;
    border: 2px solid #ff7a59;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #fff5f1;
}

.quota {
    color: #666;
    font-size: 14px;
}

.quota strong {
    color: #ff7a59;
}

/* 結果區 */
.results {
    display: grid;
    gap: 16px;
}

.post-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: opacity 0.2s;
}

.post-card.loading {
    opacity: 0.4;
    pointer-events: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.type-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #fff5f1;
    color: #ff7a59;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.icon-btn {
    background: transparent;
    border: 1px solid #eee;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s, border-color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: #fff5f1;
    border-color: #ffd3c8;
}

.icon-btn:active {
    background: #ffe1d5;
}

/* 圖片區 */
.card-photos {
    margin-bottom: 14px;
}

.photo-loading,
.photo-empty {
    background: #f8f9fa;
    color: #888;
    text-align: center;
    padding: 24px 12px;
    border-radius: 10px;
    font-size: 14px;
}

.photo-loading {
    animation: pulse 1.4s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.main-photo {
    display: block;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
    background: #f0f0f0;
}

.main-photo img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: cover;
}

.photo-attr {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.4;
}

.thumbs-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thumbs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex: 1;
    min-width: 0;
}

.photo-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.thumb {
    flex-shrink: 0;
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    background: #f0f0f0;
}

.thumb:hover {
    border-color: #ffd3c8;
}

.thumb.selected {
    border-color: #ff7a59;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-src {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-content {
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
}

.card-hashtags {
    color: #1a73e8;
    font-size: 14px;
    margin-bottom: 8px;
    word-break: break-word;
}

.card-hint {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #666;
}

/* 自動附加的店家簽名區塊 */
.card-signature {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    color: #555;
    white-space: pre-wrap;
    line-height: 1.7;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
    position: relative;
}

.card-signature::before {
    content: "🔖 自動附加";
    position: absolute;
    top: -8px;
    left: 12px;
    background: #fff;
    color: #999;
    font-size: 11px;
    padding: 0 6px;
    border-radius: 4px;
}

/* 文字區下方的複製文字鈕 */
.text-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-copy-text {
    background: #fff5f1;
    color: #ff7a59;
    border: 1px solid #ffd3c8;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-copy-text:hover {
    background: #ffe1d5;
    border-color: #ff7a59;
}

.btn-copy-text:active {
    background: #ffd3c8;
}

/* 骨架載入 */
.skeleton {
    background: #fff;
}

.sk-bar {
    height: 14px;
    background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.sk-bar.short {
    width: 60%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* 底部操作 */
.bottom-actions {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

/* 錯誤訊息 */
.error-box {
    background: #fff0f0;
    color: #c53030;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    z-index: 9999;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 手機 RWD */
@media (max-width: 600px) {
    .page-header h1 { font-size: 19px; }
    .controls { padding: 16px; }
    .input-row { flex-direction: column; align-items: stretch; }
    .input-row label { margin-bottom: 4px; }
    .action-row { justify-content: space-between; }
    .post-card { padding: 14px; }
}
