@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
    --bg-gradient: #f4f6f9;
    --panel-bg: #ffffff;
    --panel-border: #e9ecef;
    --primary-color: #0A4D8C;
    --primary-glow: rgba(10, 77, 140, 0.15);
    --accent-color: #1A6BB8;
    --success-color: #28A745;
    --warning-color: #FFA500;
    --danger-color: #E63946;
    --text-main: #1A2332;
    --text-support: #6B7785;
    --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.02);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Light clean panel components */
.glass-container {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    box-shadow: var(--card-shadow);
    border-radius: 12px;
}

/* Sidebar Styling (Sleek Light Sidebar) */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-radius: 0;
    background: #ffffff;
    border-right: 1px solid var(--panel-border);
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease, transform 0.35s ease;
    overflow: hidden;
}

/* 迷你 Icon 缩放侧边栏状态 (宽度 76px，保留 Icon 展示) */
body.sidebar-collapsed .sidebar,
.sidebar.collapsed {
    width: 76px !important;
    padding: 24px 10px !important;
    margin-left: 0 !important;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 缩放时隐藏 Logo 文本与内置收起按钮 */
body.sidebar-collapsed .logo-text,
.sidebar.collapsed .logo-text,
body.sidebar-collapsed .sidebar-collapse-btn,
.sidebar.collapsed .sidebar-collapse-btn {
    display: none !important;
}

body.sidebar-collapsed .logo-section,
.sidebar.collapsed .logo-section {
    justify-content: center !important;
    padding-left: 0 !important;
}

/* 缩放时隐藏菜单文字，保留 Icon 居中 */
body.sidebar-collapsed .menu-item span,
.sidebar.collapsed .menu-item span {
    display: none !important;
}

body.sidebar-collapsed .menu-item,
.sidebar.collapsed .menu-item {
    justify-content: center !important;
    padding: 12px 0 !important;
    gap: 0 !important;
    border-left: none !important;
}

body.sidebar-collapsed .menu-item:hover,
.sidebar.collapsed .menu-item:hover,
body.sidebar-collapsed .menu-item.active,
.sidebar.collapsed .menu-item.active {
    background: rgba(10, 77, 140, 0.08) !important;
    border-radius: 10px !important;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #1A6BB8 0%, #0A4D8C 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
    font-family: 'Outfit', sans-serif;
}

.logo-text h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo-text p {
    font-size: 11px;
    color: var(--text-support);
    letter-spacing: 1px;
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-support);
    transition: all 0.2s ease;
    font-weight: 500;
}

.menu-item:hover, .menu-item.active {
    color: var(--primary-color);
    background: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding-left: 12px;
}

.menu-item.active {
    background: rgba(10, 77, 140, 0.06);
    font-weight: 600;
}

.menu-item svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* Main Content Area */
.main-wrapper {
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    min-width: 0;
    flex-grow: 1;
    padding: 30px;
    min-height: 100vh;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    box-sizing: border-box;
}

/* 当侧边栏缩放为迷你 Icon 模式时，主视图调整左边距与可视宽度 */
body.sidebar-collapsed .main-wrapper,
.main-wrapper.full-width {
    margin-left: 76px !important;
    width: calc(100% - 76px) !important;
    max-width: calc(100% - 76px) !important;
}

/* Top bar navigation */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 16px 24px;
    background: #ffffff;
}

/* 导航栏显隐开关按钮（ Header 栏纯 Icon 按钮设计） */
.sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1A6BB8 0%, #0A4D8C 100%);
    border: none;
    color: #ffffff !important;
    cursor: pointer;
    margin-right: 14px;
    box-shadow: 0 2px 8px rgba(10, 77, 140, 0.25);
    transition: all 0.25s ease;
    z-index: 10;
}

.sidebar-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(10, 77, 140, 0.35);
    opacity: 0.95;
}

.sidebar-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* 侧边栏 Logo 区域内部快捷收起按钮 */
.sidebar-collapse-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #f0f4f8;
    border: 1px solid #e2e8f0;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-collapse-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.page-title h2 {
    font-size: 22px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: #111528;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-wrapper img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    object-fit: cover;
}

.admin-info .name {
    font-weight: 600;
    font-size: 14px;
    color: #111528;
}

.admin-info .role {
    font-size: 11px;
    color: var(--text-support);
}

/* Dashboard Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #ffffff;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
}

.metric-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-support);
    font-size: 14px;
    margin-bottom: 12px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: #111528;
    margin-bottom: 6px;
}

.metric-card .icon-holder {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

/* Dynamic Content Section */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Generic Tables */
.table-card {
    padding: 24px;
    margin-bottom: 30px;
    background: #ffffff;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #111528;
}

