:root {
    --bg-color: #0f172a;
    --text-color: #ffffff;
    --secondary-text: #94a3b8;
    --card-bg: #1e293b;
    --accent-color: #38bdf8;
    --card-border: transparent;
    --transition: all 0.3s ease;
    --accent-color-rgb: 56, 189, 248;
}

/* Global Reset */
* {
    box-sizing: border-box;
}

[data-theme="light"] {
    --bg-color: #ffffff;
    --text-color: #1e293b;
    --secondary-text: #64748b;
    --card-bg: #ffffff;
    --accent-color-rgb: 2, 132, 199;
}

html {
    overflow-y: scroll;
    background-color: var(--bg-color);
}

/* Disable transitions until loaded */
body.preload {
    transition: none !important;
}

body.preload * {
    transition: none !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    min-height: 100vh;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--secondary-text);
    color: var(--text-color);
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.9rem;
    opacity: 0.4;
    z-index: 1001;
    /* Ensure above all other elements */
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    opacity: 1;
}

[data-theme="light"] .theme-toggle {
    background: rgba(0, 0, 0, 0.05);
    border-color: #cbd5e1;
}

/* New Button Container */
.controls-container {
    position: absolute;
    top: 20px;
    right: 60px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 100;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--secondary-text);
    color: var(--text-color);
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.8rem;
    opacity: 0.6;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    opacity: 1;
}

#en-btn {
    font-weight: 700;
    font-size: 0.7rem;
}

[data-theme="light"] .icon-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: #cbd5e1;
}

/* Engine Container - Hidden but Functional (Opacity Cloaked) */
.translate-container {
    visibility: visible !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: fixed !important;
    top: 0px !important;
    left: 0px !important;
    width: 1px !important;
    height: 1px !important;
    display: block !important;
    z-index: -1000;
    clip-path: circle(0);
}

/* HIDE TOP BAR AGGRESSIVELY - NUCLEAR (OPACITY CLOAKED) */
.goog-te-banner-frame.skiptranslate,
.goog-te-banner-frame,
iframe.goog-te-banner-frame,
iframe[id^=":"][id$=".container"],
iframe[name="goog-te-banner-frame"],
.goog-te-banner {
    visibility: visible !important;
    /* Must be visible for Chrome engine to execute text replacement */
    opacity: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    z-index: -1000 !important;
    display: block !important;
    top: 0px !important;
    left: 0px !important;
    clip-path: circle(0);
    /* New cloaking method */
}


body {
    top: 0px !important;
    position: relative !important;
    min-height: 100vh;
    height: auto;
}

/* Force Widget Colors */
#google_translate_element,
#google_translate_element * {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: none !important;
}

.goog-te-gadget-simple {
    padding: 5px !important;
}

#google_translate_element .goog-te-gadget-simple .goog-te-menu-value span {
    color: #000000 !important;
    border-left: none !important;
}



.container {
    padding: 20px;
    max-width: 800px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 20vh;
    animation: fadeIn 0.8s ease-in;
}

h1 {
    font-size: 3rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: -1px;
    text-transform: uppercase;
    color: var(--accent-color);
}

.subtitle {
    font-size: 1rem;
    color: var(--secondary-text);
    margin-top: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    opacity: 0.8;
    font-style: italic;
}

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--secondary-text);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.4;
    transition: var(--transition);
}

.back-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    transform: scale(1.1);
}

/* Reading/Articles Section */
.content-section {
    width: 66%;
    margin-top: 20px;
    padding: 20px;
    text-align: left;
    animation: slideUp 0.6s ease-out 0.3s backwards;
}

/* Extend Page Specific Container */
.extend-page {
    width: 66%;
    margin: 0 auto;
    padding: 40px 0;
    display: flex;
    flex-direction: column;
    min-height: 20vh;
    animation: fadeIn 0.8s ease-in;
}

.content-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.content-item {
    margin-bottom: 15px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    /* Stack vertically on all screens */
    align-items: flex-start;
    justify-content: center;
    padding: 10px 0;
    /* Increased padding */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 4px;
    /* Space between title and url */
}

