/**
 * Horizia Chat Widget Styles
 * Clean, modern chat interface
 */

/* Chat Toggle Button */
.chat-toggle {
    position: fixed !important;
    bottom: 2rem !important;
    right: 2rem !important;
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%) !important;
    color: white !important;
    border: 3px solid white !important;
    font-size: 0 !important;
    cursor: pointer !important;
    box-shadow: 0 6px 20px rgba(26, 35, 126, 0.4), 0 0 0 0 rgba(26, 35, 126, 0.1) !important;
    z-index: 1000 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-toggle::before {
    content: '💬';
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: transform 0.3s;
}

.chat-toggle:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 35, 126, 0.5), 0 0 0 4px rgba(26, 35, 126, 0.15);
}

.chat-toggle:hover::before {
    transform: scale(1.1);
}

.chat-toggle:active {
    transform: scale(1.05) translateY(0);
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 600px;
    max-height: calc(100vh - 4rem);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

.chat-widget--visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    display: flex !important;
}

/* Chat Header */
.chat-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    color: var(--color-text);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 64px;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.chat-logo {
    height: 40px;
    width: auto;
    max-width: 160px;
    min-width: 100px;
    object-fit: contain;
    filter: none;
    display: block;
    flex-shrink: 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

.chat-close {
    background: none;
    border: none;
    color: var(--color-text-light);
    font-size: 1.25rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.chat-close:hover {
    background: var(--color-bg-light);
    color: var(--color-text);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    max-width: 80%;
    padding: 1rem 1.125rem;
    border-radius: 12px;
    animation: slideIn 0.3s ease-out;
    margin-bottom: 0.75rem;
}

.chat-message--user {
    align-self: flex-end;
    background: var(--color-primary);
    color: white;
}

.chat-message--bot {
    align-self: flex-start;
    background: var(--color-bg-light);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.chat-message p {
    margin: 0;
    line-height: 1.7;
    word-wrap: break-word;
    color: inherit;
}

.chat-message p + p {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-message--user p + p {
    border-top-color: rgba(255, 255, 255, 0.25);
}

/* Bullet points and numbered lists */
.chat-message--bot ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    list-style: none;
}

.chat-message--bot ul li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.875rem;
    line-height: 1.7;
    padding-top: 0.125rem;
    display: block;
    break-inside: avoid;
}

.chat-message--bot ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: bold;
    font-size: 1.3em;
    line-height: 1;
}

.chat-message--bot ul li:last-child {
    margin-bottom: 0;
}

/* Numbered lists */
.chat-message--bot ol {
    margin: 0.75rem 0;
    padding-left: 1.75rem;
    counter-reset: list-counter;
}

.chat-message--bot ol li {
    position: relative;
    margin-bottom: 0.875rem;
    line-height: 1.7;
    padding-left: 0.5rem;
    padding-top: 0.125rem;
    list-style: decimal;
    display: list-item;
    break-inside: avoid;
}

.chat-message--bot ol li:last-child {
    margin-bottom: 0;
}

/* Bold and italic text */
.chat-message--bot strong,
.chat-message--bot b {
    font-weight: 600;
    color: var(--color-text);
}

.chat-message--bot em,
.chat-message--bot i {
    font-style: italic;
}

/* Section headers in messages */
.chat-message--bot p strong:first-child {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.05em;
    color: var(--color-primary);
}

/* Better spacing for structured content */
.chat-message--bot ul + p,
.chat-message--bot ol + p,
.chat-message--bot p + ul,
.chat-message--bot p + ol {
    margin-top: 1rem;
}

/* Typing Indicator */
.chat-typing {
    background: var(--color-bg-light);
    padding: 0.75rem 1rem;
}

.chat-typing p {
    display: flex;
    gap: 0.25rem;
    margin: 0;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-light);
    animation: typing 1.4s infinite;
}

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

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

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

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

/* Chat Input Area */
.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 0.75rem;
    background: var(--color-bg-light);
    border-radius: 0 0 16px 16px;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--color-primary);
}

