/* Main Widgets Wrapper */
#gemini-chat-widget {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: fixed;
    bottom: 84px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Floating Bubble Button styling */
#gemini-bubble-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    outline: none;
}

#gemini-bubble-btn:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

#gemini-bubble-btn:active {
    transform: scale(0.95);
}

#gemini-bubble-btn svg {
    transition: transform 0.3s ease;
}

#gemini-bubble-btn:hover svg {
    transform: rotate(8deg) scale(1.05);
}

.bubble-sparkle {
    position: absolute;
    top: 6px;
    right: 8px;
    color: #fef08a;
    font-size: 14px;
    animation: floatSparkle 2s infinite ease-in-out;
    pointer-events: none;
}

@keyframes floatSparkle {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.8; }
    50% { transform: translateY(-4px) scale(1.2); opacity: 1; }
}

/* Pulsing Ring for Initial State */
.gemini-bubble-pulse::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 2px solid #818cf8;
    opacity: 0;
    animation: pulseRing 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
}

@keyframes pulseRing {
    0% { transform: scale(0.95); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 0.3; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Chat Panel styling (Glassmorphism) */
#gemini-chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 390px;
    height: 590px;
    max-height: calc(100vh - 60px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    transform-origin: bottom right;
}

.gemini-panel-hidden {
    opacity: 0;
    transform: scale(0.7) translateY(40px);
    pointer-events: none;
}

.gemini-panel-visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Theme-specific styles using body attributes */
/* Dark Theme (Default) */
body, body[data-theme="classic"] {
    --gem-panel-bg: rgba(17, 24, 39, 0.82);
    --gem-panel-border: rgba(255, 255, 255, 0.08);
    --gem-panel-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    --gem-text-primary: #f9fafb;
    --gem-text-secondary: #9ca3af;
    --gem-bot-msg-bg: rgba(31, 41, 55, 0.75);
    --gem-user-msg-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --gem-user-msg-text: #ffffff;
    --gem-input-bg: rgba(17, 24, 39, 0.7);
    --gem-input-border: rgba(75, 85, 99, 0.4);
    --gem-input-text: #ffffff;
    --gem-chip-bg: rgba(31, 41, 55, 0.6);
    --gem-chip-border: rgba(75, 85, 99, 0.3);
    --gem-chip-text: #d1d5db;
    --gem-chip-hover: rgba(79, 70, 229, 0.25);
    --gem-chip-hover-border: #6366f1;
    --gem-code-bg: rgba(17, 24, 39, 0.9);
}

/* NESDC Light Theme */
body[data-theme="nesdc-light"] {
    --gem-panel-bg: rgba(255, 255, 255, 0.88);
    --gem-panel-border: rgba(0, 0, 0, 0.08);
    --gem-panel-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --gem-text-primary: #1f2937;
    --gem-text-secondary: #4b5563;
    --gem-bot-msg-bg: rgba(243, 244, 246, 0.95);
    --gem-user-msg-bg: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    --gem-user-msg-text: #ffffff;
    --gem-input-bg: rgba(255, 255, 255, 0.95);
    --gem-input-border: rgba(209, 213, 219, 0.8);
    --gem-input-text: #1f2937;
    --gem-chip-bg: rgba(243, 244, 246, 0.9);
    --gem-chip-border: rgba(209, 213, 219, 0.6);
    --gem-chip-text: #374151;
    --gem-chip-hover: rgba(59, 130, 246, 0.12);
    --gem-chip-hover-border: #3b82f6;
    --gem-code-bg: rgba(243, 244, 246, 1);
}

#gemini-chat-panel {
    background: var(--gem-panel-bg);
    border: 1px solid var(--gem-panel-border);
    box-shadow: var(--gem-panel-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Header styling */
.gemini-chat-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body[data-theme="nesdc-light"] .gemini-chat-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.header-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-sparkle {
    font-size: 20px;
    color: #fef08a;
    animation: pulseSparkle 1.8s infinite ease-in-out;
}

@keyframes pulseSparkle {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.2); opacity: 1; }
}

.header-main h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
    line-height: 1.2;
}

.header-main p {
    margin: 2px 0 0 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 300;
}

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

.header-actions button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Screens Layout */
.gemini-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Chat Messages Board */
#gemini-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar */
#gemini-chat-messages::-webkit-scrollbar {
    width: 6px;
}
#gemini-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#gemini-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.3);
    border-radius: 4px;
}
#gemini-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.5);
}

.gemini-msg {
    display: flex;
    width: 100%;
}

.gemini-msg.user {
    justify-content: flex-end;
}

.gemini-msg.bot {
    justify-content: flex-start;
}

.gemini-msg.system {
    justify-content: center;
    margin: 4px 0;
}

.msg-bubble {
    max-width: 82%;
    padding: 12px 16px;
    font-size: 13.5px;
    line-height: 1.55;
    letter-spacing: 0.1px;
    border-radius: 14px;
}

.user .msg-bubble {
    background: var(--gem-user-msg-bg);
    color: var(--gem-user-msg-text);
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.15);
}

