/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.1rem;
    color: #718096;
    font-weight: 500;
}

/* Header content for chatbot page */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.store-info h1 {
    font-size: 2rem;
}

.session-info {
    display: flex;
    align-items: center;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #e2e8f0;
    color: #4a5568;
}

.status-badge.connected {
    background: #c6f6d5;
    color: #22543d;
}

.status-badge.connecting {
    background: #fef7c3;
    color: #744210;
}

.status-badge.error {
    background: #fed7d7;
    color: #822727;
}

/* Main content */
.main-content {
    display: grid;
    gap: 30px;
}

/* Stores section */
.stores-section h2,
.actions-section h2 {
    font-size: 1.8rem;
    color: white;
    margin-bottom: 20px;
    font-weight: 600;
}

.stores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.store-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.store-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.store-card h3 {
    font-size: 1.4rem;
    color: #2d3748;
    margin-bottom: 8px;
}

.store-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.store-header h3 {
    margin-bottom: 0;
    flex: 1;
}

.status-indicator {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
}

.status-indicator.active {
    background: #c6f6d5;
    color: #22543d;
}

.status-indicator.inactive {
    background: #fed7d7;
    color: #822727;
}

.store-card.inactive {
    opacity: 0.7;
    border: 2px dashed #e2e8f0;
}

.store-card.inactive:hover {
    opacity: 0.9;
}

.platform-id {
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 8px;
    font-family: 'Monaco', 'Menlo', monospace;
}

.uninstalled-info {
    margin-top: 8px;
    padding: 6px 10px;
    background: #fed7d7;
    color: #822727;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.store-card .platform {
    display: inline-block;
    padding: 4px 12px;
    background: #e2e8f0;
    color: #4a5568;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.store-card .platform.shopify {
    background: #c6f6d5;
    color: #22543d;
}

.store-card .platform.standalone {
    background: #bee3f8;
    color: #2a4365;
}

.store-card p {
    color: #718096;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.store-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #a0aec0;
}

/* Actions section */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.action-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.action-card h3 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 8px;
}

.action-card p {
    color: #718096;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    background: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}

.btn-back {
    background: rgba(255, 255, 255, 0.2);
    color: #2d3748;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

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

.btn-warning {
    background: #fbbf24;
    color: #92400e;
}

.btn-warning:hover {
    background: #f59e0b;
}

.btn-danger {
    background: #f87171;
    color: #991b1b;
}

.btn-danger:hover {
    background: #ef4444;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-content h2 {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 16px;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #a0aec0;
}

.close:hover {
    color: #2d3748;
}

/* Tabs */
.tab-container {
    display: flex;
    margin-bottom: 24px;
    background: #f7fafc;
    border-radius: 10px;
    padding: 4px;
}

.tab-button {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4a5568;
}

.tab-button.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #2d3748;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-text {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: #718096;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Chat interface */
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

.chat-interface {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-interface.visible {
    display: flex;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

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

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background: #f7fafc;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
    max-width: 90%;
}

.system-message {
    text-align: center;
    padding: 16px;
    margin-bottom: 20px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    color: #0369a1;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.assistant .message-avatar {
    background: #f7fafc;
    color: #4a5568;
}

/* Chat input */
.chat-input-container {
    border-top: 1px solid #e2e8f0;
    padding: 20px 24px;
    background: white;
}

.message-form {
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.input-group input:focus {
    border-color: #667eea;
}

.input-group input:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
}

.input-group button {
    padding: 12px 20px;
    border: none;
    border-radius: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.input-group button:disabled {
    background: #e2e8f0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Quick actions */
.quick-actions h4 {
    font-size: 0.9rem;
    color: #4a5568;
    margin-bottom: 12px;
    font-weight: 600;
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-btn {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-btn:hover {
    background: #f7fafc;
    border-color: #667eea;
    color: #667eea;
}

/* Session controls */
.session-controls {
    border-top: 1px solid #e2e8f0;
    padding: 16px 24px;
    background: #f8fafc;
    flex-shrink: 0;
    display: none;
}

.session-controls.visible {
    display: block;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-info-detailed {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: #4a5568;
}

.session-info-detailed code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    cursor: help;
}

.control-buttons {
    display: flex;
    gap: 12px;
}

.control-buttons .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* Loading indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: white;
}

.loading-indicator.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .stores-grid {
        grid-template-columns: 1fr;
    }
    
    .action-cards {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        height: calc(100vh - 120px);
    }
    
    .controls-row {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .session-info-detailed {
        justify-content: center;
    }
    
    .control-buttons {
        justify-content: center;
    }
}

/* Product cards in chat messages - Horizontal Scrollable */
.products-container {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin: 12px 0;
    width: 100%;
    padding: 8px 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    /* Remove min-height to let content define height */
}

/* Scrollbar styling - more subtle */
.products-container::-webkit-scrollbar {
    height: 8px;
}

.products-container::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 4px;
}

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

.products-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Product Card - Vertical Layout (Image on top) */
.product-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-width: 160px;
    max-width: 160px;
    flex-shrink: 0;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

.product-image-container {
    width: 100%;
    height: 140px;
    background: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f7fafc 0%, #e2e8f0 100%);
    color: #a0aec0;
    font-size: 2.5rem;
    font-weight: 500;
}

.product-card-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 38px;
}

.product-price {
    font-size: 1.05rem;
    font-weight: 700;
    color: #667eea;
    margin: 0;
}

.product-description {
    font-size: 0.85rem;
    color: #718096;
    line-height: 1.4;
    margin: 0;
    display: none; /* Hide description in compact view */
}

.message-text {
    margin: 8px 0;
    line-height: 1.6;
    white-space: normal;
}

.message-text span {
    display: block;
    margin-bottom: 4px;
}

/* Responsive product cards */
@media (max-width: 768px) {
    .products-container {
        min-height: 180px; /* Reduced height for mobile */
        gap: 8px;
        padding: 6px 0;
    }

    .product-card {
        min-width: 120px;
        max-width: 120px;
        padding: 8px;
    }
    
    .product-image-container {
        height: 90px; /* Smaller images on mobile */
    }
    
    .product-title {
        font-size: 0.8rem;
        min-height: 30px;
    }
    
    .product-price {
        font-size: 0.85rem;
    }

    .product-id {
        font-size: 0.7rem;
    }
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}
