/* =============================================
   ESP Message Page - Dark Theme Redesign
   Version: 2.0
   ============================================= */

/* === Reset B2 Defaults === */
body.message .b2-single-content.wrapper {
    max-width: 1200px;
    padding: 20px 15px;
}

body.message .site-main.box.b2-radius {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
}

body.message .dmsg-header,
body.message .message-list,
body.message .message-cle {
    display: none !important;
}

/* === Layout === */
.esp-message-layout {
    display: flex;
    min-height: 75vh;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #3a3a3a;
}

/* === Left Sidebar === */
.esp-msg-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #2a2a2a;
    padding: 28px 0;
    border-right: 1px solid #3a3a3a;
}

.esp-msg-sidebar-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    padding: 0 20px;
    margin: 0 0 24px;
    letter-spacing: 0.5px;
}

.esp-msg-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.esp-msg-nav li {
    padding: 13px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #aaa;
    font-size: 14px;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
    border-left: 3px solid transparent;
}

.esp-msg-nav li:hover {
    color: #ddd;
    background: rgba(255,255,255,0.04);
}

.esp-msg-nav li.active {
    color: #e94632;
    background: rgba(233,70,50,0.08);
    border-left-color: #e94632;
    font-weight: 600;
}

.esp-msg-nav li .nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.esp-msg-nav li .nav-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.esp-msg-nav li .nav-label {
    flex: 1;
}

.esp-msg-nav .unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e94632;
    flex-shrink: 0;
}

.esp-msg-nav .unread-count {
    background: #e94632;
    color: #fff;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Sidebar divider */
.esp-msg-nav .nav-divider {
    height: 1px;
    background: #3a3a3a;
    margin: 8px 20px;
    padding: 0;
    cursor: default;
    border: 0;
}

.esp-msg-nav .nav-divider:hover {
    background: #3a3a3a;
}

/* === Main Content Area === */
.esp-msg-main {
    flex: 1;
    background: #333;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.esp-msg-header {
    padding: 18px 24px;
    border-bottom: 1px solid #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.esp-msg-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.esp-msg-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.esp-msg-header-info {
    font-size: 13px;
    color: #888;
}

.esp-msg-header-info .hl {
    color: #e94632;
    font-weight: 600;
}

/* Notice bar */
.esp-msg-notice {
    margin: 16px 24px 0;
    padding: 10px 14px;
    background: rgba(233,70,50,0.06);
    border-radius: 8px;
    border-left: 3px solid #e94632;
}

.esp-msg-notice p {
    font-size: 12px;
    color: #888;
    margin: 2px 0;
    line-height: 1.6;
}

.esp-msg-notice b {
    color: #e94632;
}

/* === Message List === */
.esp-message-list {
    flex: 1;
    overflow-y: auto;
}

.esp-message-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Date group header */
.esp-msg-date-divider {
    padding: 16px 24px 6px;
    font-size: 12px;
    color: #666;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Message item */
.esp-msg-item {
    padding: 14px 24px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s ease;
}

.esp-msg-item:last-child {
    border-bottom: none;
}

.esp-msg-item:hover {
    background: rgba(255,255,255,0.02);
}

.esp-msg-item.unread {
    background: rgba(233,70,50,0.03);
}

.esp-msg-item.unread:hover {
    background: rgba(233,70,50,0.06);
}

/* Avatar */
.esp-msg-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #444;
    display: flex;
    align-items: center;
    justify-content: center;
}

.esp-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.esp-msg-avatar .sys-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e94632 0%, #ff6b5a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.esp-msg-avatar .sys-icon svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

/* Body */
.esp-msg-body {
    flex: 1;
    min-width: 0;
}

.esp-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.esp-msg-type-tag {
    font-size: 11px;
    color: #e94632;
    background: rgba(233,70,50,0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.esp-msg-time {
    font-size: 12px;
    color: #666;
}

.esp-msg-new-badge {
    font-size: 10px;
    color: #fff;
    background: #e94632;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: 0.5px;
    animation: newBadgePulse 2s ease-in-out infinite;
}

@keyframes newBadgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.esp-msg-text {
    font-size: 13.5px;
    color: #ccc;
    line-height: 1.7;
    word-break: break-word;
}

.esp-msg-text a {
    color: #e94632;
    text-decoration: none;
    transition: color 0.15s;
}

.esp-msg-text a:hover {
    color: #ff6b5a;
    text-decoration: underline;
}

/* Empty state */
.esp-msg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #555;
}

.esp-msg-empty svg {
    width: 80px;
    height: 80px;
    fill: #444;
    margin-bottom: 16px;
    opacity: 0.6;
}

.esp-msg-empty p {
    font-size: 14px;
    color: #666;
    margin: 4px 0;
}

/* Loading */
.esp-msg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #888;
    font-size: 14px;
    gap: 8px;
}

.esp-msg-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #555;
    border-top-color: #e94632;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Settings Panel === */
.esp-msg-settings {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
}

.esp-settings-title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 6px;
}