.bot .msg-bubble {
    background: var(--gem-bot-msg-bg);
    color: var(--gem-text-primary);
    border: 1px solid var(--gem-panel-border);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.system-badge {
    font-size: 11px;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

/* Message Formatting elements */
.gemini-chat-list {
    margin: 6px 0 6px 16px;
    padding: 0;
    list-style-type: disc;
}

.gemini-chat-list li {
    margin-bottom: 4px;
}

.gemini-inline-code {
    font-family: Consolas, Monaco, "Andale Mono", monospace;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.15);
    padding: 2px 5px;
    border-radius: 4px;
    color: #ec4899;
}

body, body[data-theme="classic"] .gemini-inline-code {
    background: rgba(255, 255, 255, 0.08);
    color: #f472b6;
}

.gemini-code-block {
    background: var(--gem-code-bg);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid var(--gem-panel-border);
    font-family: Consolas, Monaco, "Andale Mono", monospace;
    font-size: 12px;
}

.gemini-code-block code {
    color: var(--gem-text-primary);
}

/* Typing indicator styling */
#gemini-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 12px 16px;
}

.gemini-typing-dots {
    display: flex;
    gap: 4px;
}

.gemini-typing-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--gem-text-secondary);
    border-radius: 50%;
    display: inline-block;
    animation: bounceDot 1.4s infinite ease-in-out both;
}

.gemini-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.gemini-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounceDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.typing-text {
    font-size: 11px;
    color: var(--gem-text-secondary);
    font-weight: 300;
}

/* Suggestion Chips Board */
#gemini-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    border-top: 1px solid var(--gem-panel-border);
    background: rgba(0, 0, 0, 0.02);
}

.gemini-suggestion-chip {
    background: var(--gem-chip-bg);
    border: 1px solid var(--gem-chip-border);
    color: var(--gem-chip-text);
    padding: 6px 10px;
    font-size: 11.5px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    line-height: 1.3;
}

.gemini-suggestion-chip:hover {
    background: var(--gem-chip-hover);
    border-color: var(--gem-chip-hover-border);
    color: var(--gem-text-primary);
    transform: translateY(-1px);
}

/* Input Form styling */
#gemini-input-form {
    display: flex;
    padding: 10px 16px 14px 16px;
    gap: 8px;
    border-top: 1px solid var(--gem-panel-border);
}

#gemini-chat-input {
    flex: 1;
    background: var(--gem-input-bg);
    border: 1px solid var(--gem-input-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--gem-input-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#gemini-chat-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

body[data-theme="nesdc-light"] #gemini-chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

#gemini-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #4f46e5;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    flex-shrink: 0;
}

body[data-theme="nesdc-light"] #gemini-send-btn {
    background: #3b82f6;
}

#gemini-send-btn:hover {
    transform: scale(1.05);
    background: #4338ca;
}

body[data-theme="nesdc-light"] #gemini-send-btn:hover {
    background: #2563eb;
}

#gemini-send-btn:active {
    transform: scale(0.95);
}

/* Config / Settings Screen styling */
.config-container {
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow-y: auto;
    flex: 1;
    color: var(--gem-text-primary);
}

.config-icon {
    font-size: 40px;
    margin-bottom: 12px;
    animation: wringIcon 2.5s infinite ease;
}

@keyframes wringIcon {
    0%, 90%, 100% { transform: rotate(0); }
    93% { transform: rotate(8deg); }
    95% { transform: rotate(-8deg); }
    97% { transform: rotate(5deg); }
    99% { transform: rotate(-3deg); }
}

.config-container h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.config-container p {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--gem-text-secondary);
    margin: 0 0 20px 0;
    font-weight: 300;
}

#gemini-config-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
}

.form-group label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gem-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select {
    width: 100%;
    background: var(--gem-input-bg);
    border: 1px solid var(--gem-input-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--gem-input-text);
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus, .form-group select:focus {
    border-color: #6366f1;
}

.config-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.btn-save {
    flex: 1;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: none;
    color: #ffffff;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

body[data-theme="nesdc-light"] .btn-save {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}

.btn-save:hover {
    opacity: 0.95;
}

.btn-cancel {
    background: #374151;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e5e7eb;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

body[data-theme="nesdc-light"] .btn-cancel {
    background: #e5e7eb;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #374151;
}

.btn-cancel:hover {
    background: #4b5563;
}

body[data-theme="nesdc-light"] .btn-cancel:hover {
    background: #d1d5db;
}

.api-help {
    margin-top: 16px;
}

.api-help a {
    font-size: 11.5px;
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}

body[data-theme="nesdc-light"] .api-help a {
    color: #3b82f6;
}

.api-help a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 480px) {
    #gemini-chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        z-index: 10000;
    }
    #gemini-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    #theme-switcher {
        right: 82px !important;
        bottom: 16px !important;
    }
}

/* Dynamic positioning of theme-switcher and bubble btn when chat opens */
#theme-switcher {
    transition: bottom 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), background 0.3s, border-color 0.3s, box-shadow 0.3s !important;
}

body.gemini-chat-open #theme-switcher {
    bottom: 630px !important; /* 590px (panel height) + 24px (panel bottom) + 16px (gap) */
    z-index: 9999 !important;
}

/* Fade out chat bubble button when panel is open */
#gemini-bubble-btn {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease, transform 0.25s ease !important;
}

body.gemini-chat-open #gemini-bubble-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) translateY(20px) !important;
}

/* Resize Handles for Desktop */
.gemini-resize-handle {
    position: absolute;
    background: transparent;
    z-index: 10000;
}
.gemini-resize-handle.handle-t {
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: ns-resize;
}
.gemini-resize-handle.handle-l {
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
}
.gemini-resize-handle.handle-tl {
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 10001;
}

/* Hide resize handles on mobile devices */
@media (max-width: 480px) {
    .gemini-resize-handle {
        display: none !important;
    }
}

