* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --main: #f1f9f6;
    --card: #ffffff;
    --text-primary: #0f291e;
    --text-secondary: #4a6b5d;
    --shadow: rgba(15, 41, 30, 0.06);
    --lens-color: #00b22d;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--main);
    background-image: url("/assets/bg/bg1.png");
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    font-family:
        "Inter",
        system-ui,
        -apple-system,
        sans-serif;
    color: var(--text-primary);
    transition:
        background-image 0.5s ease,
        background-color 0.5s ease;
}

body[data-theme="light"] {
    background-image: url("/assets/bg/bg1.png") !important;
    background-size: cover;
    background-position: center;
}

body[data-theme="dark"] {
    background-image: url("/assets/bg/bg2.png") !important;
    background-size: cover;
    background-position: center;
}

body[data-theme="light"] h2 {
    color: var(--text-primary);
}

body[data-theme="dark"] h2 {
    color: #ffffff;
}

header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 15px 5%;
    border-bottom: 1px solid rgba(0, 178, 45, 0.08);
    box-shadow: 0px 4px 20px var(--shadow);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

button {
    user-select: none;
}

.logo-container {
    font-size: 1.5rem;
    text-decoration: none;
}

.logo1,
.logo2 {
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo1 {
    color: #90ee90;
}

.logo2 {
    color: var(--lens-color);
}

.navContainerBtn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.backBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 2px solid rgba(0, 178, 45, 0.2);
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.25s ease-in-out;
}

.backBtn:hover {
    background-color: rgba(0, 178, 45, 0.08);
    color: var(--lens-color);
    border-color: var(--lens-color);
    transform: translateY(-1px);
}

.backBtn:active {
    transform: translateY(1px);
}

.btnVideo {
    padding: 8px 14px;
    border: 1px solid rgba(0, 178, 45, 0.15);
    background: var(--lens-color);
    border-radius: 10px;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0, 178, 45, 0.1);
    transition: all 0.2s ease;
}

.btnVideo:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.fx-misc-switch {
    display: inline-flex;
    cursor: pointer;
    flex-shrink: 0;
}

.fx-misc-switch input {
    display: none;
}

.fx-misc-switch-track {
    width: 68px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%);
    position: relative;
    backdrop-filter: blur(10px);
    transition: background 0.5s ease;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.15);
}

.fx-misc-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fef3c7, #fbbf24);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
    transition:
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        background 0.5s ease,
        box-shadow 0.5s ease;
}

.fx-misc-switch input:checked + .fx-misc-switch-track {
    background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
}

.fx-misc-switch input:checked + .fx-misc-switch-track .fx-misc-switch-thumb {
    transform: translateX(36px);
    background: radial-gradient(circle at 70% 30%, #e5e7eb, #94a3b8);
    box-shadow:
        inset -5px -3px 0 0 #475569,
        0 0 12px rgba(203, 213, 225, 0.4);
}

.ai-search-layout {
    display: flex;
    height: calc(100vh - 75px);
    position: relative;
    overflow: hidden;
}

.ai-conversations-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--card);
    border-right: 1px solid rgba(0, 178, 45, 0.15);
    display: flex;
    flex-direction: column;
    transition:
        transform 0.3s ease,
        margin-left 0.3s ease;
    z-index: 50;
}

.ai-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-weight: 700;
    border-bottom: 1px solid rgba(0, 178, 45, 0.1);
}

.ai-sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.ai-conversations-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
}

.ai-empty-note {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    opacity: 0.7;
    padding: 20px 10px;
}

.ai-conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    transition: background 0.15s ease;
}

.ai-conversation-item:hover {
    background: rgba(0, 178, 45, 0.08);
}

.ai-conversation-item.active {
    background: rgba(0, 178, 45, 0.15);
    font-weight: 600;
}

.ai-conversation-item .ai-conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
}

