/* style.css - Enhanced Styles for WebRTC P2P Platform v9.9 (已修复) */

/* --- Base & Theme Variables --- */
:root {
    /* Default Theme: Aurora Green */
    --color1: #94c83e;
    --color2: #01b3ab;
    
    --accent-color: #f39c12;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f1c40f;
    --light-color: #F8F9FA;
    --dark-color: #2c3e50;
    --card-bg: rgba(10, 25, 41, 0.8);
    --card-border: rgba(255, 255, 255, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--light-color);
    font-family: 'Segoe UI', 'Microsoft YaHei', Tahoma, Geneva, Verdana, sans-serif;
    position: relative;
    overflow-x: hidden;
    background-color: #333; /* Fallback color */
}

/* Dynamic Gradient Background */
.background-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient( to right bottom, var(--color1), var(--color2) );
    background-size: 150% 150%;
    animation: gentleGradientShift 16s ease infinite;
    z-index: -3;
}

@keyframes gentleGradientShift {
    0%   { background-position: 10% 10%; }
    25%  { background-position: 90% 10%; }
    50%  { background-position: 90% 90%; }
    75%  { background-position: 10% 90%; }
    100% { background-position: 10% 10%; }
}

/* Background Image Blending */
.unsplash-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover; z-index: -2; opacity: 0;
    filter: brightness(0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 1.5s ease-in-out;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.3); /* Dark overlay */
    z-index: -1;
}


/* --- General Text & UI Elements --- */
h1, h2, h3, h4, h5, h6, p, span, label, div, small, strong, a, li {
    text-shadow: var(--text-shadow);
    color: var(--light-color);
}
#userList .list-group-item {
    color: var(--light-color) !important;
    font-weight: 500;
}

a, button, .btn { color: white !important; }
.text-info { color: #3498db !important; }
.text-white-50 { color: rgba(248, 249, 250, 0.65) !important; }
.badge { color: white !important; }
b, strong { color: var(--accent-color) !important; }

.card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 15px;
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 40px var(--shadow-color);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 15px 50px var(--shadow-color); }
.card-header { background: rgba(0, 0, 0, 0.3); border-bottom: 1px solid var(--card-border); font-weight: 600; padding: 1rem 1.5rem; font-size: 1.1rem; }
.form-control, .form-select, textarea { background-color: rgba(0,0,0,0.2) !important; border-color: rgba(255, 255, 255, 0.2); font-weight: 500; color: var(--light-color) !important; }
.form-control::placeholder, textarea::placeholder { color: rgba(255,255,255,0.5) !important; }
.form-control:focus, .form-select:focus, textarea:focus { border-color: var(--accent-color); box-shadow: 0 0 0 0.25rem rgba(243, 156, 18, 0.3); background-color: rgba(0,0,0,0.3) !important; }

/* --- Connection Status --- */
.connection-status { width: 14px; height: 14px; border-radius: 50%; margin-right: 10px; box-shadow: 0 0 8px rgba(0,0,0,0.6); transition: background-color 0.3s ease, box-shadow 0.3s ease; }
.status-connected { background: var(--success-color); box-shadow: 0 0 12px var(--success-color); }
.status-disconnected { background: var(--danger-color); }
.status-connecting { background: var(--warning-color); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.5; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0.5; transform: scale(0.9); } }

/* --- File Transfer & History --- */
.file-transfer-item { background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 12px; margin-bottom: 10px; position: relative; border-left: 4px solid var(--accent-color); }
.file-transfer-item.status-completed { border-left-color: var(--success-color); }
.file-transfer-item.status-failed, .file-transfer-item.status-aborted { border-left-color: var(--danger-color); }
.file-transfer-item.status-paused { border-left-color: #7f8c8d; }
.file-transfer-item .delete-btn { position: absolute; top: 5px; right: 5px; cursor: pointer; background: none; border: none; font-size: 0.8rem; }
.progress { height: 8px; background: rgba(0, 0, 0, 0.4); }
.file-type-icon { font-size: 2rem; width: 35px; text-align: center; }
.transfer-controls { display: flex; gap: 8px; }

/* 修复问题1：为提示文本保留固定空间，防止UI因文本出现/消失而抖动。 */
.transfer-hint {
    font-style: italic;
    font-size: 0.8rem;
    color: var(--warning-color) !important;
    min-height: 1.2em; /* 为单行文本保留空间 */
    transition: opacity 0.2s ease; /* 使文本出现/消失更平滑 */
}

#filePreviewContainer { display: flex; align-items: center; justify-content: center; flex-direction: column; }
#filePreviewContainer.has-file { flex-direction: row; }
#clearFileSelectionBtn { background: var(--danger-color); border: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; line-height: 1; cursor: pointer; transition: transform 0.2s, background-color 0.2s; margin-left: 10px; flex-shrink: 0; }
#clearFileSelectionBtn:hover { transform: scale(1.1); background-color: #c0392b; }

/* --- Screen Share --- */
#remoteScreen { width: 100%; height: auto; aspect-ratio: 16/9; background: #000; border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
#remoteScreen .placeholder-content { color: #888; }
#remoteScreen video { width: 100%; height: 100%; object-fit: contain; transition: transform 0.3s ease; }
#remoteScreen video.mirrored { transform: scaleX(-1); }
#localScreen { border: 2px solid rgba(255,255,255,0.2); }
.screen-controls { gap: 10px; }
#remoteScreen video:not([style*="display: none"]) ~ #remoteScreenPlaceholder {
    display: none !important;
}


