/* Mesme Offline / P2P Mode Stylesheet */

#offlineView {
    --accent: #22c55e;
    --accent-hover: #4ade80;
    --accent-glow: rgba(34, 197, 94, 0.25);
    --accent-gradient: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    
    display: flex;
    height: 100vh;
    width: 100%;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-darkest);
    color: var(--text-normal);
    font-family: inherit;
    overflow: hidden;
}

#offlineView.hidden {
    display: none !important;
}

/* Sidebar */
#offlineSocialSidebar {
    width: 280px;
    height: 100%;
    background: var(--bg-medium);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    backdrop-filter: blur(20px);
    z-index: 20;
}

.offline-sidebar-header {
    height: 52px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
}

.offline-tabs {
    display: flex;
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--glass-border);
}

.offline-tab-btn {
    flex: 1;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.offline-tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-normal);
}

.offline-tab-btn.active {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--accent);
}

.offline-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Category header in channels */
.offline-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 8px 4px 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.offline-category-header button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 4px;
}

.offline-category-header button:hover {
    color: var(--text-normal);
    background: rgba(255, 255, 255, 0.08);
}

/* List items (Peer & Channel) */
.offline-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s ease;
    user-select: none;
}

.offline-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-normal);
}

.offline-nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-normal);
    font-weight: 600;
    border-left: 3px solid var(--accent);
}

.offline-nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-lighter);
    color: var(--text-normal);
    font-weight: bold;
    font-size: 13px;
    flex-shrink: 0;
    position: relative;
}

.offline-nav-status {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-medium);
}

.offline-nav-status.online { background: #22c55e; }
.offline-nav-status.offline { background: #6b7280; }

.offline-nav-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.offline-nav-name {
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-nav-sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-unread-badge {
    background: var(--accent);
    color: #000;
    font-weight: bold;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
}

/* User Controls Bar at bottom of sidebar */
.offline-user-bar {
    padding: 10px 14px;
    background: var(--bg-dark);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.offline-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-lighter);
    font-weight: bold;
}

.offline-user-info {
    flex: 1;
    min-width: 0;
}

.offline-user-name {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-user-id {
    font-size: 10px;
    color: var(--text-muted);
    font-family: monospace;
}

.offline-user-btns {
    display: flex;
    gap: 4px;
}

.offline-btn-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.offline-btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-normal);
}

.offline-btn-icon.active {
    color: #ef4444;
}

/* Voice Call persistent bar */
.offline-voice-bar {
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.1);
    border-top: 1px solid rgba(34, 197, 94, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.offline-voice-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.offline-voice-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: offlinePulse 1.5s infinite;
}

@keyframes offlinePulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Main Chat Container */
#offlineMainContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    background: var(--bg-darkest);
    overflow: hidden;
}

.offline-chat-header {
    height: 52px;
    padding: 0 16px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.offline-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.offline-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Chat Messages */
#offlineMessages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

/* Message Group Bubbles (Matching Main App) */
.offline-msg-row {
    position: relative;
    display: flex;
    gap: 14px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.offline-msg-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.offline-msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    cursor: pointer;
    background: var(--bg-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.offline-msg-body {
    flex: 1;
    min-width: 0;
}

.offline-msg-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.offline-msg-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-normal);
    cursor: pointer;
}

.offline-msg-author:hover {
    text-decoration: underline;
}

.offline-msg-time {
    font-size: 11px;
    color: var(--text-muted);
}

.offline-msg-content {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-normal);
    word-break: break-word;
    white-space: pre-wrap;
}

.offline-msg-content.emoji-only {
    font-size: 32px;
    line-height: 1.2;
}

.offline-msg-content img.emoji {
    width: 20px;
    height: 20px;
    vertical-align: -3px;
    margin: 0 1px;
}

.offline-msg-content.emoji-only img.emoji {
    width: 38px;
    height: 38px;
}

.offline-msg-pinned-tag {
    font-size: 10px;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.offline-msg-reply-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--accent);
}

.offline-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.offline-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.offline-reaction-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.offline-reaction-pill.reacted {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--accent);
}

.offline-reaction-pill img.emoji {
    width: 14px;
    height: 14px;
}

/* Floating Action Bar on Hover */
.offline-floating-actions {
    position: absolute;
    right: 16px;
    top: -12px;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    display: none;
    align-items: center;
    gap: 2px;
    padding: 2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.offline-msg-row:hover .offline-floating-actions {
    display: flex;
}

.offline-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.offline-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-normal);
}

/* Input Area (Rebuilt to match main app) */
.offline-composer-area {
    padding: 10px 16px;
    background: var(--bg-dark);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.offline-composer-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.offline-toolbar-btn {
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: var(--bg-medium);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.offline-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-normal);
}

.offline-composer-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-medium);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.offline-composer-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

#offlineChatInput {
    flex: 1;
    min-height: 24px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-normal);
    outline: none;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 4px 0;
}

#offlineChatInput:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
}

.offline-reply-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(34, 197, 94, 0.08);
    border-left: 3px solid var(--accent);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-normal);
}

.offline-reply-preview-bar button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.offline-attachment-tray {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.offline-attachment-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.offline-attachment-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offline-attachment-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Floating Drawers (Search & Pins) */
.offline-side-drawer {
    position: absolute;
    top: 52px;
    bottom: 0;
    right: 0;
    width: 320px;
    background: var(--bg-medium);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 30;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    animation: slideLeft 0.2s ease;
}

@keyframes slideLeft {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.offline-drawer-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.offline-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.offline-search-input-box {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--bg-dark);
    color: var(--text-normal);
    font-size: 13px;
    outline: none;
}

.offline-search-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.offline-chip {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: pointer;
}

.offline-chip.active {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* GIF Picker for Offline */
#offlineGifPicker {
    position: fixed;
    width: 360px;
    height: 400px;
    background: var(--bg-medium);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.offline-gif-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 8px;
}

.offline-gif-card {
    aspect-ratio: 4/3;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-dark);
}

.offline-gif-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.offline-gif-card:hover img {
    transform: scale(1.05);
}

/* Video Grid Overlay */
#offlineVoiceGrid {
    position: relative;
    width: 100%;
    height: 280px;
    background: #06060c;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