.ai-conversation-item .ai-conv-delete {
    opacity: 0.5;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.ai-conversation-item .ai-conv-delete:hover {
    opacity: 1;
    color: #dc3545;
}

.ai-chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

.ai-toggle-sidebar {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 20;
    background: var(--card);
    border: 1px solid rgba(0, 178, 45, 0.2);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 5%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-welcome-message {
    text-align: center;
    max-width: 480px;
    margin: 40px auto;
    color: var(--text-secondary);
}

.ai-welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.ai-message {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-message-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-message.user {
    align-items: flex-end;
}

.ai-message.user .ai-message-bubble {
    align-self: flex-end;
    background: var(--lens-color);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.ai-message.assistant {
    align-items: flex-start;
}

.ai-message.assistant .ai-message-bubble {
    align-self: flex-start;
    background: var(--card);
    color: var(--text-primary);
    border: 1px solid rgba(0, 178, 45, 0.12);
    border-bottom-left-radius: 4px;
}

.ai-typing-indicator {
    align-self: flex-start;
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid rgba(0, 178, 45, 0.12);
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.ai-image-drawer-toggle {
    align-self: flex-start;
    margin-top: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(0, 178, 45, 0.25);
    background: transparent;
    color: var(--lens-color);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.ai-image-drawer {
    align-self: stretch;
    max-width: 720px;
    width: 100%;
    margin: 6px auto 0 auto;
    overflow-x: auto;
    overflow-y: hidden;
    display: none;
    gap: 10px;
    padding-bottom: 8px;
    touch-action: pan-x;
}

.ai-image-drawer.open {
    display: flex;
}

.ai-drawer-card {
    flex-shrink: 0;
    width: 150px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--card);
    border: 1px solid rgba(0, 178, 45, 0.1);
    cursor: pointer;
    position: relative;
}

.ai-drawer-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.ai-drawer-card .ai-drawer-provider {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 8px;
}

.ai-chat-input-wrapper {
    border-top: 1px solid rgba(0, 178, 45, 0.12);
    padding: 12px 5% 16px 5%;
    background: var(--card);
}

.ai-advanced-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    cursor: pointer;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.ai-input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.ai-input-row textarea {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 48px;
    height: 48px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    display: block;
    border-radius: 14px;
    border: 1px solid rgba(0, 178, 45, 0.2);
    padding: 11px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.45;
    outline: none;
    background: var(--card);
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
}

.ai-input-row textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.9;
}

.ai-input-row textarea:focus {
    border-color: var(--lens-color);
}

.ai-input-row button {
    flex: 0 0 auto;
    min-width: 96px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 14px;
    border: none;
    background: var(--lens-color);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    align-self: stretch;
}

.ai-input-row button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 41, 30, 0.38);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.ai-confirm-modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ai-confirm-box {
    width: min(100%, 390px);
    padding: 26px 22px 20px;
    border-radius: 20px;
    background: var(--card);
    color: var(--text-primary);
    border: 1px solid rgba(0, 178, 45, 0.14);
    box-shadow: 0 18px 50px rgba(15, 41, 30, 0.18);
    text-align: center;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.2s ease;
}

.ai-confirm-modal.open .ai-confirm-box {
    transform: translateY(0) scale(1);
}

.ai-confirm-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.1);
    font-size: 1.35rem;
}

.ai-confirm-box h2 {
    margin: 0 0 9px;
    color: var(--text-primary);
    font-size: 1.18rem;
    line-height: 1.3;
}

.ai-confirm-box p {
    margin: 0 auto;
    max-width: 330px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.ai-confirm-actions {
    display: flex;
    gap: 9px;
    margin-top: 20px;
}

.ai-confirm-actions button {
    flex: 1 1 0;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        opacity 0.15s ease,
        background 0.15s ease;
}

.ai-confirm-actions button:active {
    transform: scale(0.97);
}

.ai-confirm-cancel {
    border: 1px solid rgba(0, 178, 45, 0.22);
    background: transparent;
    color: var(--text-primary);
}

.ai-confirm-cancel:hover {
    background: rgba(0, 178, 45, 0.07);
}

.ai-confirm-delete {
    border: 1px solid #dc3545;
    background: #dc3545;
    color: #ffffff;
}

.ai-confirm-delete:hover {
    opacity: 0.9;
}

@media (max-width: 768px) {
    .ai-search-layout {
        height: calc(100vh - 65px);
    }

    .ai-conversations-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 30;
        margin-left: -280px;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.1);
    }

    .ai-conversations-sidebar.open {
        margin-left: 0;
    }

    .ai-sidebar-close {
        display: block;
    }

    .ai-toggle-sidebar {
        display: block;
    }

    .ai-chat-messages {
        padding-top: 56px;
    }

    .ai-drawer-card {
        width: 120px;
    }

    .ai-drawer-card img {
        height: 90px;
    }

    .ai-chat-input-wrapper {
        padding: 10px 12px max(12px, env(safe-area-inset-bottom));
    }

    .ai-advanced-toggle-label {
        width: 100%;
        margin-bottom: 7px;
        font-size: 0.76rem;
    }

    .ai-input-row {
        gap: 7px;
    }

    .ai-input-row textarea {
        min-height: 46px;
        height: 46px;
        max-height: 112px;
        padding: 10px 12px;
        font-size: 0.88rem;
        line-height: 1.4;
    }

    .ai-input-row button {
        min-width: 82px;
        min-height: 46px;
        padding: 0 16px;
        border-radius: 13px;
    }
}

@media (max-width: 420px) {
    .navContainerBtn {
        gap: 6px;
    }

    .backBtn,
    .btnVideo {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .ai-chat-input-wrapper {
        padding-left: 10px;
        padding-right: 10px;
    }

    .ai-input-row {
        gap: 6px;
    }

    .ai-input-row textarea {
        min-height: 44px;
        height: 44px;
        max-height: 104px;
        padding: 9px 11px;
        font-size: 0.86rem;
        border-radius: 12px;
    }

    .ai-input-row button {
        min-width: 76px;
        min-height: 44px;
        padding: 0 13px;
        border-radius: 12px;
    }

    .ai-confirm-modal {
        padding: 14px;
    }

    .ai-confirm-box {
        padding: 23px 17px 17px;
        border-radius: 18px;
    }

    .ai-confirm-actions {
        gap: 7px;
        margin-top: 17px;
    }

    .ai-confirm-actions button {
        min-height: 46px;
    }
}
