/* 全局樣式 */
:root {
    --primary-color: #4a6fa5;
    --secondary-color: #6b8cc2;
    --accent-color: #2c4875;
    --bg-color: #f5f7fa;
    --text-color: #333;
    --light-gray: #e1e5eb;
    --dark-gray: #6c757d;
    --sidebar-width: 300px;
    --header-height: 60px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
}

/* 按鈕樣式 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn i {
    font-size: 16px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background-color: var(--light-gray);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #d0d4db;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-new-chat {
    width: 100%;
    background-color: var(--accent-color);
    color: white;
    margin-bottom: 15px;
    padding: 10px;
    font-weight: 500;
}

.btn-new-chat:hover {
    background-color: #243c65;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-send {
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.3s;
}

.btn-send:hover {
    background-color: var(--accent-color);
    transform: scale(1.05);
}

.btn-docs {
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 14px;
}

.btn-docs:hover {
    background-color: #5a78a8;
}

.btn-upload {
    background-color: var(--primary-color);
    color: white;
    margin-left: 10px;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-profile, .btn-admin, .btn-settings, .btn-logout {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    background-color: rgba(74, 111, 165, 0.1);
    transition: all 0.2s;
}

.btn-profile:hover, .btn-admin:hover, .btn-settings:hover {
    background-color: rgba(74, 111, 165, 0.2);
    transform: translateY(-1px);
}

.btn-logout {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.btn-logout:hover {
    background-color: rgba(220, 53, 69, 0.2);
    transform: translateY(-1px);
}

/* 檔案選擇按鈕樣式 */
.btn-file-select {
    background-color: var(--secondary-color);
    color: white;
    margin-right: 10px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.3s;
}

.btn-file-select:hover {
    background-color: var(--accent-color);
    transform: scale(1.05);
}

/* 檔案選擇列表樣式 */
.file-select-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

#rag-files-list {
    list-style: none;
    padding: 0;
}

#rag-files-list li {
    padding: 12px 15px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
}

#rag-files-list li:last-child {
    border-bottom: none;
}

#rag-files-list li label {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
}

#rag-files-list li input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
}

#rag-files-list .file-name {
    flex: 1;
    font-size: 14px;
}

/* 登入/註冊頁面 */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--bg-color);
    background-image: linear-gradient(135deg, rgba(74, 111, 165, 0.1) 0%, rgba(255, 255, 255, 0.1) 100%);
}

.auth-box {
    background-color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 420px;
    max-width: 90%;
    transition: transform 0.3s;
}

.auth-box:hover {
    transform: translateY(-2px);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--primary-color);
    font-weight: 600;
}

.tabs {
    display: flex;
    margin-bottom: 25px;
    border-radius: 6px;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background-color: var(--light-gray);
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--accent-color);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

.auth-form button {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 500;
}

/* 主應用佈局 */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 側邊欄 */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border-right: 1px solid var(--light-gray);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: width 0.3s;
    z-index: 10;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    flex-direction: column;
}

.sidebar-header h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 20px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-gray) transparent;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background-color: var(--dark-gray);
    border-radius: 6px;
}

.chat-item {
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    background-color: rgba(245, 247, 250, 0.6);
}

.chat-item:hover {
    background-color: var(--light-gray);
    border-color: #d0d4db;
    transform: translateY(-1px);
}

.chat-item.active {
    background-color: rgba(74, 111, 165, 0.1);
    border-color: rgba(74, 111, 165, 0.2);
}

.chat-title {
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--accent-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-time {
    font-size: 12px;
    color: var(--dark-gray);
}

.delete-chat {
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
    transition: all 0.2s;
}

.delete-chat:hover {
    color: #bd2130;
    transform: scale(1.1);
}

/* 確保刪除按鈕在任何結構下都正確顯示 */
.chat-item:hover .chat-info .delete-chat {
    display: inline-block;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--light-gray);
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: rgba(245, 247, 250, 0.5);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.user-info span {
    font-weight: 500;
    color: var(--accent-color);
}

.user-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* 主內容區 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

.chat-header {
    height: var(--header-height);
    padding: 0 25px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    box-shadow: var(--shadow-sm);
}

.chat-header h1 {
    color: var(--primary-color);
    font-size: 22px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--dark-gray) transparent;
    background-color: var(--bg-color);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--dark-gray);
    border-radius: 6px;
}

