/**
 * KSG Chat Widget Styles
 * Version: 3.0 - Enhanced Readability & Responsive
 */

/* Chart Animation Styles */
.chart-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 28px;
}

.chart-bar {
    width: 5px;
    background: linear-gradient(to top, #cbd300, #fff);
    border-radius: 2px;
    animation: chartEqualizer 1.2s ease-in-out infinite;
}

.bar-1 { height: 12px; animation-delay: 0s; }
.bar-2 { height: 20px; animation-delay: 0.2s; }
.bar-3 { height: 16px; animation-delay: 0.4s; }
.bar-4 { height: 24px; animation-delay: 0.1s; }

@keyframes chartEqualizer {
    0%, 100% { height: 8px; opacity: 0.6; }
    50% { height: 28px; opacity: 1; }
}

.chart-avatar-small {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bars-small {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 20px;
}

.chart-bar-sm {
    width: 4px;
    background: rgba(255,255,255,0.9);
    border-radius: 1px;
    animation: chartEqualizerSmall 1s ease-in-out infinite;
}

.bar-sm-1 { animation-delay: 0s; }
.bar-sm-2 { animation-delay: 0.15s; }
.bar-sm-3 { animation-delay: 0.3s; }

@keyframes chartEqualizerSmall {
    0%, 100% { height: 6px; opacity: 0.7; }
    50% { height: 18px; opacity: 1; }
}

/* Widget Close Button */
.widget-close-btn {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: all 0.3s;
    z-index: 10000;
    padding: 0;
}

.ksg-assistant-float:hover .widget-close-btn {
    opacity: 1;
}

.widget-close-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Widget Animation States */
.ksg-assistant-float.hiding {
    animation: fadeOutScale 0.4s ease forwards;
}

@keyframes fadeOutScale {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

/* Main Widget Styles */
.ksg-assistant-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #2c5f41 0%, #1a4d2e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(44, 95, 65, 0.4);
    z-index: 9999;
    border: 3px solid white;
    transition: all 0.3s ease;
}

.ksg-assistant-float:hover { 
    transform: scale(1.1); 
    box-shadow: 0 6px 30px rgba(44, 95, 65, 0.6); 
}

.assistant-avatar { 
    position: relative; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.assistant-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #cbd300;
    color: #1a4d2e;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Container - Larger & Responsive */
.ksg-chat-container {
    position: fixed;
    bottom: 95px;
    right: 20px;
    width: 480px;
    max-width: calc(100vw - 30px);
    height: 720px;
    max-height: calc(100vh - 110px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    border: 1px solid rgba(0,0,0,0.08);
}

.ksg-chat-container.active { 
    display: flex; 
}

/* Tablet Responsiveness */
@media (max-width: 768px) {
    .ksg-chat-container {
        width: calc(100vw - 30px);
        right: 15px;
        height: 75vh;
        bottom: 85px;
        border-radius: 16px;
    }
    .ksg-assistant-float {
        width: 55px;
        height: 55px;
        bottom: 15px;
        right: 15px;
    }
}

/* Small Mobile Responsiveness */
@media (max-width: 480px) {
    .ksg-chat-container {
        width: calc(100vw - 20px);
        right: 10px;
        height: 80vh;
        bottom: 75px;
        border-radius: 14px;
    }
    .ksg-assistant-float {
        width: 50px;
        height: 50px;
        bottom: 12px;
        right: 12px;
    }
    .chat-messages {
        padding: 14px;
        gap: 12px;
    }
    .message-content {
        padding: 10px 14px;
        font-size: 15px;
    }
    .chat-input-area {
        padding: 12px 14px;
    }
    .program-suggestion {
        padding: 14px;
    }
    .program-suggestion h5 {
        font-size: 15px;
    }
}

/* Very Small Mobile */
@media (max-width: 360px) {
    .ksg-chat-container {
        width: calc(100vw - 16px);
        right: 8px;
        height: 82vh;
        bottom: 70px;
    }
    .message {
        max-width: 92%;
    }
    .message-avatar {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
    .message.bot .message-avatar img {
        width: 26px;
        height: 26px;
    }
}

.chat-header {
    background: linear-gradient(135deg, #2c5f41 0%, #1a4d2e 100%);
    color: white;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-title { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
}

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

.chat-title .name { 
    display: block; 
    font-weight: 600; 
    font-size: 17px; 
    font-family: 'Cinzel', serif; 
}

.chat-title .status {
    display: block;
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-title .status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.close-chat {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-chat:hover { 
    background: rgba(255,255,255,0.3); 
    transform: rotate(90deg); 
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: slideIn 0.3s ease;
    max-width: 88%;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0;
    color: white;
}

.message.bot .message-avatar { 
    background: transparent; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden;
}

.message.bot .message-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.message.user .message-avatar { 
    background: #cbd300; 
    color: #1a4d2e; 
}

.message-content {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15.5px;
    line-height: 1.65;
    word-wrap: break-word;
    letter-spacing: 0.01em;
}

.message.bot .message-content {
    background: white;
    color: #1e293b;
    border-bottom-left-radius: 6px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
}

.message.user .message-content {
    background: linear-gradient(135deg, #2c5f41 0%, #1a4d2e 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-content strong {
    color: #1a4d2e;
    font-weight: 700;
}

.message.user .message-content strong {
    color: #cbd300;
}

.message-content em {
    color: #475569;
    font-style: italic;
}

.message.user .message-content em {
    color: rgba(255,255,255,0.85);
}

/* Numbered List Styling within Messages */
.message-content .option-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
}

.message-content .option-line:last-child {
    border-bottom: none;
}

.message-content .option-line-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #2c5f41 0%, #1a4d2e 100%);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.message-content .option-line-text {
    flex: 1;
    font-weight: 500;
}

.message-content .option-hint {
    display: block;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    color: #64748b;
    font-size: 13px;
}

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 18px;
    background: white;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    width: fit-content;
}

.typing-indicator span {
    width: 9px;
    height: 9px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.option-chip {
    padding: 14px 18px;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
}

.option-chip:hover {
    background: #cbd300;
    border-color: #cbd300;
    color: #1a4d2e;
    transform: translateX(4px);
}

.option-chip.selected {
    background: #2c5f41;
    color: white;
}

.option-chip .count {
    background: rgba(44, 95, 65, 0.1);
    color: #2c5f41;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.option-chip:hover .count {
    background: rgba(255,255,255,0.3);
    color: #1a4d2e;
}

.option-chip.selected .count {
    background: rgba(255,255,255,0.2);
    color: white;
}

.option-chip .arrow {
    opacity: 0;
    transition: opacity 0.2s;
    font-weight: bold;
}

.option-chip:hover .arrow { 
    opacity: 1; 
}

.section-header {
    font-size: 13px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 10px;
    font-weight: 600;
}

/* Program Cards - Enhanced */
.program-suggestion {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 18px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.3s;
    animation: slideIn 0.4s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.program-suggestion:hover {
    border-color: #cbd300;
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0,0,0,0.12);
}

.program-suggestion h5 {
    margin: 0 0 10px 0;
    color: #1a4d2e;
    font-size: 16px;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    line-height: 1.4;
}

.program-suggestion p {
    margin: 0 0 14px 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.program-meta-small {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: #b8860b;
    font-weight: 600;
    margin-bottom: 14px;
}

.program-meta-small span {
    background: #fefce8;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #fde047;
}

.action-buttons { 
    display: flex; 
    gap: 10px; 
    flex-wrap: wrap;
}

.btn-mini {
    flex: 1;
    min-width: 70px;
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-save { 
    background: #f1f5f9; 
    color: #1e293b; 
}

.btn-save:hover { 
    background: #e2e8f0; 
}

.btn-save.saved { 
    background: #fef3c7; 
    color: #d97706; 
}

.btn-brochure { 
    background: #cbd300; 
    color: #1a4d2e; 
}

.btn-brochure:hover { 
    background: #a8b000; 
}

.btn-view { 
    background: #f1f5f9; 
    color: #1e293b; 
}

.btn-view:hover { 
    background: #e2e8f0; 
}

.fallback-banner {
    background: linear-gradient(90deg, #fef3c7 0%, #fffbeb 100%);
    border: 1px solid #f59e0b;
    border-radius: 12px;
    padding: 18px;
    margin: 14px 0;
    text-align: center;
}

.fallback-banner p { 
    margin: 0 0 14px 0; 
    font-size: 15px; 
    color: #1e293b; 
}

.btn-fallback {
    display: inline-block;
    background: #2c5f41;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.btn-fallback:hover { 
    background: #1a4d2e; 
}

/* Email Popup Styles */
.email-popup {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
    z-index: 10000;
    padding: 24px;
    animation: popIn 0.3s ease;
}

.email-popup.active { 
    display: block; 
}

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

.email-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #cbd300 0%, #a8b000 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.email-popup h4 {
    margin: 0 0 8px 0;
    color: #2c5f41;
    text-align: center;
    font-family: 'Cinzel', serif;
}

.email-popup p { 
    margin: 0 0 16px 0; 
    color: #64748b; 
    text-align: center; 
    font-size: 14px; 
}

.email-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 16px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.email-input:focus { 
    outline: none; 
    border-color: #cbd300; 
}

.email-actions { 
    display: flex; 
    gap: 12px; 
}

.btn-text {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-text:hover { 
    background: #f1f5f9; 
}

.email-actions .btn-primary {
    flex: 2;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    background: #2c5f41;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.success-check {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    animation: scaleIn 0.5s ease;
    color: white;
    font-size: 30px;
}

@keyframes scaleIn { 
    from { transform: scale(0); } 
    to { transform: scale(1); } 
}

/* Chat Input Styles */
.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 14px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
}

.chat-input-wrapper:focus-within {
    border-color: #1a4d2e;
    box-shadow: 0 0 0 3px rgba(26, 77, 46, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 16px;
    color: #1a4d2e;
    outline: none;
    font-family: inherit;
    font-weight: 500;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-submit {
    background: linear-gradient(135deg, #1a4d2e 0%, #2d6a4f 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(26, 77, 46, 0.3);
    flex-shrink: 0;
}

.chat-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26, 77, 46, 0.4);
}

.input-hint {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

/* Animation Keyframes */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

@keyframes chartEq1 {
    0%, 100% { height: 8px; }
    50% { height: 16px; }
}

@keyframes chartEq2 {
    0%, 100% { height: 12px; }
    50% { height: 6px; }
}

@keyframes chartEq3 {
    0%, 100% { height: 6px; }
    50% { height: 14px; }
}

/* Enhanced chat styles */
#emailPopup.active {
    display: flex;
    animation: fadeInUp 0.3s ease;
}

.success-check {
    color: #22c55e;
    font-size: 24px;
    text-align: center;
    margin: 10px 0;
    font-weight: bold;
}

.program-suggestion {
    transition: all 0.3s ease;
}

.program-suggestion:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

/* Persistent Chat Input Area */
.chat-input-area {
    padding: 18px 22px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chat-input-area .chat-input-wrapper {
    margin: 0;
}

.chat-input-area .input-hint {
    margin-top: 10px;
    margin-bottom: 0;
    text-align: center;
}

@media (max-width: 480px) {
    .chat-input-area {
        padding: 14px;
    }
    .chat-input-wrapper {
        padding: 12px;
    }
    .chat-input {
        font-size: 16px;
    }
    .chat-submit {
        padding: 10px 14px;
    }
    .input-hint {
        font-size: 12px;
    }
}
