/* Global Cover Styles */
:root {
    --python-blue: #306998;
    --python-yellow: #FFD43B;
    --gray-bg: #f8f9fa;
    --text-color: #333;
    --code-bg: #f1f1f1;

    /* Widget Variables - White Mode / Light Glassmorphism */
    --widget-bg: rgba(255, 255, 255, 0.85);
    --widget-header-bg: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.08);
    /* Light subtle border */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    /* Indigo/Violet */
    --accent-color: #4f46e5;

    --my-msg-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --my-msg-text: #ffffff;

    --other-msg-bg: #e5e7eb;
    /* Darker gray for better contrast */
    --other-msg-text: #111827;
    /* Darker text for better readability */

    --text-light: #111827;
    /* Dark text for light mode */
    --text-muted: #6b7280;
    /* Gray text */

    --success-color: #10b981;
    --glow-color: rgba(79, 70, 229, 0.3);

    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--gray-bg);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Cover Site */
header {
    background-color: var(--python-blue);
    /* #306998 */
    color: white;
    padding: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

header nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    margin-left: 20px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

header nav a:hover,
header nav a.active {
    color: var(--python-yellow);
    /* #FFD43B */
}

.tagline {
    background: rgba(0, 0, 0, 0.1);
    text-align: center;
    padding: 8px;
    margin: 0;
    color: var(--python-yellow);
    font-weight: 600;
    font-size: 0.85rem;
}

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

.main-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    header nav {
        margin-top: 15px;
    }
}

article {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.hero-post {
    border-top: 4px solid var(--python-yellow);
}

h2 {
    color: var(--python-blue);
    margin-top: 5px;
}

.category {
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--python-blue);
    font-weight: bold;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Sidebar Styles */
.sidebar-widget {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
}

.sidebar-widget h3 {
    margin-top: 0;
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    color: var(--text-color);
}

.link-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.link-list li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

.link-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    color: var(--python-blue);
    font-weight: bold;
}

.link-list a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.link-list a:hover {
    color: var(--python-blue);
}

.challenge-answer {
    display: block;
    background: var(--code-bg);
    padding: 10px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    color: var(--python-blue);
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
}

pre {
    background-color: var(--code-bg);
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    border-left: 4px solid var(--python-blue);
}

footer {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 0.9em;
}

#footer-dot {
    color: inherit;
    text-decoration: none;
    cursor: default;
    user-select: none;
}

/* ============================
   MESSAGING WIDGET - White Glassmorphism
   ============================ */

#messaging-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: var(--widget-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', -apple-system, sans-serif;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.2s ease;
}

#messaging-widget.show {
    display: flex !important;
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Header */
.widget-header {
    background: var(--widget-header-bg);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.95rem;
}

.widget-header span:first-child {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-back {
    cursor: pointer;
    padding: 4px 8px;
    margin: -4px -8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.header-back:hover {
    background: rgba(0, 0, 0, 0.05);
}

.header-action {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.header-action:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-light);
}

/* Views */
.widget-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* Login View */
#view-login {
    padding: 32px 28px;
    justify-content: center;
}

#view-login h3 {
    color: var(--text-light);
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    font-size: 1.5rem;
}

#view-login .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 32px;
}

#view-login input {
    width: 100%;
    padding: 14px 16px;
    margin: 8px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-sizing: border-box;
    background: white;
    color: var(--text-light);
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#view-login input::placeholder {
    color: #9ca3af;
}

#view-login input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--glow-color);
}

#view-login button {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px var(--glow-color);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--glow-color);
}

.btn-secondary {
    background: white;
    color: var(--text-light);
    border: 1px solid #e5e7eb !important;
    margin-top: 8px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: #f9fafb;
}

.error {
    color: #ef4444;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 12px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(254, 226, 226, 0.5);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.error:empty {
    display: none;
}

