/* Synthoil Consultor IA — Widget & Página */

:root {
    --ai-primary: #001833;
    --ai-accent: #D4AF37;
    --ai-accent-hover: #b5952f;
    --ai-bg: #ffffff;
    --ai-surface: #f4f6f9;
    --ai-text: #141414;
    --ai-muted: #6b7280;
    --ai-border: rgba(0, 24, 51, 0.12);
    --ai-shadow: 0 12px 40px rgba(0, 24, 51, 0.18);
    --ai-radius: 16px;
}

/* ─── Floating launcher (widget mode) ─────────────────────────────────────── */

.ai-launcher {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), #002a5c);
    color: var(--ai-accent);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--ai-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 16px 48px rgba(0, 24, 51, 0.28);
}

.ai-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* ─── Chat panel ──────────────────────────────────────────────────────────── */

.ai-panel {
    position: fixed;
    bottom: 100px;
    left: 30px;
    z-index: 9999;
    width: min(400px, calc(100vw - 24px));
    height: min(580px, calc(100vh - 120px));
    background: var(--ai-bg);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ai-border);
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.28s ease;
}

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

.ai-panel--page {
    position: relative;
    bottom: auto;
    left: auto;
    width: 100%;
    max-width: 900px;
    height: min(680px, 75vh);
    margin: 0 auto;
    transform: none;
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.ai-header {
    background: linear-gradient(135deg, var(--ai-primary), #002a5c);
    color: #fff;
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.ai-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--ai-accent);
    flex-shrink: 0;
}

.ai-header-info h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
}

.ai-header-info p {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    opacity: 0.75;
}

.ai-header-actions {
    margin-left: auto;
    display: flex;
    gap: 0.4rem;
}

.ai-icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.ai-icon-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Auth gate */
.ai-auth {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    gap: 1rem;
    background: var(--ai-surface);
}

.ai-auth-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), #002a5c);
    color: var(--ai-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.ai-auth h4 {
    margin: 0;
    color: var(--ai-primary);
    font-size: 1.05rem;
}

.ai-auth p {
    margin: 0;
    color: var(--ai-muted);
    font-size: 0.875rem;
    line-height: 1.5;
    max-width: 280px;
}

.ai-google-btn-wrap {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-auth-note {
    font-size: 0.72rem !important;
    color: #9ca3af !important;
    max-width: 260px !important;
}

.ai-auth-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.8rem;
    max-width: 300px;
    line-height: 1.4;
}

.ai-unavailable {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.78rem;
    padding: 0.55rem 1rem;
    text-align: center;
    flex-shrink: 0;
}

.ai-unavailable a {
    color: #b45309;
    font-weight: 600;
}

.ai-logout-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--ai-border);
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    font-size: 0.68rem;
    color: var(--ai-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.ai-logout-btn:hover {
    color: var(--ai-primary);
    border-color: var(--ai-primary);
}

/* Messages area */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

.ai-msg {
    max-width: 88%;
    padding: 0.65rem 0.85rem;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.ai-msg--assistant {
    align-self: flex-start;
    background: var(--ai-surface);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.ai-msg--user {
    align-self: flex-end;
    background: var(--ai-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg--error {
    align-self: center;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: 0.8rem;
    max-width: 95%;
    text-align: center;
}

.ai-msg--typing {
    align-self: flex-start;
    background: var(--ai-surface);
    color: var(--ai-muted);
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.75rem 1rem;
}

.ai-msg--typing span {
    width: 7px;
    height: 7px;
    background: var(--ai-muted);
    border-radius: 50%;
    animation: ai-bounce 1.2s infinite ease-in-out;
}

.ai-msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-msg--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.ai-msg a {
    color: var(--ai-accent-hover);
    text-decoration: underline;
}

.ai-msg--user a {
    color: var(--ai-accent-light, #f5d76e);
}

/* Quick suggestions */
.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.5rem;
    flex-shrink: 0;
}

.ai-suggestion {
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    color: var(--ai-primary);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    line-height: 1.3;
}

.ai-suggestion:hover {
    background: var(--ai-surface);
    border-color: var(--ai-accent);
}

/* Input area */
.ai-input-area {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--ai-border);
    flex-shrink: 0;
    background: #fff;
}

.ai-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.ai-input:focus {
    border-color: var(--ai-accent);
}

.ai-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: var(--ai-accent);
    color: var(--ai-primary);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-send-btn:hover:not(:disabled) {
    background: var(--ai-accent-hover);
    color: #fff;
}

.ai-send-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ai-user-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--ai-surface);
    border-top: 1px solid var(--ai-border);
    font-size: 0.75rem;
    color: var(--ai-muted);
    flex-shrink: 0;
}

.ai-user-bar img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
}

.ai-user-bar span {
    color: var(--ai-primary);
    font-weight: 600;
}

/* Page layout */
.ai-page-hero {
    background: linear-gradient(135deg, var(--ai-primary), #002a5c);
    color: #fff;
    padding: 4rem 1.5rem 3rem;
    text-align: center;
}

.ai-page-hero h1 {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    margin-bottom: 0.75rem;
}

.ai-page-hero p {
    opacity: 0.85;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
}

.ai-page-container {
    padding: 2rem 1.5rem 4rem;
    background: var(--ai-surface);
}

@media (max-width: 768px) {
    .ai-launcher {
        bottom: 20px;
        left: 20px;
        width: 55px;
        height: 55px;
    }

    .ai-panel {
        bottom: 85px;
        left: 12px;
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-panel,
    .ai-launcher,
    .ai-msg--typing span {
        transition: none !important;
        animation: none !important;
    }
}
