/**
 * Silvinha Chatbot - Estilos
 * Integrado ao tema retro do Django Daisy
 */

/* ===== CONTAINER GERAL ===== */
#silvinha-chat-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    font-family: inherit;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* ===== BOTÃO FLUTUANTE ===== */
.silvinha-chat-toggle {
    width: 68px !important;
    height: 68px !important;
    border-radius: 50% !important;
    background: #004D40 !important;
    border: 3px solid rgba(255,255,255,0.25) !important;
    box-shadow: 0 6px 18px rgba(0, 77, 64, 0.45), 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1 !important;
    visibility: visible !important;
}

.silvinha-chat-toggle:hover {
    transform: scale(1.1);
    background: #00695C !important;
    box-shadow: 0 8px 24px rgba(0, 77, 64, 0.55), 0 3px 8px rgba(0, 0, 0, 0.2) !important;
    cursor: grab;
}

.silvinha-chat-toggle:active {
    transform: scale(0.95);
}

.silvinha-chat-toggle.silvinha-dragging {
    cursor: grabbing !important;
    transform: scale(1.12) !important;
    opacity: 0.9 !important;
    transition: none !important;
}

.silvinha-chat-icon {
    width: 32px;
    height: 32px;
    color: white;
}

/* ===== GREETING BUBBLE ===== */
.silvinha-greeting-bubble {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: white;
    color: #004D40;
    padding: 10px 14px;
    border-radius: 12px;
    border-bottom-right-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: 0 4px 14px rgba(0, 77, 64, 0.18);
    white-space: nowrap;
    border: 1.5px solid #004D40;
    animation: greetingPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999998;
    pointer-events: none;
}

.silvinha-greeting-bubble::after {
    content: '';
    position: absolute;
    right: 15px;
    bottom: -9px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 9px solid #004D40;
}

.silvinha-greeting-bubble::before {
    content: '';
    position: absolute;
    right: 16px;
    bottom: -7px;
    width: 0;
    height: 0;
    border-top: 0px solid transparent;
    border-bottom: 7px solid transparent;
    border-right: 8px solid white;
    z-index: 1;
}

