/* File Name: chat.css */
/* Petro AI Assistant - Premium Responsive UI */

:root {
    --petro: #108082;
    --petro-dark: #0a5e60;
    --petro-soft: #eaf8f7;
    --ink: #172126;
    --muted: #6f7c82;
    --line: #e4ecec;
    --surface: #ffffff;
    --page: #f5f8f8;
    --shadow: 0 14px 45px rgba(16, 128, 130, .10);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--page);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.chat-page {
    width: min(1120px, 100%);
    height: 100dvh;
    margin: 0 auto;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    background: var(--surface);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
}

.assistant-header-v2 {
    min-height: 82px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(14px);
    position: relative;
    z-index: 10;
}

.header-left-v2 {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.ai-logo-v2,
.message-avatar,
.welcome-icon,
.help-icon {
    display: grid;
    place-items: center;
}

.ai-logo-v2 {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    color: white;
    background: linear-gradient(145deg, var(--petro), var(--petro-dark));
    box-shadow: 0 8px 24px rgba(16, 128, 130, .22);
    position: relative;
    flex: 0 0 auto;
}

.ai-logo-v2 i {
    position: relative;
    z-index: 2;
}

.logo-glow {
    position: absolute;
    inset: -5px;
    border-radius: 20px;
    background: rgba(16,128,130,.10);
    z-index: 0;
}

.ai-title-box {
    min-width: 0;
}

.title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.title-row h1 {
    margin: 0;
    font-size: clamp(18px, 2.4vw, 24px);
    line-height: 1.15;
}

.ai-title-box p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .03em;
}

.ai-title-box p i {
    color: var(--petro);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border-radius: 999px;
    background: var(--petro-soft);
    color: var(--petro-dark);
    font-size: 11px;
    font-weight: 800;
}

.live-badge > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22ad66;
    box-shadow: 0 0 0 4px rgba(34,173,102,.12);
}

.back-btn-v2 {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--ink);
    background: #f4f7f7;
    text-decoration: none;
    border: 1px solid var(--line);
}

.chat-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 24px clamp(14px, 3vw, 32px) 30px;
    scroll-behavior: smooth;
}

#welcomeArea {
    display: contents;
}

.welcome-ai-card {
    padding: 22px;
    border: 1px solid rgba(16,128,130,.14);
    border-radius: 22px;
    background:
        radial-gradient(circle at 100% 0%, rgba(16,128,130,.12), transparent 34%),
        linear-gradient(135deg, #ffffff, #f4fbfa);
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.welcome-top {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.welcome-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--petro);
    color: #fff;
    flex: 0 0 auto;
}

.welcome-top h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.welcome-top p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.support-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 18px;
}

.support-tags span {
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: #4b5c62;
}

.support-tags i {
    color: var(--petro);
    margin-right: 5px;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 15px 0;
    animation: messageIn .18s ease-out;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    flex: 0 0 auto;
    margin-top: 3px;
    background: var(--petro-soft);
    color: var(--petro);
}

.message.user .message-avatar {
    background: #edf1f2;
    color: #435259;
}

.message-bubble {
    max-width: min(760px, 82%);
    padding: 12px 14px 13px;
    border: 1px solid var(--line);
    border-radius: 6px 18px 18px 18px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(20,45,50,.05);
}

.message.user .message-bubble {
    background: var(--petro);
    border-color: var(--petro);
    color: #fff;
    border-radius: 18px 6px 18px 18px;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 6px;
    font-size: 11px;
}

.message-meta strong {
    font-size: 12px;
}

.message-meta span {
    color: var(--muted);
    white-space: nowrap;
}

.message.user .message-meta span {
    color: rgba(255,255,255,.75);
}

.message-content {
    font-size: 14px;
    line-height: 1.62;
    overflow-wrap: anywhere;
}

.message-content p {
    margin: 7px 0;
}

.message-content p:first-child {
    margin-top: 0;
}

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

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.chat-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 5px 6px 5px 0;
    padding: 9px 11px;
    border-radius: 10px;
    text-decoration: none;
    background: var(--petro-soft);
    color: var(--petro-dark);
    font-weight: 800;
    font-size: 12px;
}

.message.user .chat-link-btn {
    background: rgba(255,255,255,.15);
    color: #fff;
}

.ai-help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0 24px 44px;
}

.help-card {
    width: 100%;
    display: flex;
    align-items: flex-start;
    text-align: left;
    gap: 12px;
    padding: 15px;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    color: inherit;
    transition: .18s ease;
}

.help-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16,128,130,.35);
    box-shadow: var(--shadow);
}

.help-icon {
    width: 39px;
    height: 39px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--petro-soft);
    color: var(--petro);
}

.help-card h3 {
    margin: 1px 0 4px;
    font-size: 14px;
}

.help-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.quick-buttons {
    display: flex;
    gap: 8px;
    padding: 9px 14px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
    background: #fff;
    scrollbar-width: none;
}

.quick-buttons::-webkit-scrollbar {
    display: none;
}

.quick-buttons button {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    background: #fff;
    color: #4c5a60;
    border-radius: 999px;
    padding: 9px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.quick-buttons button:hover {
    border-color: var(--petro);
    color: var(--petro);
}

.quick-buttons i {
    margin-right: 5px;
}

.chat-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 9px;
    padding: 12px 14px max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: #fff;
}

.input-wrap {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #dce5e6;
    border-radius: 15px;
    background: #f8fafa;
}

.input-wrap:focus-within {
    border-color: rgba(16,128,130,.55);
    box-shadow: 0 0 0 4px rgba(16,128,130,.08);
}

.input-wrap > i {
    color: #92a1a5;
}

#messageInput {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

#messageInput::placeholder {
    color: #9aa6a9;
}

#sendBtn {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 15px;
    background: var(--petro);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(16,128,130,.22);
}

#sendBtn:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.typing {
    display: inline-flex;
    gap: 4px;
    padding: 5px 1px;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ba8aa;
    animation: typingDot 1s infinite ease-in-out;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

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

@media (max-width: 700px) {
    .chat-page {
        border: 0;
    }

    .assistant-header-v2 {
        min-height: 72px;
        padding: 11px 13px;
    }

    .ai-logo-v2 {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }

    .live-badge {
        display: none;
    }

    .chat-messages {
        padding: 16px 12px 24px;
    }

    .welcome-ai-card {
        padding: 17px;
        border-radius: 18px;
    }

    .support-tags {
        gap: 7px;
    }

    .support-tags span {
        padding: 7px 9px;
    }

    .ai-help-grid {
        grid-template-columns: 1fr;
        margin-left: 0;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }

    .message-bubble {
        max-width: calc(100% - 42px);
        padding: 11px 12px;
    }

    .chat-footer {
        padding-left: 10px;
        padding-right: 10px;
    }
}
