/* style.css */

/* 全局變數 */
:root {
    --primary-color: #4CAF50; /* 主色調：綠色 */
    --secondary-color: #2196F3; /* 次要色調：藍色 */
    --background-color: #f0f2f5; /* 淺灰色背景 */
    --card-background: #ffffff; /* 卡片背景色 */
    --text-color: #333; /* 主要文字顏色 */
    --light-text-color: #666; /* 次要文字顏色 */
    --border-color: #e0e0e0; /* 邊框顏色 */
    --shadow-light: rgba(0, 0, 0, 0.08); /* 輕微陰影 */
    --shadow-medium: rgba(0, 0, 0, 0.15); /* 中等陰影 */
    --danger-color: #f44336; /* 危險操作顏色：紅色 */
    --info-color: #2196f3; /* 資訊提示顏色 */
    --success-color: #4CAF50; /* 成功提示顏色 */
    --font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 基本樣式 */
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 讓內容從頂部開始 */
    min-height: 100vh;
}

.container {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-light);
    padding: 30px;
    margin: 20px;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
}

h1, h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 25px;
    font-weight: 600;
}

h2 {
    font-size: 1.8em;
    margin-top: 30px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    color: var(--secondary-color);
    display: flex; /* 讓 h2 內部元素可以並排 */
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    position: relative; /* 為了絕對定位按鈕 */
}

/* 按鈕樣式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap; /* 防止按鈕文字換行 */
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #43a047; /* 綠色深一點 */
    box-shadow: 0 4px 8px var(--shadow-light);
}

.btn-secondary {
    background-color: #6c757d; /* 灰色 */
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    box-shadow: 0 4px 8px var(--shadow-light);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #d32f2f;
    box-shadow: 0 4px 8px var(--shadow-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 6px;
    margin-left: 8px; /* 小按鈕之間加間距 */
}

/* 新增的刷新按鈕樣式 */
.btn-icon {
    background-color: transparent; /* 透明背景 */
    color: var(--secondary-color); /* 與標題顏色一致 */
    padding: 5px 10px;
    font-size: 0.9em;
    font-weight: 600;
    margin-left: 15px; /* 與標題文字間距 */
    border: 1px solid var(--secondary-color); /* 邊框 */
}

.btn-icon:hover {
    background-color: rgba(33, 150, 243, 0.1); /* 淺藍色背景 */
    color: var(--secondary-color);
    box-shadow: none;
}

/* 登入區塊 */
.auth-section {
    text-align: center;
    padding: 40px;
    background-color: var(--card-background);
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-light);
    margin-top: 50px;
}

.auth-section h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 2em;
}

.auth-section .g_id_signin {
    margin: 25px auto;
    width: fit-content; /* 讓 Google 按鈕居中 */
}

.auth-hint {
    color: var(--light-text-color);
    font-size: 0.95em;
}

/* 頁面標頭 (登入後) */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
}

header h1 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 2.2em;
}

.user-info {
    display: flex;
    align-items: center;
    font-size: 1.05em;
    color: var(--light-text-color);
}

#user-email {
    font-weight: 500;
    margin-right: 15px;
    color: var(--text-color);
}

/* 上傳區塊 */
.upload-section {
    background-color: var(--card-background);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px var(--shadow-light);
    text-align: center;
}

.file-input {
    display: block;
    width: calc(100% - 20px);
    padding: 10px;
    margin: 15px auto 20px auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background-color: #fdfdfd;
}

/* 檔案列表區塊 */
.file-list-section {
    background-color: var(--card-background);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px var(--shadow-light);
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* 自動適應，最小寬度 280px */
    gap: 20px; /* 卡片之間的間距 */
    padding: 10px 0;
}

.file-card {
    background-color: #f9f9f9;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 2px 8px var(--shadow-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px var(--shadow-medium);
}

.file-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 500;
    word-break: break-all; /* 防止長文件名溢出 */
}

.file-icon {
    font-size: 1.5em;
    margin-right: 10px;
    color: var(--secondary-color);
}

.file-name-text {
    flex-grow: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-color);
}

.file-size {
    font-size: 0.9em;
    color: var(--light-text-color);
    margin-left: 8px;
    white-space: nowrap; /* 防止文件大小換行 */
}

.file-actions {
    display: flex;
    justify-content: flex-end; /* 按鈕靠右 */
    margin-top: 10px;
}

/* 訊息提示 */
.info-message, .error-message {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.info-message {
    background-color: #e3f2fd; /* 淺藍色 */
    color: var(--info-color);
    border: 1px solid var(--info-color);
}

.error-message {
    background-color: #ffebee; /* 淺紅色 */
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

/* Google Sign-In 按鈕的自定義樣式，盡量不干擾 GSI 的樣式 */
.g_id_signin div[aria-labelledby^="gsi_"] {
    display: block !important;
    margin: 0 auto !important;
}

/* RWD 響應式調整 */
@media (max-width: 768px) {
    .container {
        margin: 15px;
        padding: 20px;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
    }

    header h1 {
        margin-bottom: 10px;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
    }

    .file-grid {
        grid-template-columns: 1fr; /* 小螢幕下單列顯示 */
    }

    .file-card {
        padding: 15px;
    }

    .btn {
        width: 100%;
        margin-bottom: 10px; /* 在小螢幕下按鈕間隔 */
    }
    .btn-sm {
        margin-left: 0;
    }
    .file-actions .btn-sm:not(:last-child) {
        margin-right: 8px; /* 小按鈕在同一行時的間距 */
        margin-bottom: 0;
    }

    h2 {
        flex-direction: column; /* 小螢幕下標題和按鈕垂直排列 */
        align-items: center;
    }

    .btn-icon {
        margin-top: 10px; /* 刷新按鈕和標題的間距 */
        margin-left: 0;
        width: 100%;
    }
}
