/**
 * Product Page AI Chat - Modern Frontend Styles
 * Version: 1.1.1 (Alignment, Hover, Suggestion order fixes)
 */

:root {
    --ppaichat-bg-container: #ffffff;
    --ppaichat-bg-messages: #f9f9f9;
    --ppaichat-bg-bubble-ai: #eef3fd; /* Lighter blue */
    --ppaichat-bg-bubble-user: #f0f0f0; /* Light grey */
    --ppaichat-text-color: #333333;
    --ppaichat-text-secondary: #666666;
    --ppaichat-accent-color: #007bff; /* Example: Bootstrap primary blue */
    --ppaichat-accent-text-color: #ffffff;
    --ppaichat-border-color: #e0e0e0;
    --ppaichat-border-radius: 12px; /* Softer corners */
    --ppaichat-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --ppaichat-font-family: inherit; /* Inherit from theme */
    --ppaichat-star-color: #ffc107; /* Gold */
    --ppaichat-star-color-inactive: #cccccc;
}

/* --- Main Container --- */
.ppaichat-container {
    font-family: var(--ppaichat-font-family);
    color: var(--ppaichat-text-color);
    background-color: var(--ppaichat-bg-container);
    border-radius: var(--ppaichat-border-radius);
    box-shadow: var(--ppaichat-shadow);
    overflow: hidden;
    max-width: 600px;
    margin: 30px auto;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid #0081983d;
}

/* --- Message Area --- */
.ppaichat-messages {
    flex-grow: 1;
    max-height: 450px;
    overflow-y: auto;
    padding: 15px;
    background-color: var(--ppaichat-bg-messages);
    scroll-behavior: smooth;
    border-bottom: 1px solid var(--ppaichat-border-color);
}

/* Scrollbar styling */
.ppaichat-messages::-webkit-scrollbar { width: 6px; }
.ppaichat-messages::-webkit-scrollbar-track { background: transparent; }
.ppaichat-messages::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.15); border-radius: 6px; }
.ppaichat-messages::-webkit-scrollbar-thumb:hover { background-color: rgba(0,0,0,0.25); }

/* --- Message Bubbles --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-bubble {
    padding: 10px 15px;
    border-radius: var(--ppaichat-border-radius);
    margin-bottom: 10px;
    max-width: 85%;
    line-height: 1.5;
    word-wrap: break-word;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-bubble.ai {
    background-color: var(--ppaichat-bg-bubble-ai);
    border-bottom-left-radius: 4px;
    margin-right: auto;
    color: #2c3e50;
}
/* <<< ADDED Text Align Left for AI */
.chat-bubble.ai p {
    text-align: left;
}


.chat-bubble.you {
    background-color: var(--ppaichat-bg-bubble-user);
    border-bottom-right-radius: 4px;
    margin-left: auto;
    color: var(--ppaichat-text-color);
}
/* <<< ADDED Text Align Right for User */
.chat-bubble.you p {
    text-align: right;
}