/* --- Chat Panel --- */
#chatPanel { position: fixed; right: 0; bottom: 0; width: 360px; height: 480px; background: var(--card-bg); backdrop-filter: blur(20px); border-top-left-radius: 20px; border-top: 1px solid var(--card-border); border-left: 1px solid var(--card-border); box-shadow: -10px -10px 40px var(--shadow-color); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.4s ease-out; z-index: 1050; }
#chatPanel.show { transform: translateX(0); }
#chatHeader { background: rgba(0, 0, 0, 0.3); padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; }
#chatMessages { flex-grow: 1; padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }

.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.message-bubble {
    max-width: 85%;
    padding: 8px 14px;
    border-radius: 18px;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
    display: flex;
    flex-direction: column;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.user-name {
    font-weight: 600;
    white-space: nowrap;
    color: var(--light-color) !important;
}

.timestamp {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6) !important;
}

.message-content {
    word-break: break-word;
}

.message-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    margin-bottom: 4px; /* Align with bubble padding */
    align-items: center;
}

.message-wrapper:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white !important;
    padding: 2px 6px;
    font-size: 0.8rem;
    line-height: 1;
}
.message-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.message-sent {
    justify-content: flex-end;
}
.message-sent .message-bubble {
    background-color: #007bff;
    border-bottom-right-radius: 4px;
}
.message-sent .message-actions {
    margin-right: 8px;
}

.message-received {
    align-self: flex-start;
}
.message-received .message-bubble {
    background-color: #34495e;
    border-bottom-left-radius: 4px;
}
.message-received .message-actions {
    margin-left: 8px;
}

.message-snippet { background-color: #1e2731; border: 1px solid #4a5b70; border-radius: 8px; padding: 8px; margin-top: 5px; }
.message-snippet pre { margin: 0; background: none; padding: 0; }
.message-snippet code { font-size: 0.85em; }

.revoked-message {
    font-style: italic;
    white-space: nowrap;
    color: rgba(248, 249, 250, 0.7) !important;
}

#typing-indicator { height: 20px; padding: 0 1rem; font-style: italic; transition: opacity 0.3s; }

/* Emoji Picker */
#emoji-picker { position: absolute; bottom: 65px; left: 1rem; background: var(--dark-color); border: 1px solid var(--card-border); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; box-shadow: 0 -5px 15px rgba(0,0,0,0.3); z-index: 1060; }
#emoji-picker.d-none { display: none !important; }
#emoji-picker span { cursor: pointer; font-size: 1.5rem; text-align: center; transition: transform 0.2s; }
#emoji-picker span:hover { transform: scale(1.2); }

/* --- Quick Reactions --- */
.reactions-container { display: flex; justify-content: center; gap: 10px; padding: 10px 0; }
.reaction-btn { font-size: 1.5rem; cursor: pointer; transition: transform 0.2s ease; }
.reaction-btn:hover { transform: scale(1.3); }
.reaction-popup { position: fixed; top: 50%; left: 50%; font-size: 5rem; pointer-events: none; animation: fly-up 1.5s ease-out forwards; z-index: 9999; }
@keyframes fly-up { 0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; } 100% { transform: translate(-50%, -400%) scale(1.2); opacity: 0; } }

/* --- Theme Switcher --- */
#theme-switcher { position: fixed; top: 20px; right: 20px; z-index: 1060; cursor: pointer; font-size: 1.5rem; padding: 10px; background: var(--card-bg); border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; transition: transform 0.3s, color 0.3s; }
#theme-switcher:hover { transform: scale(1.1) rotate(15deg); color: var(--accent-color); }

/* --- System Log --- */
#logPanel { height: 200px; background-color: rgba(0, 0, 0, 0.4); border-radius: 8px; padding: 10px; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-size: 0.85rem; }
.log-entry { margin-bottom: 5px; white-space: pre-wrap; word-break: break-all; }
.log-time { color: #7f8c8d; margin-right: 10px; }
.log-info { color: #3498db; }
.log-success { color: var(--success-color); }
.log-warn { color: var(--warning-color); }
.log-error { color: var(--danger-color); }
.log-debug { color: #9b59b6; }

/* --- Whiteboard Styles --- */
#whiteboard {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    cursor: crosshair;
}
#whiteboard-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
#colorPicker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    background-color: transparent;
    border: none;
    cursor: pointer;
}
#colorPicker::-webkit-color-swatch {
    border-radius: 50%;
    border: 2px solid var(--light-color);
}
#colorPicker::-moz-color-swatch {
    border-radius: 50%;
    border: 2px solid var(--light-color);
}
