/* Premium Mobile-First CSS Design System */
:root {
    /* EPocket Themed Color Palette */
    --primary-green: #1b6b20;
    --primary-green-light: #e8f5e8;
    --primary-orange: #cc6600;
    --primary-orange-light: #fff3e0;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-focus: #1b6b20;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Container as a Full-Screen Shell */
.chat-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
    position: relative;
    overflow: hidden;
}

/* Header Section */
.chat-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.chat-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chat-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Tier Badges */
.tier-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.premium-badge {
    background-color: var(--primary-orange-light);
    color: var(--primary-orange);
    border: 1px solid rgba(204, 102, 0, 0.2);
}

.standard-badge {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Tabs & Panels */
.tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.tab-panel.active {
    display: flex;
}

/* Chat Panel Area */
.chat-window {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Message Styles */
.chat-message {
    display: flex;
    margin-bottom: 4px;
    animation: slideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

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

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    font-weight: 450;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.bot-message .message-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.user-message .message-content {
    background-color: var(--primary-green);
    color: var(--text-white);
    border-bottom-right-radius: 4px;
}

/* Markdown formatting inside Bot Messages */
.message-content h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 8px 0 4px 0;
    color: var(--primary-green);
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content p {
    margin-bottom: 6px;
}

/* WhatsApp Code Copy Blocks */
.message-content pre {
    background-color: var(--bg-main);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-size: 0.8125rem;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin: 8px 0;
    position: relative;
}

.message-content code {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
}

.copy-btn-wrapper {
    margin-top: 6px;
    display: flex;
    justify-content: flex-end;
}

.copy-badge-btn {
    background-color: #e8f5e8;
    color: #1b6b20;
    border: 1px solid rgba(27, 107, 32, 0.2);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

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

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-green);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Prompt Chips List */
.chips-container {
    background-color: var(--bg-main);
    padding: 8px 12px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none; /* Firefox */
}

.chips-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.prompt-chip {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 550;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.prompt-chip:active {
    background-color: #f1f5f9;
    transform: translateY(1px);
}

/* Input Container Styling */
.input-container {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    gap: 12px;
    align-items: center;
}

#user-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
}

#user-input:focus {
    border-color: var(--border-focus);
}

#send-button {
    background-color: var(--primary-green);
    color: var(--text-white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

#send-button:active {
    transform: scale(0.95);
}

#send-text {
    font-weight: 600;
    font-size: 0.8125rem;
}

/* Insights tab container */
.insights-container {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

/* Lock Gated Overlay */
.upgrade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(248, 250, 252, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
    z-index: 100;
}

.lock-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.upgrade-overlay h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.upgrade-overlay p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 280px;
    line-height: 1.5;
}

.upgrade-btn {
    background: linear-gradient(135deg, var(--primary-green) 0%, #2e7d32 100%);
    color: var(--text-white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.9375rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease;
}

.upgrade-btn:active {
    transform: scale(0.98);
}

/* Premium Content Dashboard Layout */
.premium-content {
    display: none; /* Shown dynamically if tier is premium */
    flex-direction: column;
    padding: 12px 0;
    gap: 16px;
    width: 100%;
}

/* KPI Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.metric-trend {
    font-size: 0.75rem;
    font-weight: 700;
    color: #10b981; /* Green up */
}

/* Charts Cards styling */
.chart-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 0 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-container-svg {
    width: 100%;
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bottom Navigation Bar */
.bottom-nav {
    border-top: 1px solid var(--border-color);
    display: flex;
    height: 64px;
    background-color: var(--bg-card);
}

.nav-item {
    flex: 1;
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    gap: 4px;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary-green);
}

.nav-item.active .nav-icon {
    transform: scale(1.15);
}

.nav-icon {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
}

/* System Notifications */
.notification {
    position: fixed;
    top: 16px;
    left: 16px;
    right: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-white);
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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