.chat-bubble .label {
    display: block;
    font-size: 0.75em;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--ppaichat-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.chat-bubble.you .label { text-align: right; }

.chat-bubble p {
    margin: 0;
    padding: 0;
    font-size: 0.95em;
}
.chat-bubble p strong { font-weight: 600; }

/* System messages */
.chat-bubble.system {
    background-color: #fffbe6; color: #8a6d3b;
    font-style: italic; font-size: 0.9em; text-align: center;
    max-width: 100%; border: 1px solid #ffeeba; border-radius: 4px;
    box-shadow: none;
}
#offline-message { background-color: #fffbe6 !important; }
.chat-bubble.ppaichat-progress {
    background-color: #f5f5f5;
    color: #7a7a7a;
    font-style: italic;
}


/* --- Input Area --- */
.ppaichat-input {
    display: flex;
    align-items: flex-end;
    padding: 10px 15px;
    background-color: var(--ppaichat-bg-container);
    /* <<< ADDED Border Top */
    border-top: 1px solid var(--ppaichat-border-color);
}

#chat-input {
    flex-grow: 1; min-height: 45px; max-height: 150px; resize: vertical;
    padding: 10px 15px; border: 1px solid var(--ppaichat-border-color);
    border-radius: var(--ppaichat-border-radius);
    background-color: var(--ppaichat-bg-messages);
    font-family: var(--ppaichat-font-family); font-size: 0.95em; line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-right: 10px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
#chat-input:focus {
    outline: none; border-color: var(--ppaichat-accent-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

#chat-submit {
    flex-shrink: 0; padding: 10px 15px;
    background-color: var(--ppaichat-accent-color);
    color: var(--ppaichat-accent-text-color);
    border: none; border-radius: var(--ppaichat-border-radius);
    cursor: pointer; font-size: 0.95em; font-weight: 500;
    line-height: 1.4; transition: background-color 0.2s ease, opacity 0.2s ease, filter 0.2s ease; /* <<< ADDED filter */
    height: 45px;
}

/* <<< UPDATED Hover Style */
#chat-submit:hover,
#chat-submit:focus {
    /* background-color: darken(var(--ppaichat-accent-color), 10%); */ /* Removed non-standard function */
    filter: brightness(90%); /* Darken background slightly */
    outline: none;
    /* Text color remains white (var(--ppaichat-accent-text-color)) */
}
#chat-submit:disabled {
    background-color: #cccccc; cursor: not-allowed; opacity: 0.7; filter: none; /* Remove filter when disabled */
}


/* --- Suggested Questions --- */
/* <<< MOVED DOWN in template, now below input */
.ppaichat-suggestions {
    padding: 10px 15px;
    background-color: #fdfdfd; /* Slightly different background maybe */
    border-top: 1px solid var(--ppaichat-border-color); /* Separator from input */
    display: flex; /* Use flexbox for alignment */
    align-items: center; /* <<< Vertically align title and chips */
    gap: 10px; /* Spacing between title and list */
    flex-wrap: wrap; /* Allow wrapping if many suggestions */
}

/* <<< ADDED Style for Title */
.suggestion-title {
    margin: 0;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--ppaichat-text-secondary);
    flex-shrink: 0; /* Prevent title from shrinking */
}

/* <<< ADDED Wrapper for Chips */
.suggestion-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Spacing between individual suggestions */
}

.suggestion {
    display: inline-block; padding: 6px 12px; background: transparent;
    border: 1px solid var(--ppaichat-accent-color); color: var(--ppaichat-accent-color);
    font-size: 0.85em; cursor: pointer; border-radius: 20px; /* Pill shape */
    transition: all 0.2s ease-in-out;
}
.suggestion:hover,
.suggestion:focus {
    background-color: var(--ppaichat-accent-color);
    color: var(--ppaichat-accent-text-color) !important;
    border-color: var(--ppaichat-accent-color);
    outline: none;
}


/* --- Rating Section --- */
.ppaichat-rating.sticky {
    position: sticky; bottom: 0; background: #fff;
    padding: 10px 15px; border-top: 1px solid var(--ppaichat-border-color);
    z-index: 10; transition: opacity 0.3s ease;
}
.ppaichat-rating.hidden { display: none; }

.ppaichat-rating p {
    margin: 0 0 8px 0; font-size: 0.9em; font-weight: 500;
    color: var(--ppaichat-text-secondary);
}

.stars { display: flex; gap: 5px; margin-bottom: 10px; transition: opacity 0.3s ease; }
.stars.hidden { opacity: 0; pointer-events: none; }

