/* Brand guideline colors and styles */
:root {
    --primary-accent: #6d0f39; /* maroon */
    --secondary-accent: #334fb4; /* blue */
    --color-foreground: rgba(18, 18, 18, 0.8);
    --background-color: #ffffff;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-800: #1f2937;
    --border-radius: 16px; /* rounded-2xl */
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--color-foreground);
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 25px;
    margin-top: 10px;
}

.header-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.header-logo a {
    display: block;
}

.header-logo-img {
    max-width: 100%;
    height: auto;
    max-height: 100px;
    display: block;
}

header p {
    color: var(--gray-600);
    margin-bottom: 16px;
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* Chat Container */
.chat-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 30px;
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

/* Messages */
.message {
    margin-bottom: 16px;
    display: flex;
    max-width: 80%;
}

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
    margin-left: auto;
}

.message-content {
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 500;
    max-width: 20rem;
}

.bot-message .message-content {
    background-color: var(--gray-200);
    color: var(--gray-800);
    border-radius: 16px 16px 16px 6px; /* rounded-2xl with rounded-bl-md */
}

.user-message .message-content {
    background-color: #3b82f6; /* blue-500 */
    color: white;
    border-radius: 16px 16px 6px 16px; /* rounded-2xl with rounded-br-md */
}

/* Confirmation Messages */
.confirmation-message {
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 16px;
}

.confirmation-buttons {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.confirm-btn {
    background-color: var(--success-color);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.confirm-btn:hover {
    opacity: 0.9;
}

.cancel-btn {
    background-color: var(--gray-300);
    color: var(--gray-600);
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 14px;
}

.cancel-btn:hover {
    background-color: var(--gray-200);
}

/* Input Section */
.chat-input-container {
    padding: 20px;
    background-color: #f9fafb;
}

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

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    resize: vertical;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    color: var(--color-foreground);
}

#messageInput::placeholder {
    color: var(--gray-400);
}

#messageInput:focus {
    border-color: var(--secondary-accent);
    box-shadow: 0 0 0 3px rgba(51, 79, 180, 0.1);
}

#sendButton {
    background-color: var(--primary-accent);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    min-width: 44px;
}

#sendButton:hover {
    background-color: #5a0c2f;
}

#sendButton svg {
    transition: transform 0.2s;
}

#sendButton:hover svg {
    transform: translateX(2px);
}

.dots-loader {
    display: flex;
    gap: 2px;
    justify-content: center;
    align-items: center;
}

.dots-loader div {
    width: 4px;
    height: 4px;
    background-color: white;
    border-radius: 50%;
    animation: dots-pulse 1.4s ease-in-out infinite both;
}

.dots-loader div:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-loader div:nth-child(2) {
    animation-delay: -0.16s;
}

.dots-loader div:nth-child(3) {
    animation-delay: 0s;
}

@keyframes dots-pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

#sendButton:disabled {
    background-color: var(--gray-300);
    cursor: not-allowed;
}

/* Loading Indicator - Hidden */
.loading {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
}


.hat-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.hat-item {
    text-align: center;
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    background: var(--white);
}

.hat-item img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
}

.hat-item h3 {
    color: var(--gray-800);
    font-size: 16px;
    margin-bottom: 8px;
}

.hat-item .download-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.hat-item .download-link:hover {
    text-decoration: underline;
}

/* Add to Cart Button */
.add-to-cart-btn {
    background-color: var(--primary-accent);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    margin: 8px 0 4px 0;
    transition: all 0.2s ease;
    display: block;
    width: 100%;
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
}

.add-to-cart-btn:hover {
    background-color: #5a0c2f;
    transform: translateY(-1px);
}

.add-to-cart-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.add-to-cart-btn.loading {
    background-color: var(--gray-400);
}

.add-to-cart-btn.success {
    background-color: #10b981; /* green-500 */
}

.add-to-cart-btn.error {
    background-color: #ef4444; /* red-500 */
}