.welcome-message {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    max-width: 750px;
    align-self: center;
    transition: transform 0.3s;
    border: 1px solid rgba(74, 111, 165, 0.1);
}

.welcome-message:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-weight: 600;
}

.welcome-message p {
    color: var(--dark-gray);
    font-size: 16px;
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 18px;
    margin-bottom: 20px;
    line-height: 1.5;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.message:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message {
    align-self: flex-start;
    background-color: white;
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}

.bot-message pre {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    max-width: 100%;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid #eaeaea;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid var(--light-gray);
    display: flex;
    align-items: center;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.chat-input textarea {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--light-gray);
    border-radius: 24px;
    resize: none;
    min-height: 54px;
    max-height: 150px;
    margin-right: 15px;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Microsoft JhengHei', Arial, sans-serif;
    font-size: 15px;
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

/* 彈窗樣式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background-color: white;
    margin: 8% auto;
    padding: 25px;
    width: 600px;
    max-width: 90%;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light-gray);
}

.modal-header h2 {
    color: var(--primary-color);
    font-weight: 600;
}

.close {
    font-size: 24px;
    cursor: pointer;
    color: var(--dark-gray);
    transition: color 0.2s, transform 0.2s;
}

.close:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.upload-section {
    margin-bottom: 25px;
    padding: 20px;
    background-color: var(--bg-color);
    border-radius: 8px;
    border: 1px dashed var(--light-gray);
}

#upload-form {
    display: flex;
    align-items: center;
}

#doc-file {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    background-color: white;
}

.documents-list h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 500;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--light-gray);
}

#docs-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

#docs-list li {
    padding: 12px 15px;
    border-bottom: 1px solid var(--light-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

#docs-list li:hover {
    background-color: rgba(245, 247, 250, 0.8);
}

.doc-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-icon {
    color: var(--primary-color);
    font-size: 18px;
}

.doc-name {
    font-weight: 500;
    color: var(--text-color);
}

.delete-doc {
    color: #dc3545;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-doc:hover {
    color: #bd2130;
    transform: scale(1.1);
}

/* 頭像通用樣式 */
.avatar-small, .user-avatar {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.user-avatar:hover {
    transform: scale(1.05);
}

/* 個人設定相關樣式 */
.profile-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

#current-avatar {
    width: 100px;
    height: 100px;
    margin-bottom: 15px;
}

.profile-info {
    background-color: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* 管理員頁面相關樣式 */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light-gray);
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 35px;
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.admin-nav .btn {
    padding: 10px 16px;
    font-weight: 500;
}

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.user-card {
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 25px;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

.user-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(74, 111, 165, 0.3);
}

.user-card .user-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 15px;
    display: block;
    border: 3px solid #f0f0f0;
}

.user-card .user-info {
    text-align: center;
    margin-bottom: 20px;
}

.user-card .user-info h3 {
    color: var(--accent-color);
    margin-bottom: 5px;
}

.user-card .user-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.user-card .user-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 15px;
}

.user-card .stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-card .stat-item i {
    color: var(--primary-color);
    font-size: 14px;
    width: 20px;
    height: 20px;
    background-color: rgba(74, 111, 165, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-card .stat-details {
    display: flex;
    flex-direction: column;
}

.user-card .stat-label {
    font-size: 12px;
    color: var(--dark-gray);
}

.user-card .stat-value-sm {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-color);
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    margin-left: 8px;
    font-weight: 500;
}

.badge-admin {
    background-color: rgba(76, 175, 80, 0.2);
    color: #388e3c;
}

/* 側邊欄管理菜單 */
.admin-menu {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.menu-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--dark-gray);
}

