/* SURYA AI — Premium Redesign */

#surya-widget-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 10000;
    font-family: 'DM Sans', sans-serif;
}

/* ── Floating Button ── */
.surya-btn {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3d5e40 0%, #6B9E6F 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 28px rgba(74,107,78,0.5), 0 0 0 0 rgba(107,158,111,0.4);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    animation: suryaPulse 3.5s ease-in-out infinite;
    position: relative;
}
.surya-btn:hover {
    transform: scale(1.1) rotate(6deg);
    box-shadow: 0 16px 44px rgba(74,107,78,0.6), 0 0 0 10px rgba(107,158,111,0.12);
    animation: none;
}
.surya-btn svg { width: 32px; height: 32px; }

@keyframes suryaPulse {
    0%   { box-shadow: 0 8px 28px rgba(74,107,78,0.5), 0 0 0 0   rgba(107,158,111,0.4); }
    65%  { box-shadow: 0 8px 28px rgba(74,107,78,0.5), 0 0 0 16px rgba(107,158,111,0);  }
    100% { box-shadow: 0 8px 28px rgba(74,107,78,0.5), 0 0 0 0   rgba(107,158,111,0);  }
}

/* Label tooltip junto al botón */
.surya-label {
    position: absolute;
    right: 74px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(30,30,30,0.85);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.45rem 1rem;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.4s ease;
    letter-spacing: 0.03em;
}
.surya-label::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid rgba(30,30,30,0.85);
}
.surya-label.hidden { opacity: 0; }

.surya-sparkle {
    animation: suryaSparkle 2.4s infinite ease-in-out;
    transform-origin: center;
}
@keyframes suryaSparkle {
    0%, 100% { opacity: 0.7; transform: scale(0.9); }
    50%       { opacity: 1;   transform: scale(1.2); }
}

/* ── Chat Window ── */
.surya-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 580px;
    background: rgba(252, 251, 249, 0.92);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 32px;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 30px 80px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}
