/* Base CSS - Material Design Dark Theme */

/* 基礎重置和变量 */
:root {
    /* Agent 專用色彩 */
    --agent-primary: #336699;
    --agent-secondary: #FF9800;
    
    /* 系统色彩 */
    --success: #4CAF50;
    --error: #F44336;
    --warning: #FF9800;
    --info: #2196F3;
    
    /* 背景層次 */
    --bg-default: #121212;
    --bg-default-rgb: 18, 18, 18;
    --bg-paper: #1e1e1e;
    --bg-surface: #2a2a2a;
    
    /* 文字層次 */
    --text-primary: #ffffff;
    --text-secondary: rgba(255,255,255,0.7);
    --text-disabled: rgba(255,255,255,0.5);
    
    /* 邊框和分隔 */
    --divider: rgba(255,255,255,0.12);
    --border-light: rgba(255,255,255,0.23);
    --border-hover: rgba(255,255,255,0.5);
    
    /* 間距系统 (基於 8px) */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* 圓角系统 */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    
    /* 陰影系统 */
    --shadow-light: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-heavy: 0 8px 32px rgba(0,0,0,0.5);
}

/* 全域样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: "Roboto", "Helvetica", "Arial", "Noto Sans TC", sans-serif;
    background-color: var(--bg-default);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 滾動條样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-default);
}

::-webkit-scrollbar-thumb {
    background: var(--divider);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* 基礎元素样式 */
a {
    color: var(--agent-primary);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--info);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease-in-out;
}

input, textarea, select {
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--divider);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease-in-out;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--agent-primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* 工具類 */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.align-center { align-items: center; }
.align-end { align-items: flex-end; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.m-0 { margin: 0; }
.p-0 { padding: 0; }

/* Material Icons */
.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

/* 旋轉動畫 */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

/* 淡入動畫 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* 響應式斷點 */
@media (max-width: 767px) {
    :root {
        --spacing-md: 12px;
        --spacing-lg: 16px;
        --spacing-xl: 24px;
    }
}

/* 通用按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: none;
    text-decoration: none;
    min-height: 40px;
    gap: var(--spacing-xs);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background-color: #1976D2;
    box-shadow: var(--shadow-light);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--divider);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-surface);
    border-color: var(--border-light);
    color: var(--text-primary);
}

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

.btn-success:hover:not(:disabled) {
    background-color: #388E3C;
}

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

.btn-error:hover:not(:disabled) {
    background-color: #D32F2F;
}

/* 表單样式 */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-surface);
    border: 1px solid var(--divider);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.form-input::placeholder {
    color: var(--text-disabled);
}

.form-input:focus {
    border-color: var(--agent-primary);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* 错误消息 */
.error-message {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: var(--border-radius-sm);
    color: var(--error);
    font-size: 14px;
    margin-bottom: var(--spacing-md);
}

/* 加载指示器 */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* 模態框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-paper);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-heavy);
    transform: scale(0.9);
    transition: transform 0.3s ease-in-out;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(18, 18, 18, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

.loading-content .material-icons {
    font-size: 40px;
    margin-bottom: var(--spacing-sm);
}

.loading-content p {
    margin: 0;
    font-size: 16px;
}
