/* === 全域設定 === */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f6f8;
    color: #333;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

h1 { margin-top: 0; color: #1a73e8; }
h2 { border-bottom: 2px solid #e0e0e0; padding-bottom: 10px; margin-top: 40px; color: #444; }

/* === 按鈕與狀態 === */
.btn-primary {
    background-color: #1a73e8;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}
.btn-primary:hover { background-color: #1557b0; }

.status-msg { margin-top: 10px; color: #666; font-size: 0.9em; }

/* === RWD 網格系統 (核心) === */
/* 分頁列表容器 (Grid 佈局) */
.grid-container {
    display: grid;
    
    /* ★ 修改重點 1：強制分為 2 欄，每欄各佔一半 (1fr) */
    grid-template-columns: repeat(2, 1fr); 
    
    gap: 20px; /* 間距稍微加大一點比較好看 */
    padding: 10px;
}

/* ★ 修改重點 2：針對手機或窄螢幕的優化 */
/* 當螢幕寬度小於 768px (一般手機或直立平板) 時，變回 1 欄 */
@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: 1fr; /* 手機版改為單欄顯示，避免太擠 */
    }
}


/* 電腦 (寬度 > 900px) */
@media (min-width: 900px) {
    .grid-container { grid-template-columns: repeat(2, 1fr); }
}

/* === 卡片樣式 (用於 Current URL & Tabs) === */
.card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 80px;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
    border-color: #1a73e8;
}

.card-label {
    font-size: 0.85em;
    color: #888;
    font-weight: bold;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.card-url {
    font-size: 0.95em;
    color: #0066cc;
    word-break: break-all; /* 防止長網址撐破版面 */
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 最多顯示3行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === 歷史紀錄列表樣式 === */
.history-list {
    list-style: none;
    padding: 0;
}

.history-item {
    background: #fcfcfc;
    border-bottom: 1px solid #eee;
    padding: 12px 16px;
    transition: background 0.2s;
}

.history-item:hover { background-color: #f0f7ff; }
.history-item:first-child { border-top: 1px solid #eee; }

.history-item a {
    text-decoration: none;
    color: #333;
    display: flex;
    align-items: center;
}

.history-index {
    background: #e0e0e0;
    color: #555;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-right: 10px;
    font-family: monospace;
    min-width: 30px;
    text-align: center;
}

.history-title { font-weight: 500; }
.history-date { font-size: 0.8em; color: #999; margin-left: auto; padding-left: 10px;}

/* === 編輯器樣式 === */
.editor-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.url-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.url-input {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
}

.url-input:focus {
    border-color: #1a73e8;
    outline: none;
}

.btn-secondary {
    background: #f1f3f4;
    border: 1px solid #ddd;
    padding: 0 20px;
    border-radius: 4px;
    cursor: pointer;
}

/* === 上傳提示條 === */
.upload-bar {
    background-color: #fff3e0;
    border: 1px solid #ffe0b2;
    color: #e65100;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeIn 0.5s;
}

.btn-save {
    background-color: #e65100;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.btn-save:hover { background-color: #ef6c00; }

/* === Iframe 容器 === */
.iframe-wrapper {
    position: relative;
    width: 100%;
    height: 500px; /* 固定高度 */
    border: 1px solid #e0e0e0;
    background: #fafafa;
    border-radius: 4px;
    overflow: hidden;
}

.iframe-hint {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #999;
    background: rgba(255,255,255,0.8);
    margin: 0;
    padding: 5px;
    z-index: 1; /* 在 iframe 下層，但在背景上層 */
}

iframe {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2; /* 蓋過提示文字 */
    background: transparent;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }


/* 分頁卡片容器 - 必須加上 position: relative */
.editor-container {
    position: relative; /* 關鍵：讓內部的絕對定位按鈕以這裡為基準 */
    padding: 10px;
    border: 1px solid #eee;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 8px;
    transition: all 0.2s;
}

.editor-container:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 刪除按鈕樣式 */
.delete-btn {
    position: absolute;
    top: -10px;       /* 稍微凸出上方 */
    left: -10px;      /* 稍微凸出左方 */
    width: 24px;
    height: 24px;
    background-color: #ff4d4f; /* 紅色 */
    margin-top: 10px;
    margin-left: 10px;
    color: white;
    border: none;
    border-radius: 50%; /* 圓形 */
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 10;      /* 確保在 iframe 上層 */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
}

.delete-btn:hover {
    background-color: #ff7875;
    transform: scale(1.1);
}


/* === 手機版響應式設定 (螢幕小於 768px 時觸發) === */
@media (max-width: 768px) {
    
    /* 1. 針對 body：移除背景色與邊距，讓畫面更乾淨 */
    body {
        padding: 0;
        margin: 0;
        background-color: #fff; /* 將背景改成白色，與卡片融合 */
    }

    /* 2. 針對 container：強制滿版 */
    .container {
        width: 100%;           /* 寬度佔滿 100% */
        max-width: none;       /* 取消最大寬度限制 */
        margin: 0;             /* 移除上下左右的外邊距 */
        border-radius: 0;      /* 移除圓角 (變成直角) */
        box-shadow: none;      /* 移除陰影 (因為已經滿版了，不需要浮起來的效果) */
        min-height: 100vh;     /* 讓白色區塊至少佔滿整個螢幕高度 */
        padding: 15px;         /* 內容稍微保留一點內邊距 */
    }

    /* 3. (選用) 調整標題大小，避免手機上字太大 */
    header h1 {
        font-size: 24px;
        margin-top: 10px;
    }
}