/**
 * Straw Boss AI Chat - Pinestraw America Brand Colors
 * Optimized for mobile-first design with desktop compatibility
 * Version: 2.1 - Brand Aligned
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #CF1C31;
    --primary-orange: #BF5700;
    --primary-navy: #3A3870;
    --white: #FFFFFF;
    --light-orange: #F4E6D7;
    --light-red: #FCE8EA;
    --light-navy: #E8E9F3;
    --chat-bg: #F8F9FA;
    --light-gray: #f0f0f0;
    --medium-gray: #8696a0;
    --dark-gray: #54656f;
    --text-dark: #2C2C2C;
    --text-light: #667781;
    --border-light: #e9edef;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.12);
    --error-red: #CF1C31;
    --success-green: #28a745;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--primary-navy);
    color: var(--text-dark);
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

/* Container - Full height for mobile */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 0;
}

/* Chat Wrapper - Brand container */
.chat-wrapper {
    width: 100%;
    height: 100vh;
    background: var(--white);
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
}

/* Header - Pinestraw America Brand */
.chat-header {
    background: linear-gradient(135deg, var(--primary-navy) 0%, var(--primary-red) 100%);
    color: var(--white);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.logo img {
    height: 70px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-main {
    font-size: 1.1rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 500;
    margin-top: -2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Access Screen - Brand styled */
.access-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    background: var(--white);
}

.access-screen.hidden {
    display: none;
}

.access-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-navy);
    margin-bottom: 8px;
    text-align: center;
}

.access-subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
    font-size: 0.9rem;
    text-align: center;
}

.access-form {
    max-width: 320px;
    margin: 0 auto;
    width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--primary-navy);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--white);
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    /*border-color: var(--primary-orange);*/
    box-shadow: 0 0 0 2px rgba(191, 87, 0, 0.2);
}

.access-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-orange) 100%);
    color: var(--white);
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
}

.access-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.access-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.error-message {
    color: var(--error-red);
    font-size: 0.85rem;
    margin-top: 12px;
    display: none;
    text-align: center;
}

/* Chat Interface - Brand Layout */
.chat-interface {
    display: none;
    flex-direction: column;
    height: 100vh;
    background: var(--chat-bg);
}

.chat-interface.active {
    display: flex;
}

/* Messages Area - Brand background */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 80px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--chat-bg);
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(207, 28, 49, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 75% 75%, rgba(191, 87, 0, 0.05) 1px, transparent 1px);
    background-size: 30px 30px, 40px 40px;
    scroll-behavior: smooth;
}

/* Message Bubbles - Brand Style */
.message {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 4px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-bottom: 2px;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-light);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-orange) 100%);
    color: var(--white);
}

.message.bot .message-avatar {
    background: var(--primary-navy);
    color: var(--white);
}

.message-content {
    max-width: 75%;
    min-width: 60px;
    padding: 10px 14px 8px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    box-shadow: var(--shadow-light);
    word-wrap: break-word;
}

/* User messages - Brand bubble */
.message.user .message-content {
    background: linear-gradient(135deg, var(--light-red) 0%, var(--light-orange) 100%);
    color: var(--text-dark);
    border-bottom-right-radius: 4px;
    margin-right: 8px;
    border: 1px solid rgba(207, 28, 49, 0.1);
}

/* Bot messages - White bubble with brand accent */
.message.bot .message-content {
    background: var(--white);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
    margin-left: 8px;
    border: 1px solid var(--light-navy);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    text-align: right;
    opacity: 0.8;
}