/* Cart Notification */
.cart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--primary-accent);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.cart-notification.show {
    transform: translateX(0);
}

.cart-notification-icon {
    font-size: 18px;
}

.cart-notification-message {
    font-weight: 500;
    font-size: 14px;
}

/* Cart Indicator */
.cart-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
    z-index: 1000;
}

.cart-indicator.show {
    opacity: 1;
    transform: scale(1);
}

.cart-link {
    background-color: var(--primary-accent);
    color: white;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .cart-indicator {
        bottom: 15px;
        right: 15px;
    }
    
    .cart-link {
        padding: 10px 16px;
        font-size: 14px;
        gap: 6px;
    }
}

.cart-link:hover {
    background-color: #5a0c2f;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

/* Footer */
.footer {
  border-top: 1px solid rgb(191,191,191);
  padding: 30px 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(18,18,18,0.65);
  background-color: #fff;
}

.footer-links {
  margin-bottom: 15px;
}

.footer-links a {
  color: rgba(18,18,18,0.65);
  text-decoration: none;
  margin: 0 10px;
  padding: 5px 0;
}

.footer-links a:hover {
  color: #6d0f39; /* brand maroon */
  text-decoration: underline;
}

.footer-copy {
  margin-top: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .logo {
        height: 30px;
        width: auto;
        max-width: 100%;
        margin-bottom: 12px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    #messageInput, #sendButton {
        width: 100%;
    }
    
    .hero-title {
        font-size: 2.3rem;
    }
    
    .hat-icon {
        font-size: 1.8rem;
    }
    
    .chat-messages {
        height: 300px;
    }
    
    /* Prevent iOS zoom on input focus */
    #messageInput {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .logo {
        height: 24px;
        width: auto;
        max-width: 100%;
        margin-bottom: 8px;
    }
    
    .header-logo-img {
        max-height: 75px; /* Proportional increase */
    }
    
    .hat-icon {
        font-size: 1.5rem;
    }
    
    .chat-messages {
        height: 250px;
    }
}

@media (max-width: 360px) {
    .header-logo-img {
        max-height: 65px; /* Proportional increase */
    }
}

/* === Trending Now Section === */
.trending-section {
    padding: 30px 0;
    margin-top: 40px;
    margin-bottom: 20px;
    border-top: 1px solid var(--gray-200);
}

.section-header {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    font-size: 1.7rem;
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
    color: var(--color-foreground);
    line-height: 1.2;
}

.product-carousel-container {
    overflow-x: auto;
    padding-bottom: 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-accent) var(--background-color);
    position: relative;
}

.product-carousel-container::after {
    content: '❯';
    position: absolute;
    top: 40%;
    right: 8px;
    transform: translateY(-50%);
    font-size: 2.2rem;
    color: rgba(18, 18, 18, 0.25);
    pointer-events: none;
    z-index: 5;
    line-height: 0;
}

.product-carousel-container::-webkit-scrollbar {
    height: 8px;
}

.product-carousel-container::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 4px;
}

.product-carousel-container::-webkit-scrollbar-thumb {
    background-color: var(--secondary-accent);
    border-radius: 4px;
}

.product-carousel-list {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding: 0 10px;
}

.product-carousel-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 160px;
    margin: 0 auto;
    background: none;
    border-radius: 0;
    box-shadow: none;
    transition: transform 0.2s ease-in-out;
}

.product-carousel-card:hover {
    transform: translateY(-2px);
}

.product-carousel-image {
    border-radius: 8px;
    width: 100%;
    height: 140px;
    object-fit: cover;
    transition: opacity 0.2s ease;
}

.product-carousel-image:hover {
    opacity: 0.9;
}

.product-carousel-info {
    padding: 12px 0 0 0;
    text-align: left;
}

