/* 
   Obsidian Premium Support Widget Styles - Ultimate Edition
   Design: Glassmorphism & High-End UX
*/

:root {
    --sp-bg-glass: rgba(10, 10, 10, 0.75);
    --sp-card-glass: rgba(20, 20, 20, 0.85);
    --sp-border-glass: rgba(255, 255, 255, 0.1);
    --sp-border-highlight: rgba(245, 158, 11, 0.3);
    --sp-accent: #f59e0b; /* Brand Primary */
    --sp-accent-hover: #d97706;
    --sp-text: #f5f5f5;
    --sp-text-muted: #a3a3a3;
    --sp-user-msg: linear-gradient(135deg, #f59e0b, #d97706);
    --sp-ai-msg: rgba(30, 30, 30, 0.8);
    --sp-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
}

#sp-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#sp-widget-container * {
    box-sizing: border-box;
}

/* Trigger Button */
.sp-trigger {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--sp-accent), var(--sp-accent-hover));
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 10001;
}

.sp-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 35px rgba(245, 158, 11, 0.6);
}

.sp-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #141414;
    animation: sp-bounce 2s infinite;
}

@keyframes sp-bounce {
    0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
    40% {transform: translateY(-5px);}
    60% {transform: translateY(-3px);}
}

/* Chat Window */
.sp-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 380px;
    height: 600px;
    background: var(--sp-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--sp-border-glass);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: var(--sp-shadow);
    transform-origin: bottom right;
}

.sp-window.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.sp-window.fullscreen {
    position: fixed;
    bottom: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
    z-index: 10005;
}

/* Header */
.sp-header {
    padding: 16px 20px;
    background: var(--sp-card-glass);
    border-bottom: 1px solid var(--sp-border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sp-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sp-avatar-container {
    position: relative;
}

.sp-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #333, #111);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--sp-accent);
    border: 1px solid var(--sp-border-glass);
}

.sp-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #141414;
    background: #10b981;
}

.sp-status-dot.online { background: #10b981; box-shadow: 0 0 8px #10b981; }
.sp-status-dot.offline { background: #6b7280; }

.sp-header-info {
    display: flex;
    flex-direction: column;
}

.sp-header-title {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.sp-header-status {
    color: var(--sp-accent);
    font-size: 12px;
    font-weight: 500;
}

.sp-header-actions {
    display: flex;
    gap: 8px;
}

.sp-action-btn {
    background: transparent;
    border: none;
    color: var(--sp-text-muted);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sp-action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Quick Topics */
.sp-quick-topics-container {
    padding: 15px 20px 10px;
    border-bottom: 1px solid var(--sp-border-glass);
    background: rgba(0,0,0,0.2);
}

.sp-topics-title {
    font-size: 12px;
    color: var(--sp-text-muted);
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sp-topic-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--sp-border-glass);
    color: var(--sp-text);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-topic-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--sp-accent);
    color: var(--sp-accent);
}

/* Messages */
.sp-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sp-messages::-webkit-scrollbar { width: 4px; }
.sp-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sp-msg-container {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: sp-fade-in-up 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes sp-fade-in-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-msg-container {
    align-self: flex-end;
    align-items: flex-end;
}

.ai-msg-container {
    align-self: flex-start;
    align-items: flex-start;
}

.sp-msg {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.sp-msg-user {
    background: var(--sp-user-msg);
    color: #fff;
    border-radius: 18px 18px 0 18px;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.2);
}

.sp-msg-ai {
    background: var(--sp-ai-msg);
    color: var(--sp-text);
    border-radius: 18px 18px 18px 0;
    border: 1px solid var(--sp-border-glass);
}

.sp-msg-info {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.sp-msg-time {
    font-size: 10px;
    color: var(--sp-text-muted);
}

.sp-msg-status {
    font-size: 10px;
    color: var(--sp-accent);
}

/* Footer & Input */
.sp-footer {
    padding: 16px 20px;
    background: var(--sp-card-glass);
    border-top: 1px solid var(--sp-border-glass);
    position: relative;
}

.sp-input-actions.top-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.sp-tool-btn {
    background: transparent;
    border: none;
    color: var(--sp-text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-tool-btn:hover {
    color: var(--sp-accent);
}

.sp-input-wrapper {
    display: flex;
    align-items: flex-end;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--sp-border-glass);
    border-radius: 20px;
    padding: 8px 16px;
    transition: border-color 0.3s;
}

.sp-input-wrapper:focus-within {
    border-color: var(--sp-accent);
}

#sp-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 100px;
    padding: 4px 0;
    font-family: inherit;
    scrollbar-width: none;
}

#sp-input::-webkit-scrollbar { display: none; }

.sp-input-actions.right-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 2px;
    padding-left: 10px;
}

.sp-send-btn {
    width: 32px;
    height: 32px;
    background: var(--sp-accent);
    color: #000;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    font-size: 14px;
}

.sp-send-btn:hover {
    transform: scale(1.1);
}

.sp-send-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

/* Emoji Picker */
.sp-emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: var(--sp-card-glass);
    border: 1px solid var(--sp-border-glass);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: var(--sp-shadow);
    backdrop-filter: blur(10px);
}

.emoji-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.emoji-list span {
    font-size: 24px;
    cursor: pointer;
    transition: transform 0.2s;
    text-align: center;
    user-select: none;
}

.emoji-list span:hover {
    transform: scale(1.2);
}

/* Typing Indicator */
.sp-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    width: fit-content;
}

.sp-typing span {
    width: 6px;
    height: 6px;
    background: var(--sp-accent);
    border-radius: 50%;
    animation: sp-blink 1.4s infinite ease-in-out both;
}

.sp-typing span:nth-child(1) { animation-delay: -0.32s; }
.sp-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes sp-blink {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Mic Recording Animation */
.mic-btn.recording {
    color: #ef4444;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@media (max-width: 480px) {
    .sp-window {
        width: calc(100vw - 32px);
        height: 75vh;
        bottom: 85px;
        right: 16px;
        border-radius: 20px;
    }
    
    #sp-widget-container {
        bottom: 16px;
        right: 16px;
    }
}