.surya-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.surya-header {
    padding: 1.2rem 1.4rem;
    background: linear-gradient(135deg, #3a5c3e 0%, #587d5c 100%);
    display: flex;
    align-items: center;
    gap: 0.9rem;
    position: relative;
    flex-shrink: 0;
}

.surya-avatar-wrap {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.surya-avatar-wrap svg { width: 24px; height: 24px; }

.surya-header-info { flex: 1; min-width: 0; }
.surya-header-name {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    color: white;
    margin: 0;
    line-height: 1.2;
    font-weight: 600;
}
.surya-header-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.surya-status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #7eff9e;
    box-shadow: 0 0 0 0 rgba(126,255,158,0.5);
    animation: statusPulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes statusPulse {
    0%   { box-shadow: 0 0 0 0   rgba(126,255,158,0.6); }
    60%  { box-shadow: 0 0 0 6px rgba(126,255,158,0);   }
    100% { box-shadow: 0 0 0 0   rgba(126,255,158,0);   }
}
.surya-header-sub span {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.7);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.surya-tokens-pill {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.7rem;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.surya-tokens-pill svg { width: 11px; height: 11px; opacity: 0.8; }

.surya-close-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    flex-shrink: 0;
}
.surya-close-btn:hover { background: rgba(255,255,255,0.25); }
.surya-close-btn svg { width: 16px; height: 16px; }

/* ── History Panel ── */
.surya-history-btn { margin-right: -4px; }

.surya-history-panel {
    position: absolute;
    inset: 0;
    background: rgba(252,251,249,0.98);
    backdrop-filter: blur(20px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 32px;
}
.surya-history-panel.open { transform: translateX(0); }
[data-theme="dark"] .surya-history-panel { background: rgba(12,14,12,0.98); }

.surya-history-top {
    padding: 1.2rem 1.2rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}
[data-theme="dark"] .surya-history-top { border-color: rgba(255,255,255,0.06); }

.surya-history-back {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer;
    font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 700;
    color: #4A6B4E; padding: 0.4rem 0.6rem; border-radius: 100px;
    transition: 0.25s;
}
.surya-history-back:hover { background: rgba(74,107,78,0.08); }

.surya-new-chat-btn {
    display: flex; align-items: center; gap: 5px;
    background: #4A6B4E; color: white; border: none;
    padding: 0.42rem 0.9rem; border-radius: 100px;
    font-family: 'DM Sans', sans-serif; font-size: 0.75rem; font-weight: 700;
    cursor: pointer; transition: 0.25s;
}
.surya-new-chat-btn:hover { background: #3a5c3e; transform: translateY(-1px); }

.surya-history-list {
    flex: 1; overflow-y: auto; padding: 0.8rem;
    display: flex; flex-direction: column; gap: 6px;
    scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.08) transparent;
}
.surya-history-empty, .surya-history-loading {
    text-align: center; padding: 3rem 1rem;
    opacity: 0.4; font-size: 0.85rem; font-style: italic;
}

.surya-history-item {
    background: white; border: 1px solid rgba(0,0,0,0.05);
    border-radius: 16px; padding: 1rem 1.1rem;
    cursor: pointer; transition: 0.25s;
}
.surya-history-item:hover { border-color: rgba(74,107,78,0.3); transform: translateX(4px); box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
[data-theme="dark"] .surya-history-item { background: #1a1c1a; border-color: rgba(255,255,255,0.05); }

.shi-date {
    font-size: 0.72rem; font-weight: 800; text-transform: capitalize;
    color: #4A6B4E; margin-bottom: 4px; letter-spacing: 0.02em;
}
.shi-preview { font-size: 0.83rem; line-height: 1.4; opacity: 0.7; margin-bottom: 6px; }
.shi-count { font-size: 0.68rem; opacity: 0.35; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }

/* Date divider in messages */
.surya-date-divider {
    text-align: center; font-size: 0.68rem; font-weight: 800;
    text-transform: capitalize; letter-spacing: 0.06em;
    opacity: 0.35; padding: 0.5rem 0 0.2rem;
}

/* ── Messages ── */
.surya-messages {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}
.surya-messages::-webkit-scrollbar { width: 4px; }
.surya-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 4px; }

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}
.msg-row.row-user { flex-direction: row-reverse; }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar-mini {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3a5c3e, #6B9E6F);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.msg-avatar-mini svg { width: 15px; height: 15px; }

.msg {
    max-width: 78%;
    padding: 0.85rem 1.1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    line-height: 1.55;
    position: relative;
}

.msg-surya {
    background: white;
    color: #2a2a2a;
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.04);
}

.msg-user {
    background: linear-gradient(135deg, #C4714A, #d4824e);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 6px 20px rgba(196,113,74,0.35);
}

/* Typing indicator */
.surya-typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgIn 0.35s ease forwards;
    opacity: 0;
}
.typing-bubble {
    background: white;
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    padding: 0.85rem 1.1rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    display: flex;
    gap: 5px;
    align-items: center;
}
.typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #7A9E7E;
    animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
    30%            { transform: translateY(-7px); opacity: 1;   }
}

/* ── Quick Chips ── */
.surya-chips {
    padding: 0.5rem 1rem 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.surya-chip {
    background: rgba(122,158,126,0.1);
    color: #4A6B4E;
    border: 1px solid rgba(122,158,126,0.2);
    border-radius: 100px;
    padding: 0.35rem 0.9rem;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.25s;
    white-space: nowrap;
    font-family: 'DM Sans', sans-serif;
}
.surya-chip:hover {
    background: #4A6B4E;
    color: white;
    border-color: #4A6B4E;
    transform: translateY(-1px);
}

/* ── Input Area ── */
.surya-input-area {
    padding: 0.9rem 1rem;
    background: white;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.surya-input-area input {
    flex: 1;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 100px;
    padding: 0.72rem 1.1rem;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    background: #f9f8f7;
    transition: 0.3s;
    color: #2a2a2a;
}
.surya-input-area input::placeholder { color: rgba(0,0,0,0.3); }
.surya-input-area input:focus {
    border-color: #4A6B4E;
    background: white;
    box-shadow: 0 0 0 4px rgba(74,107,78,0.08);
}
.surya-input-area input:disabled { opacity: 0.4; cursor: not-allowed; }

.surya-send {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #3a5c3e, #6B9E6F);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: 0.3s;
    box-shadow: 0 4px 14px rgba(74,107,78,0.35);
}
.surya-send:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(74,107,78,0.5); }
.surya-send svg { width: 18px; height: 18px; }

/* ── Low tokens warning ── */
.surya-tokens-low {
    padding: 0.7rem 1rem;
    background: rgba(196,113,74,0.08);
    color: #b05e38;
    font-size: 0.78rem;
    text-align: center;
    border-top: 1px solid rgba(196,113,74,0.15);
    font-weight: 600;
    flex-shrink: 0;
}

/* ── Dark / Night Mode ── */
[data-theme="dark"] .surya-btn {
    background: linear-gradient(135deg, #090e1f 0%, #101d3a 50%, #162040 100%);
    border-color: rgba(120, 160, 230, 0.2);
    animation: suryaNightPulse 4s ease-in-out infinite;
}
[data-theme="dark"] .surya-btn:hover {
    background: linear-gradient(135deg, #101d3a 0%, #1e3a5f 100%);
    border-color: rgba(120, 160, 230, 0.4);
}
@keyframes suryaNightPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(80,130,220,0), 0 8px 32px rgba(10,20,60,0.5); }
    50% { box-shadow: 0 0 0 10px rgba(80,130,220,0.08), 0 8px 32px rgba(10,20,60,0.6); }
}

[data-theme="dark"] .surya-window {
    background: rgba(10, 13, 22, 0.97);
    border-color: rgba(80, 130, 220, 0.12);
    box-shadow: 0 30px 100px rgba(0,0,0,0.65), 0 0 30px rgba(60,100,200,0.06);
}
[data-theme="dark"] .surya-header {
    background: linear-gradient(135deg, #0d1825, #162035);
    border-color: rgba(255,255,255,0.05);
}
[data-theme="dark"] .surya-header-name { color: #dde4f0; }
[data-theme="dark"] .surya-header-sub { color: rgba(180,200,240,0.6); }
[data-theme="dark"] .surya-status-dot {
    background: #7eb5ff;
    box-shadow: 0 0 0 0 rgba(126,181,255,0.4);
    animation: statusPulseNight 2s ease-in-out infinite;
}
@keyframes statusPulseNight {
    0%, 100% { box-shadow: 0 0 0 0 rgba(126,181,255,0.4); }
    50% { box-shadow: 0 0 0 5px rgba(126,181,255,0); }
}
[data-theme="dark"] .msg-avatar-mini {
    background: linear-gradient(135deg, #101d3a, #1e3a5f);
}
[data-theme="dark"] .msg-surya {
    background: #141a26;
    color: #dde4f0;
    border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .msg-user {
    background: rgba(176, 85, 77, 0.15) !important;
    color: #ff9d94 !important;
    border-color: rgba(176, 85, 77, 0.2) !important;
}
[data-theme="dark"] .typing-bubble {
    background: #141a26;
    border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .typing-dot { background: #4a7aaa; }
[data-theme="dark"] .surya-input-area {
    background: #0a0d16;
    border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .surya-input-area input {
    background: #141a26;
    border-color: rgba(255,255,255,0.1);
    color: #dde4f0;
}
[data-theme="dark"] .surya-input-area input:focus {
    background: #1a2235;
    box-shadow: 0 0 0 4px rgba(60,100,180,0.12);
}
[data-theme="dark"] .surya-chip {
    background: rgba(60,100,180,0.1);
    border-color: rgba(80,130,220,0.2);
    color: #7aaad8;
}
[data-theme="dark"] .surya-chip:hover { background: #1e3a5f; color: #aed0f5; }
[data-theme="dark"] .surya-chips { border-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .surya-send {
    background: linear-gradient(135deg, #101d3a, #1e3a5f);
    box-shadow: 0 4px 16px rgba(20,50,120,0.4);
}
[data-theme="dark"] .surya-send:hover { box-shadow: 0 6px 20px rgba(20,50,120,0.6); }
[data-theme="dark"] .surya-history-item { background: #141a26; border-color: rgba(255,255,255,0.05); }
[data-theme="dark"] .surya-history-item:hover { background: #1e2a40; }
[data-theme="dark"] .history-item-title { color: #7aaad8; }
[data-theme="dark"] .history-item-preview { color: rgba(180,200,240,0.5); }

/* ── Mobile ── */
@media (max-width: 480px) {
    #surya-widget-container { bottom: 16px; right: 16px; }
    .surya-window {
        width: calc(100vw - 32px);
        height: 70vh;
        bottom: 76px;
        right: 0;
        border-radius: 24px;
    }
    .surya-label { display: none; }
}