.product-carousel-name {
    color: var(--color-foreground);
    margin-bottom: 4px;
    white-space: normal;
    word-break: break-word;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.product-carousel-price {
    color: rgba(18, 18, 18, 0.65);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 2px;
    display: block;
}

.product-link {
    text-decoration: none;
    color: inherit;
}

/* === FAQ Section === */
.faq-section-container {
    margin-bottom: 40px;
    margin-top: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    border-top: 1px solid var(--gray-200);
    padding-top: 40px;
}

/* FAQ header styles removed - now using standard section-header */

.faq-section {
    margin-bottom: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.faq-item {
    border-bottom: 1px solid var(--gray-200);
    padding: 15px 0;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    font-size: 1.1rem;
    padding: 5px 0;
    transition: color 0.2s ease;
}

.faq-question:hover {
    color: var(--primary-accent);
}

.faq-item-toggle {
    font-size: 1.5rem;
    color: var(--secondary-accent);
    margin-left: 10px;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 25px;
    text-align: center;
}

.faq-question:hover .faq-item-toggle {
    color: var(--primary-accent);
    transform: scale(1.1);
}

.faq-answer {
    margin-top: 10px;
    padding: 15px;
    color: rgba(18, 18, 18, 0.7);
    font-size: 0.95rem;
    line-height: 1.6;
    background-color: rgba(109, 15, 57, 0.02);
    border-radius: 8px;
    border-left: 3px solid var(--primary-accent);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    .section-header {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .product-carousel-card {
        max-width: 130px;
    }
    
    .product-carousel-name {
        font-size: 0.9rem;
    }
    
    .product-carousel-price {
        font-size: 0.85rem;
    }

    .product-carousel-image {
        height: 120px;
    }
    
    .product-carousel-info {
        padding: 8px 0 0 0;
    }
    
    .faq-section-container {
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    
    .faq-header .section-header {
        font-size: 1.3rem;
    }
    
    .faq-question {
        font-size: 1rem;
    }
    
    .faq-answer {
        font-size: 0.9rem;
        padding: 12px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    animation: modalSlideIn 0.2s ease-out;
    margin: 0 auto;
    flex-shrink: 0;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--gray-400);
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--gray-200);
    color: var(--gray-800);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.modal-image-section {
    position: relative;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: 40px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-product-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.modal-details-section {
    padding: 30px;
}

.modal-product-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-foreground);
    margin-bottom: 8px;
    line-height: 1.2;
}

.modal-product-price {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-accent);
    margin-bottom: 20px;
}

.modal-features {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 0;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    justify-content: space-between;
}

.feature-label {
    font-weight: 500;
    color: var(--gray-800);
    font-size: 0.9rem;
}

.color-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.color-pill:hover {
    transform: scale(1.05);
}

.modal-description {
    color: var(--color-foreground);
    line-height: 1.6;
    margin-bottom: 25px;
}

.modal-description p {
    margin-bottom: 12px;
}

.modal-description p:last-child {
    margin-bottom: 0;
}

.modal-cart-btn {
    width: 100%;
    background: var(--primary-accent);
    color: white;
    border: none;
    padding: 14px 24px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.modal-cart-btn:hover {
    background: #5a0d30;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.modal-cart-btn:active {
    transform: translateY(0);
}

/* Desktop Modal Styles - Explicit Centering */
@media (min-width: 769px) {
    .modal-overlay {
        align-items: center;
        justify-content: center;
    }
}

/* Mobile Modal Styles */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }
    
    .modal-content {
        max-height: 85vh;
        border-radius: var(--border-radius) var(--border-radius) 0 0;
        animation: modalSlideUp 0.3s ease-out;
    }
    
    @keyframes modalSlideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .modal-image-section {
        padding: 30px 20px;
    }
    
    .modal-product-image {
        max-height: 200px;
    }
    
    .modal-details-section {
        padding: 20px;
    }
    
    .modal-product-title {
        font-size: 1.3rem;
    }
    
    .modal-product-price {
        font-size: 1.1rem;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
    }
}

/* Modal Share Button Styles */
.modal-share-btn {
    flex-shrink: 0;
    margin-left: auto;
}