/* =========================================================
   Final dark mode polish v14.3
   This file is loaded last and only overrides dark-mode issues.
   ========================================================= */

body.dark-mode {
    --bg: #070d18;
    --surface: #111b2d;
    --surface-soft: #17243a;
    --surface-accent: #1d2c47;
    --line: #31415e;
    --line-strong: #50658a;
    --text: #eef4ff;
    --muted: #aebbd0;
    --brand: #6f7cff;
    --brand-dark: #aeb8ff;
    --danger-soft: rgba(214, 73, 73, 0.14);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
    background:
        radial-gradient(circle at top left, rgba(111, 124, 255, 0.10), transparent 28%),
        linear-gradient(180deg, #050a13 0%, #0b1220 100%) !important;
    color: var(--text) !important;
}

body.dark-mode * {
    scrollbar-color: #31415e #0b1220;
}

body.dark-mode a,
body.dark-mode .text-link,
body.dark-mode .block-head a,
body.dark-mode .secondary-link,
body.dark-mode .subbar-right a {
    color: #9eabff !important;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode strong,
body.dark-mode label span,
body.dark-mode .brand-text,
body.dark-mode .brand-text span,
body.dark-mode .user-chip-name,
body.dark-mode .name-row,
body.dark-mode .directory-body,
body.dark-mode .profile-name-line h2,
body.dark-mode .admin-dashboard-copy h2,
body.dark-mode .admin-album-head h2,
body.dark-mode .messages-sidebar-head h1,
body.dark-mode .messages-thread-user strong,
body.dark-mode .message-conversation-title strong {
    color: var(--text) !important;
}

body.dark-mode p,
body.dark-mode small,
body.dark-mode .meta-row,
body.dark-mode .muted-copy,
body.dark-mode .section-intro,
body.dark-mode .feature-caption span,
body.dark-mode .admin-meta,
body.dark-mode .admin-description,
body.dark-mode .admin-dashboard-copy p:not(.eyebrow),
body.dark-mode .message-conversation-copy p,
body.dark-mode .message-conversation-title small,
body.dark-mode .messages-thread-user small,
body.dark-mode .messages-empty,
body.dark-mode .messages-thread-empty,
body.dark-mode .info-row span,
body.dark-mode .profile-quick-meta,
body.dark-mode .profile-quick-bio {
    color: var(--muted) !important;
}

/* Global cards */
body.dark-mode .site-header,
body.dark-mode .section-hero,
body.dark-mode .highlight-card,
body.dark-mode .promo-vertical,
body.dark-mode .rail-block,
body.dark-mode .side-widget,
body.dark-mode .composer-panel,
body.dark-mode .feed-card,
body.dark-mode .media-card,
body.dark-mode .profile-card,
body.dark-mode .match-card,
body.dark-mode .story-card,
body.dark-mode .video-card,
body.dark-mode .profile-top,
body.dark-mode .profile-info-card,
body.dark-mode .profile-form-card,
body.dark-mode .directory-card,
body.dark-mode .directory-hero,
body.dark-mode .settings-page-card,
body.dark-mode .settings-card-block,
body.dark-mode .album-upload-dropzone-card,
body.dark-mode .album-upload-main-card,
body.dark-mode .album-detail-gallery,
body.dark-mode .album-detail-summary,
body.dark-mode .album-detail-preview-card,
body.dark-mode .album-owner-strip,
body.dark-mode .album-comments-wrap,
body.dark-mode .related-content-card,
body.dark-mode .messages-sidebar,
body.dark-mode .messages-thread-panel,
body.dark-mode .messages-shell,
body.dark-mode .admin-empty-state,
body.dark-mode .admin-album-card,
body.dark-mode .admin-dashboard-card,
body.dark-mode .admin-modal-panel,
body.dark-mode .admin-report-card,
body.dark-mode .admin-report-preview,
body.dark-mode .admin-detail-card,
body.dark-mode .search-modal-panel,
body.dark-mode .auth-panel,
body.dark-mode .modal-backdrop + .auth-modal .auth-panel {
    background: rgba(17, 27, 45, 0.96) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
    box-shadow: var(--shadow) !important;
}

body.dark-mode .topbar,
body.dark-mode .subbar {
    background: rgba(17, 27, 45, 0.60) !important;
    border-color: var(--line) !important;
}

body.dark-mode .subbar {
    background: rgba(13, 21, 35, 0.86) !important;
}

/* Right rail and recommendations */
body.dark-mode .right-recommendation-item,
body.dark-mode .online-friend-row,
body.dark-mode .visit-item,
body.dark-mode .notification-item,
body.dark-mode .notification-empty,
body.dark-mode .profile-albums-empty,
body.dark-mode .album-empty-state,
body.dark-mode .album-status-note,
body.dark-mode .message-conversation-item,
body.dark-mode .friend-request-row,
body.dark-mode .info-row,
body.dark-mode .video-placeholder-card,
body.dark-mode .verified-status-box,
body.dark-mode .toast,
body.dark-mode .settings-block,
body.dark-mode .upload-photo-card,
body.dark-mode .album-dropzone,
body.dark-mode .message-media-preview,
body.dark-mode .message-media-preview-card {
    background: rgba(24, 36, 58, 0.96) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

body.dark-mode .messages-conversation-item:hover,
body.dark-mode .messages-conversation-item.active,
body.dark-mode .user-dropdown-item:hover,
body.dark-mode .user-dropdown-item.active,
body.dark-mode .tab-btn.active,
body.dark-mode .pill.active {
    background: rgba(111, 124, 255, 0.20) !important;
    color: #eef4ff !important;
}

/* Forms */
body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select,
body.dark-mode .search-chip,
body.dark-mode .search-modal-input,
body.dark-mode .messages-search,
body.dark-mode .composer-input,
body.dark-mode .field input,
body.dark-mode .field textarea,
body.dark-mode .message-compose textarea,
body.dark-mode .upload-photo-caption {
    background: rgba(20, 31, 50, 0.98) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
    box-shadow: none !important;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #8391ab !important;
}

body.dark-mode .radio-line,
body.dark-mode .checkbox-line,
body.dark-mode .theme-grid label {
    color: #d7e1f3 !important;
}

body.dark-mode input[type="checkbox"],
body.dark-mode input[type="radio"] {
    accent-color: #7d8cff;
}

/* Buttons and pills */
body.dark-mode .ghost-btn,
body.dark-mode .icon-only,
body.dark-mode .icon-btn,
body.dark-mode .tab-btn,
body.dark-mode .pill,
body.dark-mode .album-stat-pill,
body.dark-mode .mini-btn,
body.dark-mode .message-emoji-button,
body.dark-mode .small-icon-btn {
    background: rgba(25, 39, 64, 0.98) !important;
    color: #dfe7ff !important;
    border-color: var(--line) !important;
}

body.dark-mode .primary-btn,
body.dark-mode .message-send-button,
body.dark-mode .auth-submit {
    background: linear-gradient(135deg, #6472ff, #8d99ff) !important;
    color: #fff !important;
    border-color: transparent !important;
}

body.dark-mode .vip-card {
    background: linear-gradient(135deg, rgba(108, 82, 23, 0.96), rgba(35, 45, 68, 0.96)) !important;
    border-color: rgba(255, 213, 92, 0.34) !important;
}

body.dark-mode .vip-card h3,
body.dark-mode .vip-card p,
body.dark-mode .promo-vertical h2,
body.dark-mode .promo-vertical p {
    color: var(--text) !important;
}

/* User chip / avatars / images */
body.dark-mode .user-chip,
body.dark-mode .user-dropdown,
body.dark-mode .notification-panel {
    background: rgba(18, 29, 48, 0.99) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

body.dark-mode .user-chip-avatar,
body.dark-mode .message-avatar,
body.dark-mode .notification-avatar,
body.dark-mode .online-friend-row img,
body.dark-mode .online-friend-row span,
body.dark-mode .right-recommendation-item img,
body.dark-mode .profile-avatar-large,
body.dark-mode .directory-avatar,
body.dark-mode .album-comment-avatar,
body.dark-mode .album-liker-avatar {
    background: linear-gradient(135deg, #5968e8, #8794ff) !important;
    color: #fff !important;
    opacity: 1 !important;
    filter: none !important;
    mix-blend-mode: normal !important;
}

body.dark-mode img,
body.dark-mode .avatar-photo,
body.dark-mode .feature-tile,
body.dark-mode .thumb-card,
body.dark-mode .post-preview,
body.dark-mode .media-thumb,
body.dark-mode .profile-album-card img,
body.dark-mode .right-recommendation-item img,
body.dark-mode .message-media-image,
body.dark-mode .message-media-video,
body.dark-mode .album-detail-main-photo,
body.dark-mode .album-detail-thumb img,
body.dark-mode .upload-photo-thumb-wrap img {
    opacity: 1 !important;
    filter: none !important;
    mix-blend-mode: normal !important;
}

body.dark-mode .user-chip-avatar img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Messages */
body.dark-mode .messages-list,
body.dark-mode .chat-dock-body {
    background: linear-gradient(180deg, rgba(10, 18, 31, 0.96), rgba(13, 22, 38, 0.96)) !important;
}

body.dark-mode .message-bubble-row.theirs .message-bubble {
    background: rgba(27, 41, 66, 0.98) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

body.dark-mode .message-bubble-row.mine .message-bubble {
    background: linear-gradient(135deg, #5e6bf2, #8794ff) !important;
    color: #fff !important;
}

body.dark-mode .message-compose,
body.dark-mode .chat-dock-head,
body.dark-mode .messages-thread-head,
body.dark-mode .messages-sidebar-head {
    background: rgba(16, 26, 44, 0.98) !important;
    border-color: var(--line) !important;
}

body.dark-mode .message-emoji-popover {
    background: rgba(18, 29, 48, 0.99) !important;
    border-color: var(--line) !important;
}

body.dark-mode .message-emoji-popover button {
    background: rgba(26, 40, 64, 0.98) !important;
    color: var(--text) !important;
}

/* Critical: minimized chat must not leave a giant rectangle behind it */
.chat-dock.minimized .chat-dock-panel {
    grid-template-rows: auto !important;
    transform: none !important;
}

.chat-dock.minimized .chat-dock-body {
    display: none !important;
}

.chat-dock.open .chat-dock-panel {
    grid-template-rows: auto minmax(0, 430px) !important;
    transform: translateY(0) !important;
}

.chat-dock.open .chat-dock-body {
    display: block !important;
}

body.dark-mode .chat-dock-panel {
    background: rgba(17, 27, 45, 0.99) !important;
    border: 1px solid var(--line) !important;
    box-shadow: 0 18px 45px rgba(0,0,0,.42) !important;
}

body.dark-mode .chat-dock.minimized .chat-dock-panel {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.dark-mode .chat-dock.minimized .chat-dock-head {
    background: rgba(17, 27, 45, 0.99) !important;
    border: 1px solid var(--line) !important;
    border-radius: 24px 24px 0 0 !important;
    box-shadow: 0 18px 45px rgba(0,0,0,.34) !important;
}

/* Album upload */
body.dark-mode .album-dropzone-empty,
body.dark-mode .settings-title-row,
body.dark-mode .settings-title-row strong,
body.dark-mode .settings-title-row small,
body.dark-mode .album-upload-count,
body.dark-mode .upload-progress-inner,
body.dark-mode .upload-progress-inner span {
    color: var(--text) !important;
}

body.dark-mode .upload-progress-inner {
    background: rgba(16, 26, 44, 0.98) !important;
}

body.dark-mode .upload-photo-actions {
    background: rgba(17, 27, 45, .94) !important;
    border-color: var(--line) !important;
}

/* Admin */
body.dark-mode .admin-dashboard-card.disabled {
    opacity: .55 !important;
}

body.dark-mode .admin-dashboard-count,
body.dark-mode .admin-status,
body.dark-mode .admin-report-type,
body.dark-mode .report-status-pill {
    background: rgba(111, 124, 255, 0.16) !important;
    color: #dfe7ff !important;
}

body.dark-mode .danger-admin-btn,
body.dark-mode .user-dropdown-item.danger {
    color: #ff9aa5 !important;
}

body.dark-mode .admin-photo-thumb {
    background: rgba(24, 36, 58, 0.96) !important;
    border-color: var(--line) !important;
}

/* Light panels that were causing flashbang */
body.dark-mode .search-empty,
body.dark-mode .album-comment-item,
body.dark-mode .album-liker-item,
body.dark-mode .message-thread-placeholder,
body.dark-mode .admin-confirm-actions,
body.dark-mode .auth-footer-note,
body.dark-mode .form-message,
body.dark-mode .field,
body.dark-mode .feature-caption,
body.dark-mode .post-actions button {
    color: var(--text) !important;
}

/* Keep status dots visible */
body.dark-mode .status-dot,
body.dark-mode .visit-badge,
body.dark-mode .online-dot-badge::before {
    filter: none !important;
}

/* =========================================================
   Hotfix v14.4: album detail + floating chat clean dark mode
   Loaded last in CSS order.
   ========================================================= */
body.dark-mode .album-detail-v5 .album-profile-strip,
body.dark-mode .album-detail-v5 .album-unified-card {
    background: rgba(17, 27, 45, 0.98) !important;
    border-color: #31415e !important;
    color: #eef4ff !important;
    box-shadow: 0 22px 55px rgba(0, 0, 0, .38) !important;
}

body.dark-mode .album-detail-v5 .album-unified-card h1,
body.dark-mode .album-detail-v5 .album-unified-card h2,
body.dark-mode .album-detail-v5 .album-unified-card h3,
body.dark-mode .album-detail-v5 .album-unified-card strong,
body.dark-mode .album-detail-v5 .album-profile-strip strong,
body.dark-mode .album-detail-v5 .album-title-block h1,
body.dark-mode .album-detail-v5 .album-title-block .eyebrow {
    color: #f2f6ff !important;
    opacity: 1 !important;
}

body.dark-mode .album-detail-v5 .album-title-block p,
body.dark-mode .album-detail-v5 .album-strip-meta small,
body.dark-mode .album-detail-v5 .album-photo-caption,
body.dark-mode .album-detail-v5 .album-photo-caption.is-empty {
    color: #aebbd0 !important;
    opacity: 1 !important;
}

body.dark-mode .album-detail-v5 .album-photo-caption {
    background: rgba(24, 36, 58, 0.98) !important;
    border-color: #31415e !important;
}

body.dark-mode .album-detail-v5 .album-stat-pill {
    background: rgba(25, 39, 64, 0.98) !important;
    border-color: #31415e !important;
    color: #dfe7ff !important;
}

body.dark-mode .album-detail-v5 .album-stat-pill i,
body.dark-mode .album-detail-v5 .album-stat-pill span {
    color: #dfe7ff !important;
}

body.dark-mode .album-detail-v5 .album-preview-thumb {
    background: rgba(24, 36, 58, 0.98) !important;
    border-color: rgba(111, 124, 255, .32) !important;
}

body.dark-mode .album-detail-v5 .album-preview-thumb.active,
body.dark-mode .album-detail-v5 .album-preview-thumb:hover {
    border-color: rgba(140, 151, 255, .75) !important;
}

body.dark-mode .album-detail-v5 .album-actions-under-gallery {
    border-color: #31415e !important;
}

body.dark-mode .album-detail-v5 .album-strip-avatar,
body.dark-mode .album-detail-v5 .album-strip-avatar span {
    background: linear-gradient(135deg, #5968e8, #8794ff) !important;
    color: #fff !important;
}

body.dark-mode .album-detail-v5 .album-strip-avatar img {
    opacity: 1 !important;
    filter: none !important;
}

/* Make minimized floating messenger a clean single pill without leftover rectangle/corner */
.chat-dock.minimized {
    width: 370px !important;
    max-width: calc(100vw - 28px) !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    pointer-events: none !important;
}

.chat-dock.minimized .chat-dock-panel {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    grid-template-rows: none !important;
    transform: none !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    border-radius: 0 !important;
    pointer-events: auto !important;
}

.chat-dock.minimized .chat-dock-body {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    background: transparent !important;
    box-shadow: none !important;
}

.chat-dock.minimized .chat-dock-head {
    width: 100% !important;
    border-radius: 24px !important;
    border: 1px solid var(--line) !important;
    overflow: hidden !important;
}

body.dark-mode .chat-dock,
body.dark-mode .chat-dock::before,
body.dark-mode .chat-dock::after,
body.dark-mode .chat-dock-panel::before,
body.dark-mode .chat-dock-panel::after {
    background: transparent !important;
    box-shadow: none !important;
}

body.dark-mode .chat-dock.minimized .chat-dock-head {
    background: rgba(17, 27, 45, 0.99) !important;
    color: #eef4ff !important;
    border-color: #31415e !important;
    box-shadow: 0 18px 45px rgba(0,0,0,.34) !important;
}

body.dark-mode .chat-dock.open .chat-dock-panel {
    background: rgba(17, 27, 45, 0.99) !important;
    border: 1px solid #31415e !important;
    border-radius: 24px !important;
    overflow: hidden !important;
    box-shadow: 0 18px 45px rgba(0,0,0,.42) !important;
}

body.dark-mode .chat-dock.open .chat-dock-head {
    border-radius: 24px 24px 0 0 !important;
}

/* --- v14.5 profile form containment + dark readability --- */
body.dark-mode .profile-form-card,
body.dark-mode .profile-info-card,
body.dark-mode .profile-top,
body.dark-mode .profile-top-stats div {
    background: rgba(17, 27, 45, 0.96) !important;
    border-color: rgba(124, 145, 190, 0.32) !important;
}

body.dark-mode .profile-top-stats div {
    background: rgba(24, 38, 62, 0.92) !important;
}

body.dark-mode .extended-profile-form .field input,
body.dark-mode .extended-profile-form .field textarea,
body.dark-mode .extended-profile-form .field select,
body.dark-mode .profile-form-card input,
body.dark-mode .profile-form-card textarea,
body.dark-mode .profile-form-card select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: rgba(24, 38, 62, 0.94) !important;
    color: #eef4ff !important;
    border-color: rgba(124, 145, 190, 0.36) !important;
}

body.dark-mode .extended-profile-form .field input::placeholder,
body.dark-mode .extended-profile-form .field textarea::placeholder {
    color: rgba(216, 226, 247, 0.58) !important;
}


/* v14.7: the number inside like pill must not become its own white bubble */
body.dark-mode .album-like-count #album-likes-count,
body.dark-mode .album-detail-v5 .album-like-count #album-likes-count {
    display: inline !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    height: auto !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: inherit !important;
    font: inherit !important;
}
