* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部导航栏 */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 24px;
}

.logo h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.search-input {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    padding: 5px 10px;
    width: 120px;
    outline: none;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover {
    opacity: 0.8;
}

.ticket-id-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 100px;
    text-align: center;
}

.ticket-status {
    font-size: 12px;
    opacity: 0.9;
    margin-left: 5px;
}

.admin-link {
    color: white;
    text-decoration: none;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* 聊天主区域 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

/* 欢迎区域 */
.welcome-section {
    padding: 40px 30px;
    text-align: center;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.welcome-icon {
    font-size: 60px;
    color: #667eea;
    margin-bottom: 20px;
    opacity: 0.8;
}

.welcome-section h2 {
    font-size: 28px;
    color: #495057;
    margin-bottom: 10px;
}

.welcome-section p {
    color: #6c757d;
    font-size: 16px;
    max-width: 600px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

.instructions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.instruction-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.instruction-item i {
    font-size: 32px;
    color: #667eea;
    margin-bottom: 15px;
}

.instruction-item h3 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 16px;
}

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    padding: 25px 30px;
    overflow-y: auto;
    min-height: 400px;
    max-height: calc(100vh - 300px);
    display: flex;
    flex-direction: column;
}

.chat-messages.has-ticket {
    background: white;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
    max-width: 80%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user {
    align-self: flex-end;
    margin-left: 20%;
}

.message-admin {
    align-self: flex-start;
    margin-right: 20%;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message-user .message-bubble {
    background: #667eea;
    color: white;
    border-top-right-radius: 4px;
}

.message-user .message-bubble:after {
    content: '';
    position: absolute;
    right: -8px;
    top: 0;
    border: 8px solid transparent;
    border-top-color: #667eea;
    border-right: 0;
}

.message-admin .message-bubble {
    background: #e9ecef;
    color: #495057;
    border-top-left-radius: 4px;
}

.message-admin .message-bubble:after {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    border: 8px solid transparent;
    border-top-color: #e9ecef;
    border-left: 0;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}

.message-user .message-header {
    color: rgba(255, 255, 255, 0.9);
}

.message-admin .message-header {
    color: #6c757d;
}

.message-name {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.message-time {
    font-size: 12px;
    opacity: 0.8;
}

.message-content {
    line-height: 1.5;
    font-size: 15px;
}

/* 消息输入区域 */
.message-input-container {
    padding: 20px 30px;
    background: white;
    border-top: 1px solid #e9ecef;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    bottom: 0;
    z-index: 50;
}

.message-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.message-textarea-container {
    flex: 1;
    position: relative;
}

.message-textarea {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 60px;
    max-height: 120px;
    transition: all 0.3s;
    line-height: 1.5;
    background: #f8f9fa;
}

.message-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.message-hint {
    position: absolute;
    bottom: -25px;
    left: 0;
    font-size: 12px;
    color: #6c757d;
    padding: 5px 10px;
}

.send-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    height: 60px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.send-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 错误提示 */
.alert-error {
    position: fixed;
    top: 80px;
    right: 20px;
    background: #fff5f5;
    border: 2px solid #fed7d7;
    color: #c53030;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out, fadeOut 0.3s ease-out 3s forwards;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 300px;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s ease-out;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-icon {
    font-size: 60px;
    color: #28a745;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.modal h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 24px;
}

.modal p {
    color: #6c757d;
    margin: 10px 0 20px;
    line-height: 1.6;
}

.ticket-id-modal {
    font-size: 36px;
    font-weight: bold;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    letter-spacing: 4px;
    border: 2px dashed #667eea;
    background-color: #f8f9fa;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 30px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 150px;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.modal-btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #e9ecef;
}

.modal-btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.warning-note {
    background: #fff3cd;
    border: 2px solid #ffeaa7;
    color: #856404;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 20px;
    text-align: left;
}

.warning-note i {
    color: #ffc107;
    margin-right: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-container {
        border-radius: 0;
    }
    
    .app-header {
        padding: 12px 20px;
        flex-wrap: wrap;
    }
    
    .header-left {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 10px;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .search-container {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    
    .admin-link {
        order: 2;
    }
    
    .ticket-id-display {
        display: none;
    }
    
    .chat-messages {
        padding: 15px 20px;
        min-height: 300px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-user {
        margin-left: 10%;
    }
    
    .message-admin {
        margin-right: 10%;
    }
    
    .message-input-container {
        padding: 15px 20px;
    }
    
    .send-btn {
        padding: 0 20px;
        min-width: 80px;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .ticket-id-modal {
        font-size: 28px;
        letter-spacing: 3px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .instructions {
        grid-template-columns: 1fr;
    }
    
    .message-bubble {
        padding: 10px 15px;
    }
    
    .message-content {
        font-size: 14px;
    }
}

/* 新消息通知样式 */
.new-message-notification {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease-out;
    cursor: pointer;
}

.new-message-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.new-message-notification button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    opacity: 0.7;
}

.new-message-notification button:hover {
    opacity: 1;
}

/* 图片相关样式 */
.message-image {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    margin-top: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
}

.message-image:hover {
    transform: scale(1.02);
}

.upload-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 15px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.upload-btn:hover {
    background: #5a6268;
}

.preview-container {
    display: none;
    margin-top: 10px;
    position: relative;
}

.image-preview {
    max-width: 150px;
    max-height: 150px;
    border-radius: 5px;
    border: 2px solid #e9ecef;
}

.remove-preview {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    position: absolute;
    top: -10px;
    right: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: background 0.3s;
}

.remove-preview:hover {
    background: #c82333;
}

.image-actions {
    margin-top: 5px;
    font-size: 12px;
    color: #6c757d;
}

.image-actions a {
    color: #667eea;
    text-decoration: none;
    margin-right: 10px;
    transition: color 0.3s;
}

.image-actions a:hover {
    color: #5a6fd8;
    text-decoration: underline;
}

.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-image {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.5);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.modal-close:hover {
    transform: scale(1.2);
}

.file-name {
    color: #6c757d;
    font-size: 14px;
    margin-left: 10px;
}

/* 文件上传按钮美化 */
input[type="file"] {
    cursor: pointer;
}

/* 图片上传提示 */
.upload-hint {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .message-image {
        max-width: 200px;
    }
    
    .image-preview {
        max-width: 120px;
    }
    
    .modal-image {
        max-width: 95%;
    }
}