/* ═══════════════════════════════════════════════
   PIXEL BATTLE EVENT
   ═══════════════════════════════════════════════ */

/* ── Event Tab Layout ───────────────────────── */
.event-content {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
}
.event-content.active {
    display: flex;
}

.event-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.event-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}
.event-header .event-stats {
    display: flex;
    gap: 16px;
    margin-left: auto;
    align-items: center;
}
.event-stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.event-stat-item i {
    color: var(--accent);
}
#pxp-balance {
    font-weight: 600;
    color: #FFD700;
}
#pixel-cooldown {
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s;
}
#pixel-cooldown.active {
    color: #EF4444;
}

/* ── Canvas Container ───────────────────────── */
.pixel-canvas-wrap {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}
#pixel-canvas-container {
    flex: 1;
    overflow: hidden;
    touch-action: none;
    cursor: crosshair;
    position: relative;
}
#pixel-svg {
    display: block;
}
.pixel-rect {
    transition: fill 0.15s ease;
}

/* ── Selection highlight ───────────────────── */
.selection-rect {
    animation: selection-pulse 1s ease-in-out infinite;
}
@keyframes selection-pulse {
    0%, 100% { stroke-opacity: 1; stroke-width: 2; }
    50% { stroke-opacity: 0.4; stroke-width: 1.5; }
}

/* ── Pixel Info Popup ──────────────────────── */
.pixel-info-popup {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    pointer-events: none;
    display: flex;
    align-items: center;
}
.pixel-info-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
}
.pixel-info-color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}
.pixel-info-user {
    font-weight: 600;
    color: var(--accent);
}
.pixel-info-time {
    color: var(--text-secondary);
    font-size: 12px;
}
.pixel-info-coords {
    color: var(--text-tertiary);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}
.pixel-info-empty {
    color: var(--text-secondary);
    font-style: italic;
}

/* ── Confirm Bar ───────────────────────────── */
.pixel-confirm-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.pixel-confirm-bar .btn-primary {
    background: #22C55E;
    border-color: #22C55E;
}
.pixel-confirm-bar .btn-primary:hover {
    background: #16A34A;
}
.pixel-confirm-bar .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.pixel-confirm-bar .btn-secondary:hover {
    background: var(--bg-hover);
}

/* ── Color Picker Panel ─────────────────────── */
.pixel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}
#pixel-color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-width: 600px;
}
.px-color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.px-color-swatch:hover {
    transform: scale(1.2);
    z-index: 1;
}
.px-color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--accent);
    transform: scale(1.15);
}

.pixel-toolbar-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}

/* ── Zoom Controls ──────────────────────────── */
.zoom-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}
.zoom-controls .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

/* ═══════════════════════════════════════════════
   PXP SHOP
   ═══════════════════════════════════════════════ */
.shop-items {
    padding: 16px;
}
.shop-balance {
    font-size: 18px;
    font-weight: 600;
    color: #FFD700;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 8px;
}
.shop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    border: 1px solid var(--border-color);
}
.shop-item:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}
.shop-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.shop-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}
.shop-item-info {
    flex: 1;
    min-width: 0;
}
.shop-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.shop-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.shop-item-cost {
    font-weight: 600;
    color: #FFD700;
    font-size: 14px;
    white-space: nowrap;
}
.shop-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px;
}
.shop-role-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 14px;
}
.shop-role-item .btn-icon {
    margin-left: auto;
}

/* ═══════════════════════════════════════════════
   USER PROFILE
   ═══════════════════════════════════════════════ */
.profile-body {
    max-height: 80vh;
    overflow-y: auto;
}
.profile-banner {
    height: 140px;
    border-radius: var(--radius) var(--radius) 0 0;
    background-size: cover;
    background-position: center;
}
.profile-header {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 0 20px;
    margin-top: -40px;
    position: relative;
    z-index: 1;
}
.profile-avatar {
    flex-shrink: 0;
}
.profile-avatar .avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid var(--bg-primary);
    object-fit: cover;
}
.profile-avatar .avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 28px;
    border: 4px solid var(--bg-primary);
}
.profile-info {
    padding-bottom: 8px;
}
.profile-username {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}
.profile-handle {
    font-size: 13px;
    color: var(--text-secondary);
}
.profile-admin-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    vertical-align: middle;
}
.profile-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px 0;
}
.profile-role-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 9999px;
    border: 1px solid;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.profile-bio {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}