@keyframes greetingPop {
    from {
        opacity: 0;
        transform: scale(0.7) translateX(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

.silvinha-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

/* ===== PAINEL DO CHAT ===== */
.silvinha-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 460px;
    max-width: calc(100vw - 40px);
    height: 650px;
    max-height: calc(100vh - 120px);
    background: var(--color-base-100, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

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

/* ===== HEADER ===== */
.silvinha-chat-header {
    background: #004D40;
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.silvinha-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.silvinha-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.silvinha-avatar svg {
    width: 24px;
    height: 24px;
}

.silvinha-header-info {
    display: flex;
    flex-direction: column;
}

.silvinha-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.silvinha-status {
    font-size: 12px;
    opacity: 0.9;
}

.silvinha-chat-header-right {
    display: flex;
    gap: 8px;
}

.silvinha-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.silvinha-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.silvinha-header-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== ÁREA DE MENSAGENS ===== */
.silvinha-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--color-base-100, #f9f9f9);
}

.silvinha-messages::-webkit-scrollbar {
    width: 6px;
}

.silvinha-messages::-webkit-scrollbar-track {
    background: transparent;
}

.silvinha-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.silvinha-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ===== MENSAGENS ===== */
.silvinha-message {
    display: flex;
    gap: 10px;
    animation: messageSlide 0.3s ease-out;
}

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

.silvinha-message-assistant {
    align-self: flex-start;
}

.silvinha-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.silvinha-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.silvinha-message-assistant .silvinha-message-avatar {
    background: #004D40;
    color: white;
}

.silvinha-message-user .silvinha-message-avatar {
    background: var(--color-base-200, #e0e0e0);
    color: #2c3e50;
}

.silvinha-message-avatar svg {
    width: 20px;
    height: 20px;
}

.silvinha-message-content {
    max-width: 75%;
}

.silvinha-message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.silvinha-message-assistant .silvinha-message-bubble {
    background: white;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.silvinha-message-user .silvinha-message-bubble {
    background: #004D40;
    color: white;
    border-bottom-right-radius: 4px;
}

/* ===== INDICADOR DE DIGITAÇÃO ===== */
.silvinha-typing {
    padding: 0 20px;
}

.silvinha-typing-indicator {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.silvinha-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #7f8c8d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.silvinha-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.silvinha-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ===== INPUT DE MENSAGEM ===== */
.silvinha-input-container {
    background: white;
    border-top: 1px solid var(--color-base-300, #e0e0e0);
    padding: 16px;
}

.silvinha-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.silvinha-input {
    flex: 1;
    border: 2px solid var(--color-base-300, #e0e0e0);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
    background: var(--color-base-100, #f9f9f9);
}

.silvinha-input:focus {
    outline: none;
    border-color: #004D40;
}

.silvinha-input::placeholder {
    color: #7f8c8d;
}

.silvinha-send-btn {
    width: 40px;
    height: 40px;
    background: #004D40;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.silvinha-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: #00695C;
    box-shadow: 0 4px 12px rgba(0, 77, 64, 0.4);
}

.silvinha-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.silvinha-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.silvinha-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== MODO MAXIMIZADO (TELA CHEIA) ===== */
.silvinha-chat-panel.silvinha-maximized {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    z-index: 1000000;
}

.silvinha-maximized .silvinha-chat-header {
    border-radius: 0;
}

.silvinha-maximized .silvinha-messages {
    padding: 24px 15%;
}

.silvinha-maximized .silvinha-message-content {
    max-width: 85%;
}

.silvinha-maximized .silvinha-input-container {
    padding: 16px 15%;
}

.silvinha-maximized .silvinha-message-bubble {
    font-size: 15px;
}

@media (max-width: 900px) {
    .silvinha-maximized .silvinha-messages {
        padding: 20px;
    }
    .silvinha-maximized .silvinha-input-container {
        padding: 16px 20px;
    }
}

/* ===== RESPONSIVO ===== */
@media (max-width: 480px) {
    #silvinha-chat-container {
        bottom: 10px;
        right: 10px;
    }

    .silvinha-chat-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 90px;
        right: 10px;
    }

    .silvinha-chat-toggle {
        width: 60px !important;
        height: 60px !important;
    }

    .silvinha-chat-icon {
        width: 28px;
        height: 28px;
    }

    .silvinha-greeting-bubble {
        display: none;
    }
}

/* ===== MARKDOWN SUPORTE ===== */
.silvinha-message-bubble p {
    margin: 0 0 10px 0;
    line-height: 1.6;
}

.silvinha-message-bubble p:last-child {
    margin-bottom: 0;
}

.silvinha-message-bubble code {
    background: rgba(0, 77, 64, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #004D40;
}

.silvinha-message-bubble pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    border-left: 3px solid #004D40;
}

.silvinha-message-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.silvinha-message-bubble strong {
    font-weight: 700;
    color: #1a1a1a;
}

.silvinha-message-bubble em {
    font-style: italic;
}

.silvinha-message-bubble ul,
.silvinha-message-bubble ol {
    margin: 8px 0;
    padding-left: 22px;
}

.silvinha-message-bubble li {
    margin: 5px 0;
    line-height: 1.5;
}

.silvinha-message-bubble h3,
.silvinha-message-bubble h4 {
    margin: 12px 0 6px 0;
    font-weight: 700;
    color: #004D40;
}

.silvinha-message-bubble h3 {
    font-size: 15px;
}

.silvinha-message-bubble h4 {
    font-size: 14px;
}

.silvinha-message-bubble blockquote {
    border-left: 3px solid #004D40;
    margin: 8px 0;
    padding: 4px 12px;
    color: #555;
    background: rgba(0, 77, 64, 0.04);
    border-radius: 0 4px 4px 0;
}

.silvinha-message-bubble table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
    font-size: 13px;
}

.silvinha-message-bubble th,
.silvinha-message-bubble td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}

.silvinha-message-bubble th {
    background: #004D40;
    color: white;
    font-weight: 600;
}

.silvinha-message-bubble tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.03);
}

.silvinha-message-user .silvinha-message-bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.silvinha-message-user .silvinha-message-bubble strong {
    color: inherit;
}