.esp-settings-desc {
    font-size: 13px;
    color: #888;
    margin: 0 0 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid #3a3a3a;
}

.esp-settings-section {
    margin-bottom: 8px;
}

.esp-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    gap: 16px;
}

.esp-setting-item:last-child {
    border-bottom: none;
}

.esp-setting-info {
    flex: 1;
}

.esp-setting-info h4 {
    font-size: 14px;
    font-weight: 500;
    color: #eee;
    margin: 0 0 3px;
}

.esp-setting-info p {
    font-size: 12px;
    color: #777;
    margin: 0;
    line-height: 1.5;
}

/* Toggle switch */
.esp-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.esp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.esp-toggle-track {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #555;
    border-radius: 12px;
    transition: background 0.25s ease;
}

.esp-toggle-track::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.esp-toggle input:checked + .esp-toggle-track {
    background: #e94632;
}

.esp-toggle input:checked + .esp-toggle-track::before {
    transform: translateX(20px);
}

/* === Pagination Override === */
.esp-msg-main .pagenav-new-box {
    padding: 16px 24px;
    border-top: 1px solid #3a3a3a;
}

.esp-msg-main .pagenav-new-box .paged-box a,
.esp-msg-main .pagenav-new-box .paged-box span {
    color: #999 !important;
    background: #444 !important;
    border: 1px solid #555 !important;
    border-radius: 6px !important;
}

.esp-msg-main .pagenav-new-box .paged-box span.current {
    background: #e94632 !important;
    border-color: #e94632 !important;
    color: #fff !important;
}

.esp-msg-main .pagenav-new-box .paged-box a:hover {
    background: #555 !important;
    color: #fff !important;
}

/* === Responsive === */
@media (max-width: 900px) {
    body.message .b2-single-content.wrapper {
        padding: 10px;
    }

    .esp-message-layout {
        flex-direction: column;
        min-height: auto;
    }

    .esp-msg-sidebar {
        width: 100%;
        padding: 16px 0 8px;
        border-right: none;
        border-bottom: 1px solid #3a3a3a;
        border-radius: 12px 12px 0 0;
    }

    .esp-msg-sidebar-title {
        padding: 0 16px;
        margin-bottom: 12px;
        font-size: 15px;
    }

    .esp-msg-nav {
        display: flex;
        overflow-x: auto;
        padding: 0 12px;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .esp-msg-nav::-webkit-scrollbar {
        display: none;
    }

    .esp-msg-nav li {
        padding: 8px 14px;
        white-space: nowrap;
        border-left: none;
        border-radius: 20px;
        font-size: 13px;
        gap: 6px;
    }

    .esp-msg-nav li.active {
        border-left-color: transparent;
        background: rgba(233,70,50,0.15);
    }

    .esp-msg-nav .nav-divider {
        display: none;
    }

    .esp-msg-nav li .nav-icon {
        width: 16px;
        height: 16px;
    }

    .esp-msg-nav li .nav-icon svg {
        width: 14px;
        height: 14px;
    }

    .esp-msg-main {
        border-radius: 0 0 12px 12px;
    }

    .esp-msg-header {
        padding: 14px 16px;
    }

    .esp-msg-item {
        padding: 12px 16px;
    }

    .esp-msg-notice {
        margin: 12px 16px 0;
    }

    .esp-msg-settings {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .esp-msg-header h2 {
        font-size: 14px;
    }

    .esp-msg-header-info {
        display: none;
    }

    .esp-msg-avatar {
        width: 36px;
        height: 36px;
    }

    .esp-msg-avatar .sys-icon {
        width: 36px;
        height: 36px;
    }

    .esp-msg-avatar .sys-icon svg {
        width: 18px;
        height: 18px;
    }

    .esp-msg-text {
        font-size: 13px;
    }
}
.mission-page .custom-page-row b {font-size: 24px;}