.menu-item span {
    font-weight: 500;
    color: var(--text-color);
}

.menu-item:hover {
    background-color: var(--light-gray);
    transform: translateY(-1px);
}

.menu-item.active {
    background-color: rgba(74, 111, 165, 0.1);
    border-color: rgba(74, 111, 165, 0.2);
}

.menu-item.active i,
.menu-item.active span {
    color: var(--primary-color);
}

/* 管理界面部分 */
.admin-section {
    display: none;
    animation: fadeIn 0.3s;
}

.admin-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--light-gray);
}

.search-filter {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--dark-gray);
}

/* 統計卡片 */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    border: 1px solid var(--light-gray);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    background-color: rgba(74, 111, 165, 0.1);
    color: var(--primary-color);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info h3 {
    color: var(--dark-gray);
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
}

/* 設定卡片 */
.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.settings-card {
    background-color: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--light-gray);
    transition: all 0.3s;
}

.settings-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.settings-card h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--light-gray);
    font-weight: 600;
}

.range-value {
    text-align: center;
    margin-top: 5px;
    color: var(--accent-color);
    font-weight: 500;
}

/* 日誌界面 */
.log-entries {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    max-height: 600px;
    overflow-y: auto;
}

.log-entry {
    display: grid;
    grid-template-columns: 180px 100px 1fr;
    gap: 15px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--light-gray);
    transition: background-color 0.2s;
}

.log-entry:hover {
    background-color: rgba(245, 247, 250, 0.8);
}

.log-timestamp {
    color: var(--dark-gray);
    font-size: 13px;
}

.log-level {
    font-weight: 500;
    text-align: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

.log-message {
    font-size: 14px;
}

.log-error .log-level {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.log-warning .log-level {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.log-info .log-level {
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
}

.log-debug .log-level {
    background-color: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

/* 文件列表 */
.document-list {
    margin-top: 20px;
}

.document-item {
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    border: 1px solid var(--light-gray);
}

.document-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.document-item .doc-icon {
    width: 50px;
    height: 50px;
    background-color: rgba(74, 111, 165, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary-color);
}

.document-item .doc-info {
    flex: 1;
}

.document-item .doc-info h3 {
    color: var(--accent-color);
    margin-bottom: 5px;
}

.document-item .doc-info p {
    color: var(--dark-gray);
    font-size: 13px;
    margin-bottom: 5px;
}

.document-item .doc-description {
    font-style: italic;
    color: var(--text-color);
}

.document-item .doc-actions {
    display: flex;
    gap: 10px;
}

/* 空狀態 */
.empty-state {
    text-align: center;
    padding: 50px 0;
    color: var(--dark-gray);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.7;
}

.empty-state p {
    font-size: 16px;
}

/* 上傳相關通用樣式 */
.upload-area,
.avatar-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area {
    padding: 30px;
    border: 2px dashed var(--light-gray);
    border-radius: 10px;
    background-color: rgba(245, 247, 250, 0.6);
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.drag-over {
    background-color: rgba(74, 111, 165, 0.05);
    border-color: var(--primary-color);
}

.upload-icon {
    font-size: 40px;
    color: var(--primary-color);
    margin-bottom: 15px;
    opacity: 0.7;
}

.upload-area p {
    color: var(--dark-gray);
}

.upload-label {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.upload-label:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
}

.avatar-upload input[type="file"],
.upload-area input[type="file"] {
    display: none;
}

/* 頭像上傳專用樣式 */
.avatar-preview-container {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 15px;
    border: 3px solid #f0f0f0;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: all 0.3s;
}

.avatar-preview-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

.avatar-preview-container img,
#avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s;
}

.avatar-preview-container:hover img {
    filter: brightness(0.9);
}

/* 用戶編輯模態框中的頭像預覽容器 */
.user-modal-layout .avatar-preview-container {
    width: 180px;
    height: 180px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    color: white;
    font-size: 36px;
}

.avatar-preview-container:hover .avatar-overlay {
    opacity: 1;
}

.avatar-hint {
    font-size: 12px;
    color: var(--dark-gray);
    text-align: center;
    margin-top: 10px;
}

/* 表單通用樣式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--accent-color);
}

.form-icon {
    width: 20px;
    margin-right: 8px;
    color: var(--primary-color);
}

.form-group input[type="text"],
.form-group input[type="password"],
.search-box input,
.filter-dropdown select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-group input:focus,
.search-box input:focus,
.filter-dropdown select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

.search-box input {
    padding-left: 35px;
}

/* 表單動作 */
.form-actions,
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* 密碼輸入組 */
.password-field {
    position: relative;
    width: 100%;
}

.password-field input
.password-input-container input
{
    width: 100%;
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-100%);
    background: none;
    border: none;
    color: var(--dark-gray);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: color 0.2s;
    z-index: 10;
    outline: none;
}

.toggle-password:hover {
    color: var(--primary-color);
}

/* 為了向後相容保留 password-input-container 樣式 */
.password-input-container {
    position: relative;
    width: 100%;
}

/* 輔助文本 */
.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--dark-gray);
}

.text-danger {
    color: #dc3545;
}

/* Toast通知 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    background-color: white;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    max-width: 350px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid #4caf50;
}

.toast-error {
    border-left: 4px solid #dc3545;
}

.toast-warning {
    border-left: 4px solid #ff9800;
}

.toast-message {
    font-size: 14px;
    color: var(--text-color);
}

/* 用戶創建/編輯模態框樣式 */
.user-modal-content {
    max-width: 800px;
    width: 95%;
}

.user-modal-layout {
    display: flex;
    gap: 30px;
}

/* 頭像區塊樣式 */
.avatar-section {
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.avatar-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* 表單區塊樣式 */
.user-form-section {
    flex: 1;
}

.hidden-input {
    display: none;
}

/* 角色選擇卡片 */
.role-group {
    margin-top: 30px;
}

.role-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--accent-color);
}