.stars .star {
    font-size: 24px; /* <<< ADJUST THIS VALUE (e.g., 18px, 19px, 20px) until visually correct */
    display: inline-block;  /* Override display: block; Allows stars on same line */
    float: none;            /* Override float: left; */
    width: auto;            /* Override width: 14px; Let font-size control width */
    height: auto;           /* Let font-size control height */
    overflow: visible;      /* Override overflow: hidden; */
    position: static;       /* Override position: relative; */
    top: auto;              /* Override top: -1px; */
    font-weight: normal;    /* Ensure normal weight if theme changes it */
    color: var(--ppaichat-star-color-inactive);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;         /* Prevent extra line spacing */
    vertical-align: middle; /* Align stars nicely if on the same line */
    text-align: center;
}
.stars .star:hover { transform: scale(1.2); color: var(--ppaichat-star-color); }
.stars .star.active { color: var(--ppaichat-star-color); }
.stars .star.disabled { cursor: default; opacity: 0.6; }
.stars .star.disabled:hover { transform: none; color: var(--ppaichat-star-color-inactive); }
.stars .star.active.disabled:hover { color: var(--ppaichat-star-color); }


/* --- Feedback Area --- */
.feedback { margin-top: 10px; border-top: 1px dashed var(--ppaichat-border-color); padding-top: 10px; }
.feedback.hidden { display: none; }

.feedback textarea {
    width: 100%; min-height: 60px; max-height: 120px; resize: vertical;
    padding: 8px 12px; border: 1px solid var(--ppaichat-border-color);
    border-radius: 8px; background-color: #fff;
    font-family: var(--ppaichat-font-family); font-size: 0.9em; line-height: 1.4;
    margin-bottom: 8px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
.feedback textarea:focus {
     outline: none; border-color: var(--ppaichat-accent-color);
     box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.feedback button.feedback-submit {
    padding: 8px 15px; background-color: var(--ppaichat-accent-color);
    color: var(--ppaichat-accent-text-color); border: none; border-radius: 8px;
    cursor: pointer; font-size: 0.9em; font-weight: 500;
    transition: background-color 0.2s ease, filter 0.2s ease; /* <<< ADDED filter */
    float: right;
}
/* <<< UPDATED Hover Style */
.feedback button.feedback-submit:hover {
    /* background-color: darken(var(--ppaichat-accent-color), 10%); */
    filter: brightness(90%);
}

/* --- Rating Thank You Message --- */
.rating-thankyou {
    text-align: center; padding: 10px; font-size: 0.9em;
    color: #155724; background-color: #d4edda; border: 1px solid #c3e6cb;
    border-radius: 8px; margin-top: 10px; /* Add some margin */
}
.rating-thankyou.hidden { display: none; }


/* --- Loading Indicator (Spinner) --- */
.ppaichat-spinner-container { /* Wrapper for centering */
    text-align: center;
    padding: 15px;
}
.ppaichat-spinner {
    display: inline-block; /* Allow centering */
    width: 24px; height: 24px;
    border: 3px solid rgba(0, 123, 255, 0.2); border-top-color: var(--ppaichat-accent-color);
    border-radius: 50%; animation: ppaichat-spin 0.8s linear infinite;
}
@keyframes ppaichat-spin { to { transform: rotate(360deg); } }


/* --- Responsiveness --- */
@media (max-width: 767px) {
    .ppaichat-container {
        margin: 15px auto; max-width: 100%; border: 1px solid #0081983d;
    }
    .ppaichat-messages { max-height: 350px; }
    .chat-bubble { max-width: 90%; }
    .ppaichat-input { padding: 8px 10px; }
    #chat-input { 
        /* padding: 8px 12px;  */
        /* min-height: 40px;  */
        margin-right: 6px; }
    #chat-submit { padding: 8px 12px; height: 40px; }
    .ppaichat-rating.sticky { padding: 8px 10px; }
    .stars .star { font-size: 22px; }
    .ppaichat-suggestions {
        padding: 8px 10px;
        /* Adjust flex direction for mobile if needed */
        /* flex-direction: column;
        align-items: flex-start; */
    }
    .suggestion { padding: 5px 10px; font-size: 0.8em; }
    .suggestion-title { margin-bottom: 5px; /* Add space below title on mobile */ }
}

.submission-form-field{
	width:100%;
	border: none;
    border-radius: 5px;
}
.contact-form-submit{
	line-height: 1.5rem;
    border: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;	
	height: 3.5rem;
	margin: 20px 0;
}
