/* ========================================
   基礎重置和變量
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-cyan: #a5f4f3;
    --primary-gold: #ffd900;
    --primary-blue: #6dceff;
    --accent-teal: #06ffa5;
    --dark-bg: #0a0a0a;
    --dark-overlay: rgba(10, 10, 10, 0.85);
    --dark-secondary: rgba(20, 20, 20, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #6dceff;
    --text-secondary: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --success: #06ffa5;
    --error: #ff4757;
    --warning: #ffd900;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========================================
   粒子背景
   ======================================== */
#particles-js {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* ========================================
   屏幕切換
   ======================================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   玻璃擬態卡片
   ======================================== */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 2rem;
    transition: all 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(165, 244, 243, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* ========================================
   登錄界面
   ======================================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.login-card {
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.app-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-cyan);
    margin-bottom: 0.5rem;
}

.app-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    background: rgba(255, 255, 255, 0.15);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: var(--dark-bg);
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(165, 244, 243, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-message {
    color: var(--error);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

/* ========================================
   主應用界面
   ======================================== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--dark-overlay);
    border-bottom: 1px solid var(--glass-border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-right {
    display: flex;
    align-items: center;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.online-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.app-logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-cyan);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-id-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-id {
    font-family: 'Courier New', monospace;
    color: var(--primary-cyan);
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    background: rgba(165, 244, 243, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(165, 244, 243, 0.3);
}

.online-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* ========================================
   主內容區域
   ======================================== */
.app-main {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* 左側：檔案選擇和用戶列表 */
.sidebar-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.file-selection-card {
    flex: 0 0 auto;
    max-height: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.users-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-cyan);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.icon {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-cyan) transparent;
}

.users-list::-webkit-scrollbar {
    width: 6px;
}

.users-list::-webkit-scrollbar-track {
    background: transparent;
}

.users-list::-webkit-scrollbar-thumb {
    background: var(--primary-cyan);
    border-radius: 3px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-cyan);
    transform: translateX(5px);
}

.user-item.selected {
    background: rgba(165, 244, 243, 0.2);
    border-color: var(--primary-cyan);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--dark-bg);
    font-size: 0.9rem;
}

.user-name {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

/* 選擇類型按鈕 */
.selection-type {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.type-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-cyan);
}

.type-btn.active {
    background: rgba(165, 244, 243, 0.15);
    border-color: var(--primary-cyan);
    color: var(--primary-cyan);
}

.type-btn .icon {
    width: 18px;
    height: 18px;
}

/* 內容區域 */
.content-area {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.content-area.active {
    display: flex;
}

/* 文字輸入區域 */
#text-input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    background: rgba(255, 255, 255, 0.15);
}

.text-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

/* 右側：傳輸紀錄 */
.main-content {
    overflow: hidden;
}

.transfers-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.upload-area {
    border: 2px dashed var(--glass-border);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-cyan);
    background: rgba(165, 244, 243, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    stroke: var(--primary-cyan);
    stroke-width: 2px;
    margin-bottom: 0.75rem;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.selected-files {
    margin-top: 1.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-cyan);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark-bg);
    font-weight: 600;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-remove {
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.5rem;
    transition: all 0.3s ease;
}

.file-remove:hover {
    transform: scale(1.2);
}


.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.transfers-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-cyan) transparent;
}

.transfers-list::-webkit-scrollbar {
    width: 6px;
}

.transfers-list::-webkit-scrollbar-track {
    background: transparent;
}

.transfers-list::-webkit-scrollbar-thumb {
    background: var(--primary-cyan);
    border-radius: 3px;
}

.transfer-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.transfer-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.transfer-file-name {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.direction-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.9rem;
}

.direction-icon.send {
    background: rgba(6, 255, 165, 0.2);
    color: var(--success);
}

.direction-icon.receive {
    background: rgba(109, 206, 255, 0.2);
    color: var(--primary-blue);
}

.transfer-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.transfer-status.success {
    color: var(--success);
}

.transfer-status.error {
    color: var(--error);
}

.transfer-status.progress {
    color: var(--primary-cyan);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-cyan), var(--primary-blue));
    transition: width 0.3s ease;
}

.transfer-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.transfer-peer {
    font-weight: 500;
}

.transfer-time {
    font-family: 'Courier New', monospace;
}

.text-preview {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    border-left: 3px solid var(--primary-cyan);
}

.view-text-btn {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(165, 244, 243, 0.1);
    border: 1px solid var(--primary-cyan);
    border-radius: 8px;
    color: var(--primary-cyan);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.view-text-btn:hover {
    background: rgba(165, 244, 243, 0.2);
    transform: translateY(-1px);
}

.text-modal {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.text-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.text-modal-header h3 {
    color: var(--primary-cyan);
    margin: 0;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-modal-btn:hover {
    color: var(--text-secondary);
    transform: scale(1.1);
}

.text-modal-body {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    max-height: 50vh;
}

.text-modal-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    color: var(--text-secondary);
    line-height: 1.6;
}

.copy-text-btn {
    flex: 1;
}

/* ========================================
   模態框
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    color: var(--primary-cyan);
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    flex: 1;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-cyan);
}

/* ========================================
   Toast通知
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    min-width: 250px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.info {
    border-left: 3px solid var(--primary-cyan);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   響應式設計
   ======================================== */
@media (max-width: 1200px) {
    .app-main {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .header-left,
    .header-right {
        width: 100%;
        justify-content: center;
    }

    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .sidebar-left {
        max-height: 50vh;
    }

    .file-selection-card {
        max-height: 40%;
    }

    .glass-card {
        padding: 1rem;
    }

    .selection-type {
        flex-direction: column;
    }
}
