/**
 * WhatsApp 多账号管理系统 - 主样式表
 */

/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== 按钮样式 ==================== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-success {
    background: #25D366;
    color: white;
}

.btn-success:hover {
    background: #20BA5A;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ==================== 头部导航 ==================== */
.header {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #25D366;
    font-size: 28px;
    margin-bottom: 4px;
}

.subtitle {
    color: #666;
    font-size: 14px;
}

.header-right {
    display: flex;
    gap: 12px;
}

/* ==================== 统计卡片 ==================== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

.stat-label {
    color: #666;
    font-size: 14px;
}

/* ==================== 账号列表 ==================== */
.accounts-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.section-title {
    font-size: 20px;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f2f5;
}

.accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.account-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.account-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.account-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fafafa;
}

.account-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.account-phone {
    font-size: 13px;
    color: #666;
}

.account-status {
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-connected {
    background: #d4edda;
    color: #155724;
}

.status-qrcode {
    background: #fff3cd;
    color: #856404;
}

.status-pending {
    background: #d1ecf1;
    color: #0c5460;
}

.status-disconnected {
    background: #f8d7da;
    color: #721c24;
}

/* ==================== 二维码区域 ==================== */
.qrcode-section {
    padding: 24px;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.qrcode-tip {
    color: #666;
    margin-bottom: 16px;
    font-size: 14px;
}

.qrcode-wrapper {
    background: white;
    padding: 20px;
    border-radius: 12px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}

.qrcode-canvas canvas {
    display: block;
    border-radius: 8px;
}

.qrcode-steps {
    text-align: left;
    display: inline-block;
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 12px;
}

.qrcode-steps p {
    margin-bottom: 8px;
    color: #333;
}

.qrcode-steps ol {
    margin-left: 20px;
    color: #666;
    font-size: 13px;
}

.qrcode-steps li {
    margin-bottom: 4px;
}

/* ==================== 账号底部 ==================== */
.account-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.account-time {
    font-size: 12px;
    color: #999;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    color: #333;
    margin-bottom: 8px;
}

.empty-state p {
    color: #666;
    margin-bottom: 20px;
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: white;
    width: 90%;
    max-width: 500px;
    margin: 60px auto;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== 表单样式 ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #25D366;
}

.form-text {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #999;
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    margin-top: 16px;
    font-size: 14px;
}

/* ==================== 消息页面样式 ==================== */
.messages-page {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.top-navbar {
    height: 60px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
}

.back-btn:hover {
    text-decoration: underline;
}

.top-navbar h1 {
    font-size: 20px;
    color: #333;
}

.current-account-badge {
    background: #25D366;
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.messages-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    width: 360px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.account-selector {
    padding: 16px;
    border-bottom: 2px solid #25D366;
    background: #fafafa;
}

.account-selector label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.customers-list {
    flex: 1;
    overflow-y: auto;
}

.empty-customers {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.customer-item {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.customer-item:hover {
    background: #f5f5f5;
}

.customer-item.active {
    background: #e8f5e9;
}

.customer-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    flex-shrink: 0;
}

.customer-info {
    flex: 1;
    min-width: 0;
}

.customer-name {
    font-size: 15px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unread-badge {
    background: #25D366;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}

.customer-last-message {
    font-size: 13px;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-time {
    font-size: 11px;
    color: #999;
    flex-shrink: 0;
}

/* ==================== 聊天区域 ==================== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e5ddd5;
}

.chat-header {
    height: 60px;
    background: #25D366;
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.chat-info h3 {
    font-size: 16px;
    margin-bottom: 2px;
}

.chat-info p {
    font-size: 12px;
    opacity: 0.9;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-messages {
    text-align: center;
    padding: 40px;
    color: #666;
}

.message {
    margin-bottom: 16px;
    display: flex;
}

.message-in {
    justify-content: flex-start;
}

.message-out {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 60%;
    padding: 8px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message-in .message-bubble {
    background: white;
    border-radius: 8px 8px 8px 2px;
}

.message-out .message-bubble {
    background: #dcf8c6;
    border-radius: 8px 8px 2px 8px;
}

.message-content {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

.message-image {
    max-width: 100%;
    border-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.chat-input {
    height: 60px;
    background: #f0f0f0;
    padding: 10px 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
}

.chat-input button {
    padding: 10px 24px;
    background: #25D366;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 500;
}

.chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.no-customer-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
}

.no-customer-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.no-customer-selected h3 {
    color: #333;
    margin-bottom: 8px;
}

.no-customer-selected p {
    color: #666;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .accounts-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 100%;
        max-width: 300px;
    }

    .message-bubble {
        max-width: 80%;
    }
}