[data-theme="light"] .content-item {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.item-link:hover {
    color: var(--accent-color);
    transform: translateX(5px);
}

.item-link {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.25rem;
    transition: var(--transition);
    white-space: normal;
    line-height: 1.4;
    display: block;
    width: 100%;
}

.item-meta {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.item-date {
    font-size: 0.85rem;
    color: var(--secondary-text);
    font-style: italic;
}

.content-item>.item-url {
    align-self: flex-end;
    margin-top: 2px;
}

.item-url {
    font-size: 0.9rem;
    color: var(--secondary-text);
    white-space: nowrap;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
    position: relative;
}

.item-url:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

[data-theme="light"] .item-url:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* --- LEGACY EXTENDART MAPPING --- */
/* Mapping .article-item to .content-item look */
.article-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: none;
    /* Explicitly removed */
    transition: var(--transition);
}

.article-content {
    flex: 1;
    min-width: 0;
    padding-right: 15px;
}

[data-theme="light"] .article-item {
    border-bottom-color: transparent;
}

/* FOLDER TITLES - Mirrored Layout */
.folder-section {
    width: 100%;
    max-width: 100%;
    margin: 30px 0;
    /* Changed from auto to 0 to align left */
    text-align: left;
}

.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.folder-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: none;
    display: inline-block;
}

/* Mapping .article-title-link to .item-link look - Original Font */
.article-title-link {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
    white-space: normal;
    line-height: 1.4;
    display: block;
    width: 100%;
    margin-bottom: 4px;
}

.article-title-link:hover {
    color: var(--accent-color);
}

/* Mapping .article-meta to .item-meta look */
.article-meta {
    display: flex;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--secondary-text);
    flex-wrap: wrap;
}

.meta-date {
    font-style: italic;
}

.meta-author {
    font-weight: 500;
}

.meta-domain {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: auto;
}

[data-theme="light"] .meta-domain {
    background: rgba(0, 0, 0, 0.05);
}

/* Toast Notification */
.toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: var(--accent-color);
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 10px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 30px;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
        margin-top: 60px !important;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .content-section {
        width: 100%;
        max-width: 100%;
        padding: 15px;
        margin-top: 10px;
    }

    .extend-page {
        width: 100%;
        padding: 20px 10px;
    }

    .item-link {
        font-size: 1.1rem;
    }

    /* Allow URL wrapping on mobile to prevent horizontal scroll */
    .item-url {
        font-size: 0.85rem;
        background: rgba(var(--accent-color-rgb), 0.1);
        white-space: normal;
        word-break: break-all;
        display: inline-block;
    }

    /* Stack date and url for mobile articles if needed, or keep row */
    .item-meta {
        flex-direction: row;
    }

    /* Mobile for ExtendArt */
    .article-title-link {
        font-size: 1.1rem;
    }

    .article-meta {
        font-size: 0.8rem;
    }

    .article-content {
        padding-right: 0 !important;
        width: 100%;
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- AI Chat Widget for wtpeople.in --- */
#ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: inherit;
}

#ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--highlight-color, #3b82f6);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-size: 24px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-chat-toggle:hover {
    transform: scale(1.1);
}

#ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
}

#ai-chat-window.hidden {
    display: none;
}

.chat-header {
    padding: 15px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

#ai-chat-close {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.2rem;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.bot {
    background-color: var(--secondary-bg);
    color: var(--text-color);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background-color: var(--highlight-color, #3b82f6);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message.error {
    background-color: #ef4444;
    color: white;
    align-self: center;
}

.chat-input-area {
    padding: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    background-color: var(--bg-color);
}

#chat-input-field {
    flex: 1;
    padding: 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--secondary-bg);
    color: var(--text-color);
    outline: none;
}

#chat-input-field:focus {
    border-color: var(--highlight-color);
}

#chat-send-btn {
    background-color: transparent;
    border: none;
    color: var(--highlight-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 10px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #ai-chat-window {
        width: 90vw;
        height: 60vh;
        right: 0;
    }
}