/**
 * Chat Page Styles - Mobile-First Full Page Experience
 * Optimized for mobile with complex product integration
 */

/* ========== Reset & Base ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.chat-page-body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.chat-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

/* ========== Header ========== */
.chat-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--chat-primary-color, #2E8B57) 0%, var(--chat-primary-color, #2E8B57) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

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

.btn-back:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #000000;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-status {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
}

/* Customer Badge in Header */
.customer-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.customer-badge i {
    font-size: 10px;
}

.header-right {
    display: flex;
    gap: 8px;
}

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

.btn-header-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== Messages Container ========== */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

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

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

.chat-messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--chat-primary-color, #2E8B57) 0%, var(--chat-primary-color, #2E8B57) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.welcome-title {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 10px;
}

.welcome-text {
    font-size: 15px;
    color: #718096;
    line-height: 1.6;
}

/* Messages List */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Chat Message */
.chat-message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #000000;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 15px;
    color: #2d3748;
}

.chat-message.user .message-bubble {
    background: var(--chat-primary-color, #2E8B57);
    color: white;
}

.message-time {
    font-size: 11px;
    color: #a0aec0;
    padding: 0 8px;
}

/* Product Cards in Chat */
.chat-products-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.chat-product-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-product-card:hover {
    border-color: var(--chat-primary-color, #2E8B57);
    box-shadow: 0 4px 12px rgba(46, 139, 87, 0.15);
}

.product-card-link {
    display: flex;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

.product-card-link:hover .chat-product-name {
    color: var(--chat-primary-color, #2E8B57);
}

.chat-product-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f8f9fa;
}

.chat-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* Product Card Actions */
.product-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.btn-add-to-cart {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--chat-primary-color, #2E8B57);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(46, 139, 87, 0.2);
}

.btn-add-to-cart:hover:not(:disabled) {
    background: #267049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 139, 87, 0.3);
}

.btn-add-to-cart:active:not(:disabled) {
    transform: translateY(0);
}

.btn-add-to-cart.success {
    background: #10b981;
    animation: successPulse 0.6s ease;
}

.btn-add-to-cart:disabled,
.btn-add-to-cart.disabled {
    background: #cbd5e0;
    color: #718096;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-add-to-cart i {
    font-size: 14px;
}

.chat-product-name {
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

.chat-product-category {
    font-size: 11px;
    color: #718096;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.chat-product-price {
    font-weight: 700;
    font-size: 15px;
    color: var(--chat-primary-color, #2E8B57);
    margin-top: auto;
}

.chat-product-stock {
    font-size: 11px;
    font-weight: 500;
}

.chat-product-stock.in-stock {
    color: #10b981;
}

.chat-product-stock.low-stock {
    color: #f59e0b;
}

.chat-product-stock.out-of-stock {
    color: #ef4444;
}

/* Product Context Card */
.product-context-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px dashed #38bdf8;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

.context-label {
    font-size: 12px;
    color: #0c4a6e;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.context-product {
    display: flex;
    gap: 12px;
    align-items: center;
    background: white;
    border-radius: 8px;
    padding: 10px;
}

.context-product img {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
}

.context-info {
    flex: 1;
}

.context-name {
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 4px;
}

.context-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--chat-primary-color, #2E8B57);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 0;
    animation: fadeIn 0.3s ease;
}

.typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #000000;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.typing-dots {
    background: white;
    padding: 12px 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 6px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typing 1.4s infinite;
}

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

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

/* Quick Replies */
.quick-replies-container {
    padding: 0 16px 12px;
    flex-shrink: 0;
    background: #f8f9fa;
}

.quick-replies {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.quick-replies::-webkit-scrollbar {
    height: 4px;
}

.quick-replies::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.quick-reply-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.quick-reply-btn:hover {
    background: var(--chat-primary-color, #2E8B57);
    color: white;
    border-color: var(--chat-primary-color, #2E8B57);
    transform: translateY(-2px);
}

/* Input Area */
.chat-input-container {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.chat-input-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-field {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s;
    background: #f8f9fa;
    color: #718096;
}

.chat-input-field:focus {
    border-color: var(--chat-primary-color, #2E8B57);
    background: white;
    color: #000000;
}

.btn-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chat-primary-color, #2E8B57);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(46, 139, 87, 0.3);
    font-size: 18px;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(46, 139, 87, 0.4);
}

.btn-send:active {
    transform: scale(0.95);
}

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

/* ========== Animations ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ========== Responsive ========== */
@media (min-width: 768px) {
    .chat-page {
        max-width: 600px;
        margin: 0 auto;
        height: 100vh;
        border-left: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
    }

    .chat-page-header {
        padding: 16px 20px;
    }

    .header-title {
        font-size: 18px;
    }

    .chat-messages-container {
        padding: 20px;
    }

    .chat-input-container {
        padding: 16px 20px;
    }

    .chat-product-image {
        width: 90px;
        height: 90px;
    }
}

@media (max-width: 360px) {
    .chat-product-image {
        width: 70px;
        height: 70px;
    }

    .chat-product-name {
        font-size: 13px;
    }

    .chat-input-field {
        font-size: 14px;
        padding: 10px 16px;
    }

    .btn-send {
        width: 44px;
        height: 44px;
    }

    .btn-add-to-cart {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ========== Toast Notifications ========== */
.chat-toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 90%;
    width: 400px;
}

.chat-toast {
    background: white;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: auto;
}

.chat-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.chat-toast-success {
    border-left: 4px solid #10b981;
}

.chat-toast-error {
    border-left: 4px solid #ef4444;
}

.chat-toast-info {
    border-left: 4px solid #3b82f6;
}

.chat-toast-content {
    flex: 1;
}

.chat-toast-message {
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
    line-height: 1.4;
}

/* Success pulse animation */
@keyframes successPulse {
    0% {
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
    }
    50% {
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
        transform: scale(1);
    }
}