.btn-primary {
    background: linear-gradient(135deg, #1A6BB8 0%, #0A4D8C 100%);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(10, 77, 140, 0.2);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(10, 77, 140, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f8f9fa;
    border: 1px solid #ced4da;
    color: #495057;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #e2e6ea;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 14px 16px;
    color: #495057;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--panel-border);
    font-weight: 600;
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
    font-size: 14px;
    color: #495057;
}

.data-table tr:hover {
    background: #fdfdfd;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge-success { background: rgba(40, 167, 69, 0.1); color: var(--success-color); }
.badge-warning { background: rgba(255, 165, 0, 0.1); color: var(--warning-color); }
.badge-danger { background: rgba(230, 57, 70, 0.1); color: var(--danger-color); }

/* Forms & Dialogs styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    width: 500px;
    max-width: 90%;
    padding: 30px;
    background: #ffffff;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-support);
    font-size: 13px;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 12px;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary-color);
}

/* IM Customer Center split view */
.im-split-view {
    display: flex;
    height: calc(100vh - 200px);
    gap: 20px;
    background: #ffffff;
}

.im-conversations-list {
    width: 320px;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid var(--panel-border);
}

.conv-search {
    padding: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.conv-scroll {
    overflow-y: auto;
    flex-grow: 1;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
    transition: background 0.2s;
}

.conv-item:hover, .conv-item.active {
    background: #f8f9fa;
}

.conv-item.active {
    border-left: 4px solid var(--primary-color);
}

.partner-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.conv-detail {
    flex-grow: 1;
    min-width: 0;
}

.conv-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conv-name {
    font-weight: 600;
    font-size: 14px;
    color: #111528;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--text-support);
}

.conv-last-msg {
    font-size: 12px;
    color: var(--text-support);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-badge {
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

.im-chat-window {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-messages-area {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
}

.chat-bubble {
    max-width: 65%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-bubble.sent {
    align-self: flex-end;
}

.chat-bubble.received {
    align-self: flex-start;
}

.bubble-content {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
}

.chat-bubble.sent .bubble-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-bubble.received .bubble-content {
    background: #ffffff;
    color: #212529;
    border-bottom-left-radius: 2px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.bubble-time {
    font-size: 10px;
    color: var(--text-support);
    align-self: flex-end;
}

.chat-input-bar {
    padding: 16px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    gap: 12px;
    background: #ffffff;
}

.chat-input-bar input {
    flex-grow: 1;
}

.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-support);
    gap: 12px;
}
.no-chat-selected svg {
    width: 60px;
    height: 60px;
    stroke: var(--text-support);
    opacity: 0.5;
}

/* ========================================================= */
/* Responsive Media Queries (响应式自适应布局) */
/* ========================================================= */

.mobile-menu-toggle {
    display: none;
}

/* 1. 平板与移动端 (<= 992px) */
@media screen and (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 999;
        display: none;
        animation: fadeIn 0.2s ease;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .main-wrapper {
        margin-left: 0 !important;
        padding: 16px !important;
        width: 100% !important;
    }

    .header-bar {
        padding: 12px 16px;
        margin-bottom: 16px;
    }

    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        border-radius: 8px;
        background: #f0f4f8;
        border: none;
        font-size: 20px;
        color: var(--primary-color);
        cursor: pointer;
        margin-right: 12px;
    }

    .im-split-view {
        flex-direction: column;
        height: auto;
        min-height: 500px;
    }

    .im-conversations-list {
        width: 100% !important;
        height: 220px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--panel-border);
    }

    .im-chat-window {
        height: 450px !important;
    }
}

/* 2. 手机窄屏 (<= 576px) */
@media screen and (max-width: 576px) {
    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .card-title {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .card-title > div, .card-title > button {
        align-self: flex-start;
    }

    .table-card {
        padding: 14px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 680px;
    }

    .admin-info {
        display: none;
    }

    .modal-content {
        width: 92% !important;
        padding: 20px !important;
    }
}

/* ==================================================
   全局数据表格横向滚动条与右侧固定操作列通用标准规范
   ================================================== */
.snk-table-scroll-wrapper {
    overflow-x: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #ffffff;
    margin-top: 15px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.snk-table-scroll-wrapper::-webkit-scrollbar {
    height: 10px !important;
    display: block !important;
}

.snk-table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f3f4 !important;
    border-radius: 5px;
}

.snk-table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #1a73e8 !important;
    border-radius: 5px;
}

.snk-table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #0f4ba3 !important;
}

.sticky-right-header {
    position: sticky !important;
    right: 0 !important;
    z-index: 12 !important;
    background: #f8f9fa !important;
    border-left: 1px solid #e0e0e0 !important;
    box-shadow: -4px 0 10px rgba(0,0,0,0.06) !important;
    padding: 10px 14px !important;
    box-sizing: border-box !important;
}

.sticky-right-col {
    position: sticky !important;
    right: 0 !important;
    z-index: 10 !important;
    background: #ffffff !important;
    border-left: 1px solid #e0e0e0 !important;
    box-shadow: -4px 0 10px rgba(0,0,0,0.06) !important;
    padding: 10px 14px !important;
    box-sizing: border-box !important;
}

tr:hover .sticky-right-col {
    background-color: #f8f9fa !important;
}