.profile-no-bio {
    color: var(--text-tertiary);
    font-style: italic;
}
.profile-stats {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.profile-stat {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
}
.profile-stat + .profile-stat {
    border-left: 1px solid var(--border-color);
}
.profile-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.profile-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.profile-footer {
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-secondary);
}
.profile-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px 16px;
}
.profile-actions .btn-sm {
    font-size: 13px;
    padding: 6px 14px;
}

/* ═══════════════════════════════════════════════
   DIRECT MESSAGES
   ═══════════════════════════════════════════════ */

/* DM Sidebar */
.dm-sidebar {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.dm-sidebar.active {
    display: flex;
}
.dm-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}
.dm-sidebar-header .sidebar-title {
    flex: 1;
}

/* DM Content Area */
.dm-content {
    display: none;
    flex: 1;
    height: 100%;
    overflow: hidden;
}
.dm-content.active {
    display: flex;
}
#dm-panel {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
}
.dm-conversations-col {
    width: 300px;
    min-width: 260px;
    border-right: 1px solid var(--border-color);
    display: none; /* Hidden on desktop — sidebar shows conversations */
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-secondary);
}
.dm-conversations-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
#dm-conversation-list {
    flex: 1;
    overflow-y: auto;
}
.dm-conv-item {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.dm-conv-item:hover {
    background: var(--bg-hover);
}
.dm-conv-item.active {
    background: var(--bg-tertiary);
}
.dm-conv-avatar {
    flex-shrink: 0;
}
.dm-conv-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.dm-conv-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.dm-conv-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-conv-time {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
}
.dm-conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.dm-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    margin-left: 4px;
}

/* DM Chat Area — uses same layout as room chat */
.dm-chat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.dm-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
#dm-partner-name {
    font-weight: 600;
    font-size: 15px;
}
/* DM messages-container mirrors #messages-container */
#dm-messages-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
}
#dm-messages {
    padding: 16px;
    display: flex;
    flex-direction: column;
}
/* DM uses same message-group / msg-continuation classes as room chat — no extra styles needed */

/* DM input bar uses .input-bar class from main.css — just needs positioning */
#dm-input-bar {
    flex-shrink: 0;
}
/* DM new-msg-btn positioning */
#dm-new-msg-btn {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}
#dm-chat-area {
    position: relative;
}

/* DM Empty states */
.dm-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    text-align: center;
}
.dm-empty i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 16px;
}
.dm-empty p {
    margin: 0;
}
.dm-empty-hint {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 8px;
}
#dm-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
#dm-chat-area {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Sidebar DM badge */
.sidebar-nav-tab .nav-badge {
    display: none;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}
.sidebar-nav-tab .nav-badge.visible {
    display: inline-flex;
}

/* ── Event Sidebar ──────────────────────────── */
.event-sidebar {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.event-sidebar.active {
    display: flex;
}
.event-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .dm-conversations-col {
        display: flex; /* Show on mobile */
        width: 100%;
        min-width: 0;
    }
    #dm-panel.chat-open .dm-conversations-col {
        display: none;
    }
    #dm-panel.chat-open .dm-chat-col {
        display: flex;
    }
    .dm-chat-col {
        display: none;
    }
    .dm-chat-header .btn-dm-back {
        display: inline-flex;
    }

    .pixel-toolbar {
        flex-wrap: wrap;
        padding: 8px 12px;
    }
    #pixel-color-picker {
        max-width: 100%;
    }
    .px-color-swatch {
        width: 20px;
        height: 20px;
    }

    .profile-banner { height: 100px; }
    .profile-header { gap: 12px; padding: 0 16px; margin-top: -30px; }
    .profile-avatar .avatar-lg,
    .profile-avatar .avatar-placeholder { width: 60px; height: 60px; font-size: 22px; }
    .profile-username { font-size: 17px; }
}