/* User List */
.user-list {
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

.user-item {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.user-item:hover {
    background: #f9fafb;
}

.user-item:last-child {
    border-bottom: none;
}

.avatar-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-weight: 600;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-info {
    flex: 1;
}

.user-name {
    color: var(--text-light);
    font-weight: 600;
    font-size: 1rem;
}

.user-status {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.encryption-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.encryption-badge svg {
    width: 10px;
    height: 10px;
}

/* Chat View */
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f9fafb;
    /* Slight grey for chat area */
    display: flex;
    flex-direction: column;
}

.message-bubble {
    max-width: 78%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: msgSlide 0.25s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-top: 10px;
    overflow-wrap: break-word;
    /* Prevent overflow */
    word-wrap: break-word;
    word-break: break-word;
}

.message-bubble.media-message {
    padding: 4px;
    border-radius: 12px;
}


.message-bubble:first-child {
    margin-top: 0;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--my-msg-bg);
    color: var(--my-msg-text);
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    align-self: flex-start;
    background: var(--other-msg-bg);
    color: var(--other-msg-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Message grouping - reduce gap between consecutive messages from same sender */
.message-bubble.msg-first+.message-bubble {
    margin-top: 2px;
}

.message-bubble.msg-middle+.message-bubble {
    margin-top: 2px;
}

/* Adjust border radius for grouped messages */
.message-bubble.sent.msg-first {
    border-bottom-right-radius: 8px;
}

.message-bubble.sent.msg-middle {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.message-bubble.sent.msg-last {
    border-top-right-radius: 8px;
}

.message-bubble.received.msg-first {
    border-bottom-left-radius: 8px;
}

.message-bubble.received.msg-middle {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.message-bubble.received.msg-last {
    border-top-left-radius: 8px;
}

.msg-time {
    display: block;
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 4px;
    text-align: right;
}

.message-bubble.received .msg-time {
    color: var(--text-muted);
}

.msg-lock {
    display: inline-flex;
    margin-left: 4px;
    opacity: 0.8;
}

.msg-lock svg {
    width: 9px;
    height: 9px;
}

/* Chat Input */
.chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
}

.chat-input input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 18px;
    outline: none;
    background: #f3f4f6;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.chat-input input::placeholder {
    color: var(--text-muted);
}

.chat-input input:focus {
    background: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--glow-color);
}

.chat-input button {
    background: var(--primary-gradient);
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chat-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--glow-color);
}

/* Loading state */
.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Utility */
.d-none {
    display: none !important;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar,
.user-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.user-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.user-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.user-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--other-msg-bg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Notification Badges */
.notification-badge,
.unread-badge {
    min-width: 18px;
    height: 18px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    animation: badgePop 0.3s ease;
}

.header-back {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
}

.user-item {
    position: relative;
}

.user-item .unread-badge {
    margin-left: auto;
    flex-shrink: 0;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* ============================
   FILE ATTACHMENTS & MEDIA
   ============================ */

/* File Button in Chat Input */
.file-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}

.file-btn svg {
    width: 20px;
    height: 20px;
}

/* Media Preview in Messages */
.media-preview {
    position: relative;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    max-width: 200px;
    margin: 4px 0;
    transition: transform 0.2s;
}

.media-preview:hover {
    transform: scale(1.02);
}

.media-preview img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    min-height: 80px;
    background: rgba(0, 0, 0, 0.05);
}

.media-preview .no-preview {
    width: 150px;
    height: 100px;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-radius: 8px;
}

.video-preview .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    padding-left: 3px;
    transition: background 0.2s;
}

.video-preview:hover .play-icon {
    background: rgba(0, 0, 0, 0.8);
}

.file-size-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* File Attachment Card */
.file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    margin: 4px 0;
    min-width: 180px;
}

.message-bubble.sent .file-attachment {
    background: rgba(255, 255, 255, 0.15);
}

.file-attachment:hover {
    background: rgba(0, 0, 0, 0.1);
}

.message-bubble.sent .file-attachment:hover {
    background: rgba(255, 255, 255, 0.25);
}

.file-icon {
    font-size: 24px;
    opacity: 0.8;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-info .file-size {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

.download-icon {
    font-size: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}

/* Upload Progress */
.upload-progress {
    position: absolute;
    bottom: 60px;
    left: 16px;
    right: 16px;
    background: var(--widget-bg);
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    border: 1px solid var(--border-color);
}

.upload-progress .progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress .progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    width: 100%;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.upload-progress .progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================
   PAGINATION / LOAD MORE
   ============================ */

.loading-more {
    display: flex;
    justify-content: center;
    padding: 16px;
}

.load-more-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 8px;
    margin-bottom: 8px;
    opacity: 0.7;
}

/* Position chat view properly for upload progress */
#view-chat {
    position: relative;
}