/* Typing Indicator - Brand Style */
.typing-indicator {
    display: none;
    align-items: flex-end;
    gap: 6px;
    margin-bottom: 8px;
    padding: 0 8px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 3px;
    padding: 14px 18px;
    background: var(--white);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-light);
    margin-left: 8px;
    border: 1px solid var(--light-navy);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--primary-orange);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0);
        opacity: 0.4;
    }
    30% { 
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Chat Input - Brand Style */
.chat-input-container {
    background: var(--white);
    padding: 12px 16px;
    border-top: 2px solid var(--light-navy);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 100%;
}

.chat-input {
    flex: 1;
    resize: none;
    border: 2px solid var(--border-light);
    padding: 12px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.2s ease;
    background: var(--light-gray);
    overflow-y: auto;
    outline: none;
}

.chat-input:focus {
    
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(191, 87, 0, 0.2);
}

.chat-input::placeholder {
    color: var(--text-light);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-orange) 100%);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-light);
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: var(--medium-gray);
}

.send-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--white);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar Styling - Brand colors */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-orange);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-red);
}

/* Desktop Responsive */
@media (min-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .chat-wrapper {
        max-width: 480px;
        height: calc(100vh - 40px);
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(58, 56, 112, 0.3);
        overflow: hidden;
    }
    
    .chat-header {
        border-radius: 16px 16px 0 0;
    }
    
     .chat-messages {
        padding-top: 20px; /* Add space after header */
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .chat-input-container {
        padding: 16px 20px;
       
        border-radius: 0 0 16px 16px;
    }
    
    .chat-input-wrapper {
        gap: 12px;
    }
    
    .chat-send-btn {
        width: 48px;
        height: 48px;
    }
    
    .send-icon {
        width: 22px;
        height: 22px;
    }
    
    .chat-messages {
       padding: 20px 0px 140px 0px;
    }
}



/* Large Desktop */
@media (min-width: 1024px) {
    .chat-wrapper {
        max-width: 520px;
    }
    
    .message-content {
        font-size: 0.95rem;
    }
    
    .chat-input {
        font-size: 0.95rem;
    }
    
    
}


/* Small Mobile Adjustments */
@media (max-width: 480px) {
    .chat-header {
        padding: 10px 12px;
        min-height: 64px;
    }
    
    .logo img {
        height: 50px;
    }
    
    .logo-main {
        font-size: 1rem;
    }
    
    .subtitle {
        font-size: 0.7rem;
    }
    
    .status-indicator {
        padding: 4px 8px;
        font-size: 0.65rem;
    }
    
    .message-content {
        max-width: 82%;
        font-size: 0.85rem;
        padding: 8px 12px 6px 12px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }
    
    .chat-input {
        font-size: 0.85rem;
        padding: 10px 16px;
        min-height: 50px;
        border-radius: inherit;
    }
    
    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
    
    .send-icon {
        width: 18px;
        height: 18px;
    }
     
}

/* Ultra-compact for very small screens */
@media (max-width: 320px) {
    .chat-input-container {
        padding: 8px 10px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 0.8rem;
    }
    
    .access-screen {
        padding: 20px 16px;
    }
    
    .logo {
        gap: 4px;
    }
    
    .logo img {
        height: 50px;
    }
   
}

/* Focus indicators for keyboard navigation */
.chat-input:focus,
.access-btn:focus,
.form-input:focus {
    outline: 2px solid var(--primary-orange);
    outline-offset: 2px;
}

.chat-send-btn:focus {
    outline: 2px solid var(--primary-orange);
    outline-offset: 2px;
}


.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}


.cache-btn {
    width: 100%;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-light);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
}

.cache-btn:hover {
    background: var(--light-gray);
    color: var(--text-dark);
    border-color: var(--primary-orange);
}


.access-container {
    background: var(--white);
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 400px;
    margin: 0 auto;
}

.chat-messages {
    padding-bottom: 100px !important;
    margin-bottom: 0 !important;
}

.message:last-child {
    margin-bottom: 20px !important;
}

.typing-indicator {
    margin-bottom: 20px !important;
}

.chat-messages {
    padding-bottom: 120px !important;
    scroll-padding-bottom: 20px;
}

.message:last-child {
    margin-bottom: 30px !important;
}