.role-options {
    display: flex;
    gap: 15px;
}

.role-option {
    flex: 1;
}

.role-option input[type="radio"] {
    display: none;
}

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px;
    border: 2px solid var(--light-gray);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.role-card i {
    font-size: 30px;
    margin-bottom: 12px;
    color: var(--dark-gray);
    transition: all 0.3s;
}

.role-card span {
    font-weight: 500;
    color: var(--text-color);
}

.role-option input[type="radio"]:checked + .role-card {
    border-color: var(--primary-color);
    background-color: rgba(74, 111, 165, 0.05);
}

.role-option input[type="radio"]:checked + .role-card i {
    color: var(--primary-color);
}

.role-option:first-child input[type="radio"]:checked + .role-card i {
    color: var(--primary-color);
}

.role-option:last-child input[type="radio"]:checked + .role-card i {
    color: var(--accent-color);
}

/* 響應式設計 */
@media (max-width: 992px) {
    .sidebar {
        width: 260px;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-cards {
        grid-template-columns: 1fr;
    }

    .user-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 220px;
    }

    .message {
        max-width: 85%;
    }

    .log-entry {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .search-box {
        width: 200px;
    }

    .user-modal-layout {
        flex-direction: column;
        align-items: center;
    }

    .avatar-section, .user-form-section {
        width: 100%;
    }

    .avatar-preview-container {
        width: 150px;
        height: 150px;
    }
}

@media (max-width: 576px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
    }

    .chat-messages {
        padding: 15px;
    }

    .welcome-message {
        padding: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }

    .search-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .search-box {
        width: 100%;
    }

    .admin-nav {
        flex-direction: column;
        align-items: stretch;
    }
}

.auth-form .toggle-password {
    width: 24px !important; /* 確保覆蓋全局樣式 */
}
 