.chat-send {
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send:hover {
    background: var(--color-primary-dark);
}

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

/* Mobile Responsive */
@media (max-width: 767px) {
    .chat-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 56px;
        height: 56px;
    }
    
    .chat-toggle::before {
        font-size: 1.375rem;
    }
    
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 85vh;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }
    
    .chat-header {
        border-radius: 16px 16px 0 0;
        padding: 1rem 1.25rem;
        min-height: 72px;
    }
    
    .chat-header-content {
        gap: 0.75rem;
        align-items: center;
        flex: 1;
        min-width: 0;
    }
    
    .chat-logo {
        height: 44px;
        width: auto;
        max-width: 180px;
        min-width: 120px;
        object-fit: contain;
        display: block;
        flex-shrink: 0;
    }
    
    .chat-header h3 {
        font-size: 0.9375rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-shrink: 1;
        min-width: 0;
    }
    
    .chat-close {
        width: 32px;
        height: 32px;
        font-size: 1.125rem;
        padding: 0;
    }
    
    .chat-messages {
        padding: 0.875rem;
        gap: 0.75rem;
    }
    
    .chat-message {
        max-width: 85%;
        padding: 0.75rem 0.875rem;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .chat-message p {
        line-height: 1.6;
        font-size: 0.875rem;
    }
    
    .chat-message p + p {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }
    
    .chat-message--bot ul,
    .chat-message--bot ol {
        margin: 0.5rem 0;
        padding-left: 1.25rem;
    }
    
    .chat-message--bot ul li,
    .chat-message--bot ol li {
        margin-bottom: 0.5rem;
        line-height: 1.6;
        font-size: 0.875rem;
    }
    
    .chat-input-area {
        border-radius: 0;
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .chat-input {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
        border-radius: 8px;
    }
    
    .chat-send {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        border-radius: 8px;
    }
}

/* Tablet Responsive */
@media (min-width: 768px) and (max-width: 1023px) {
    .chat-toggle {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 60px;
        height: 60px;
    }
    
    .chat-toggle::before {
        font-size: 1.5rem;
    }
    
    .chat-widget {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 360px;
        max-width: calc(100vw - 3rem);
        height: 580px;
        max-height: calc(100vh - 3rem);
    }
    
    .chat-header {
        padding: 0.625rem 0.875rem;
        min-height: 48px;
    }
    
    .chat-header-content {
        gap: 0.625rem;
    }
    
    .chat-logo {
        height: 38px;
        width: auto;
        max-width: 150px;
        min-width: 110px;
        object-fit: contain;
        display: block;
        flex-shrink: 0;
    }
    
    .chat-header h3 {
        font-size: 0.9375rem;
    }
    
    .chat-close {
        width: 30px;
        height: 30px;
        font-size: 1.25rem;
    }
    
    .chat-messages {
        padding: 1rem;
        gap: 0.875rem;
    }
    
    .chat-message {
        max-width: 82%;
        padding: 0.875rem 1rem;
        margin-bottom: 0.625rem;
        font-size: 0.9375rem;
    }
    
    .chat-message p {
        line-height: 1.65;
        font-size: 0.9375rem;
    }
    
    .chat-message p + p {
        margin-top: 0.875rem;
        padding-top: 0.875rem;
    }
    
    .chat-message--bot ul,
    .chat-message--bot ol {
        margin: 0.625rem 0;
        padding-left: 1.375rem;
    }
    
    .chat-message--bot ul li,
    .chat-message--bot ol li {
        margin-bottom: 0.625rem;
        line-height: 1.65;
        font-size: 0.9375rem;
    }
    
    .chat-input-area {
        padding: 0.875rem;
        gap: 0.625rem;
    }
    
    .chat-input {
        padding: 0.6875rem 0.875rem;
        font-size: 0.9375rem;
    }
    
    .chat-send {
        padding: 0.6875rem 1.25rem;
        font-size: 0.9375rem;
    }
}

/* Callback Form Styles */
.chat-callback-form {
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid var(--color-border);
}

.chat-form-header {
    margin-bottom: 1rem;
}

.chat-form-header h4 {
    font-size: 1rem;
    color: var(--color-heading);
    margin: 0;
}

.chat-form-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-form-fields input,
.chat-form-fields select,
.chat-form-fields textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-form-fields input:focus,
.chat-form-fields select:focus,
.chat-form-fields textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.chat-form-fields input[type="email"]:invalid:not(:placeholder-shown) {
    border-color: #dc3545;
}

.chat-form-fields textarea {
    resize: vertical;
    min-height: 80px;
}

.chat-form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-form-submit,
.chat-form-cancel {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-form-submit {
    background: var(--color-primary);
    color: white;
}

.chat-form-submit:hover:not(:disabled) {
    background: #3949ab;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26, 35, 126, 0.2);
}

.chat-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-form-cancel {
    background: #e0e0e0;
    color: var(--color-text);
}

.chat-form-cancel:hover {
    background: #d0d0d0;
}

/* Mobile Responsive for Callback Form */
@media (max-width: 767px) {
    .chat-callback-form {
        padding: 0.875rem;
    }
    
    .chat-form-fields input,
    .chat-form-fields select,
    .chat-form-fields textarea {
        padding: 0.625rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .chat-form-submit,
    .chat-form-cancel {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
}

