/* ====================================================================
 * iOS27 液态玻璃 UI 系统 - 全局样式
 * 低饱和柔和渐变、磨砂毛玻璃、大圆角、柔光弥散阴影
 * 所有组件统一风格，弱化AI感，偏向成熟商用客服软件质感
 * ==================================================================== */

/* ============ Reset ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    line-height: 1.5;
    font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img, svg { display: block; max-width: 100%; }

/* ============ 背景渐变（柔和低饱和） ============ */
/* 全局渐变 - 淡雅蓝灰 */
body {
    min-height: 100vh;
    background: linear-gradient(135deg, #e8ecf4 0%, #d4dce8 30%, #d8dee9 60%, #c8d4e3 100%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

/* 背景柔光弥散圆（可通过 data-bg 或 JS 注入不同位置） */
body::before {
    content: '';
    position: fixed;
    top: -20%; left: -10%;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(180,195,220,0.4) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
    filter: blur(40px);
    pointer-events: none;
}
body::after {
    content: '';
    position: fixed;
    bottom: -20%; right: -10%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(200,215,230,0.35) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
    filter: blur(50px);
    pointer-events: none;
}

/* ============ 液态玻璃核心类 ============ */

/* 毛玻璃亚克力基类 */
.glass {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 8px 32px rgba(31, 38, 135, 0.12),
        0 2px 8px rgba(31, 38, 135, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-radius: 24px;
}

/* 较深的玻璃（侧边栏等） */
.glass-dark {
    background: rgba(42, 58, 80, 0.55);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    color: #e8ecf4;
}

/* 轻量玻璃（内嵌小卡片） */
.glass-light {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 18px;
}

/* 半透明毛玻璃输入框风格 */
.glass-input {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    transition: all 0.25s ease;
    outline: none;
}
.glass-input:focus {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(94,140,196,0.5);
    box-shadow: 0 0 0 4px rgba(94,140,196,0.15);
}

/* ============ 按钮系统 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

/* 主按钮 - 柔和蓝色渐变 */
.btn-primary {
    background: linear-gradient(135deg, #7fa8d5, #5e8cc4);
    color: white;
    box-shadow: 0 4px 14px rgba(94,140,196,0.35);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(94,140,196,0.45);
}
.btn-primary:active {
    transform: translateY(0);
}

/* 次要按钮 */
.btn-secondary {
    background: rgba(255,255,255,0.55);
    color: #4a5a6e;
    border: 1px solid rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.8);
}

/* 危险按钮 */
.btn-danger {
    background: linear-gradient(135deg, #e89c9c, #d47878);
    color: white;
    box-shadow: 0 4px 14px rgba(212,120,120,0.3);
}
.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212,120,120,0.4);
}

/* 成功按钮 */
.btn-success {
    background: linear-gradient(135deg, #a4d0b8, #5ea38b);
    color: white;
    box-shadow: 0 4px 14px rgba(94,163,139,0.3);
}
.btn-success:hover { transform: translateY(-1px); }

/* 幽灵按钮（无背景） */
.btn-ghost {
    background: transparent;
    color: #5e8cc4;
    border: 1px solid rgba(94,140,196,0.3);
}
.btn-ghost:hover {
    background: rgba(94,140,196,0.1);
}

/* 尺寸变体 */
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 36px; font-size: 15px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; }

/* 禁用 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ============ 表单系统 ============ */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #4a5a6e;
    margin-bottom: 8px;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=url],
.form-group input[type=tel],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.6);
    border-radius: 14px;
    font-size: 14px;
    color: #2c3e50;
    backdrop-filter: blur(10px);
    transition: all 0.25s ease;
    outline: none;
    box-shadow: 0 2px 8px rgba(31, 38, 135, 0.04);
    font-family: inherit;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    background: rgba(255,255,255,0.9);
    border-color: rgba(94,140,196,0.5);
    box-shadow: 0 0 0 4px rgba(94,140,196,0.12), 0 2px 8px rgba(31, 38, 135, 0.06);
}
.form-group textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}
.form-group .hint {
    font-size: 12px;
    color: #9ba8b8;
    margin-top: 6px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }

/* 复选框 */
.checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.4);
    border-radius: 12px;
    font-size: 13px;
    color: #4a5a6e;
    cursor: pointer;
    transition: all 0.2s;
}
.checkbox-wrap:hover { background: rgba(255,255,255,0.6); }
.checkbox-wrap input[type=checkbox] {
    width: 18px; height: 18px;
    accent-color: #5e8cc4;
    cursor: pointer;
}

/* ============ 标签 / 徽章 ============ */
.tag, .badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}
.tag-primary, .badge-primary {
    background: rgba(127,168,213,0.25);
    color: #4a6fa5;
}
.tag-success, .badge-success {
    background: rgba(152,204,180,0.3);
    color: #3d7a62;
}
.tag-warning, .badge-warning {
    background: rgba(222,193,130,0.3);
    color: #8a6d2a;
}
.tag-danger, .badge-danger {
    background: rgba(232,156,156,0.3);
    color: #a04848;
}
.tag-info, .badge-info {
    background: rgba(165,188,218,0.25);
    color: #3a5a7a;
}
.tag-gray, .badge-gray {
    background: rgba(155,168,184,0.25);
    color: #5a6a7a;
}

/* ============ 状态指示器 ============ */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.8);
}
.status-online { background: #5ea38b; }
.status-busy { background: #d4a843; }
.status-offline { background: #9ba8b8; }
.status-rest { background: #c49bd4; }

/* ============ 卡片系统 ============ */
.card {
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(31,38,135,0.08);
    padding: 24px;
    transition: all 0.25s ease;
}
.card:hover {
    box-shadow: 0 8px 24px rgba(31,38,135,0.12);
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============ 提示框 / 警告 ============ */
.alert {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.6;
    backdrop-filter: blur(20px);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-error {
    background: rgba(232,156,156,0.25);
    border: 1px solid rgba(212,120,120,0.3);
    color: #a04848;
}
.alert-success {
    background: rgba(152,204,180,0.25);
    border: 1px solid rgba(94,163,139,0.3);
    color: #3d7a62;
}
.alert-info {
    background: rgba(165,188,218,0.2);
    border: 1px solid rgba(127,168,213,0.3);
    color: #3a5a7a;
}
.alert-warning {
    background: rgba(222,193,130,0.25);
    border: 1px solid rgba(212,168,67,0.3);
    color: #8a6d2a;
}

/* ============ 模态框 ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(42, 58, 80, 0.4);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}
.modal {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.85);
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(31,38,135,0.25), inset 0 1px 0 rgba(255,255,255,0.9);
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-lg { max-width: 720px; }
.modal-header {
    padding: 22px 28px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.5);
    font-size: 17px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 28px 20px;
    border-top: 1px solid rgba(255,255,255,0.5);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.modal-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(155,168,184,0.2);
    color: #5a6a7a;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}
.modal-close:hover { background: rgba(155,168,184,0.4); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ Toast 轻提示 ============ */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 16px;
    padding: 12px 24px;
    box-shadow: 0 8px 24px rgba(31,38,135,0.15);
    font-size: 14px;
    color: #2c3e50;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}
.toast-success { border-left: 3px solid #5ea38b; }
.toast-error { border-left: 3px solid #d47878; }
.toast-warning { border-left: 3px solid #d4a843; }
.toast-info { border-left: 3px solid #5e8cc4; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ 表格系统 ============ */
.table-wrap {
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 18px;
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.table thead th {
    padding: 14px 18px;
    font-size: 12px;
    font-weight: 600;
    color: #7b8a9e;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(155,168,184,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.5);
}
.table tbody td {
    padding: 14px 18px;
    font-size: 14px;
    color: #2c3e50;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,0.2); }
.table-actions {
    display: flex;
    gap: 8px;
}

/* ============ 分页 ============ */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 0;
    justify-content: center;
    flex-wrap: wrap;
}
.pagination .page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.7);
    color: #4a5a6e;
    font-size: 13px;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.pagination .page-btn:hover {
    background: rgba(255,255,255,0.8);
}
.pagination .page-btn.active {
    background: linear-gradient(135deg, #7fa8d5, #5e8cc4);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(94,140,196,0.3);
}
.pagination .page-info {
    font-size: 13px;
    color: #7b8a9e;
    margin-right: 16px;
}

/* ============ 统计卡片 ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.stat-card {
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 4px 16px rgba(31,38,135,0.08);
    transition: all 0.25s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(31,38,135,0.12);
}
.stat-label {
    font-size: 13px;
    color: #7b8a9e;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: -1px;
}
.stat-trend {
    font-size: 12px;
    margin-top: 6px;
    color: #9ba8b8;
}

/* ============ 聊天气泡 ============ */
.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 20px;
    margin-bottom: 10px;
    position: relative;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.bubble-visitor {
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.9);
    color: #2c3e50;
    border-bottom-left-radius: 6px;
    align-self: flex-start;
}
.bubble-staff {
    background: linear-gradient(135deg, rgba(127,168,213,0.85), rgba(94,140,196,0.85));
    color: white;
    border-bottom-right-radius: 6px;
    align-self: flex-end;
    box-shadow: 0 4px 14px rgba(94,140,196,0.25);
}
.bubble-system {
    background: rgba(155,168,184,0.25);
    color: #7b8a9e;
    text-align: center;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    max-width: 90%;
    align-self: center;
}
.bubble-auto {
    background: rgba(165,188,218,0.3);
    border: 1px dashed rgba(94,140,196,0.4);
    color: #4a6fa5;
    font-style: italic;
    border-bottom-left-radius: 6px;
    align-self: flex-start;
}
.bubble-meta {
    font-size: 11px;
    color: #9ba8b8;
    margin-top: 4px;
    display: block;
}
.bubble-staff .bubble-meta {
    color: rgba(255,255,255,0.7);
}

/* 气泡内图片/视频预览 */
.bubble-media {
    border-radius: 14px;
    overflow: hidden;
    max-width: 260px;
    margin: 4px 0;
    display: block;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.6);
}
.bubble-media img,
.bubble-media video {
    width: 100%;
    height: auto;
    display: block;
}
.bubble-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.3);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.5);
}
.bubble-file .file-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(155,168,184,0.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.bubble-file .file-info { flex: 1; min-width: 0; }
.bubble-file .file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bubble-file .file-size {
    font-size: 11px;
    opacity: 0.7;
}

/* 消息组 */
.message-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}
.message-group.staff { align-items: flex-end; }
.message-group.visitor { align-items: flex-start; }
.message-group.system { align-items: center; }

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(155,168,184,0.35);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(155,168,184,0.55); }

/* ============ Loader ============ */
.loader {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 空状态 ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9ba8b8;
}
.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .glass { border-radius: 20px; }
    .card { padding: 18px; }
    .btn { padding: 8px 16px; font-size: 13px; }
    .btn-lg { padding: 12px 28px; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .chat-bubble { max-width: 85%; }
    .table thead { display: none; }
    .table tbody tr {
        display: block;
        margin-bottom: 12px;
        background: rgba(255,255,255,0.3);
        border-radius: 14px;
        padding: 12px 16px;
    }
    .table tbody td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border-bottom: 1px solid rgba(255,255,255,0.3);
    }
    .table tbody td::before {
        content: attr(data-label);
        font-weight: 500;
        color: #7b8a9e;
        font-size: 12px;
    }
    .table tbody td:last-child { border-bottom: none; }
}
@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
    body::before, body::after { display: none; }
}

/* ============ 通用布局类 ============ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; min-width: 0; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: #7b8a9e; }
.text-primary { color: #5e8cc4; }
.text-success { color: #5ea38b; }
.text-danger { color: #d47878; }
.w-full { width: 100%; }

/* 隐藏文件输入框（用按钮触发） */
.hidden { display: none !important; }
