/**
 * TinyTinyTelg Unified Layout System - RAG Edition
 * Universal Header + Left Panel Template
 * Version: 2.0
 */

:root {
    /* Layout Dimensions */
    --header-height: 64px;
    --panel-width: 240px;
    
    /* Colors */
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Main Application Layout */
.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Universal Header */
.unified-header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: 2rem;
    flex-shrink: 0;
    min-width: 200px;
}

.header-brand a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    white-space: nowrap;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(124, 58, 237, 0.1);
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap !important;
    display: inline-block;
    min-width: fit-content;
}

.brand-text {
    white-space: nowrap !important;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Header Version */
.header-version {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 1rem;
    height: 100%;
}

.version-text {
    font-size: 0.875rem !important;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Header Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Portal Dropdown */
.portal-dropdown {
    position: relative;
    margin-right: 1rem;
}

.portal-button {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-decoration: underline;
}

.portal-button:hover {
    color: var(--primary-color);
}

.portal-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-primary);
    min-width: 200px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1001;
    margin-top: 0.5rem;
}

.portal-dropdown-content.show {
    display: block;
}

.portal-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.portal-dropdown-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.portal-dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.portal-dropdown-item:hover {
    background-color: var(--bg-secondary);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success-color);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background-color: var(--danger-color);
    animation: none;
}

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

/* Main Content Layout */
.main-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

/* Universal Left Panel */
.universal-panel {
    width: var(--panel-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Panel Sections */
.panel-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
    flex: 1;
}

.panel-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Panel Navigation */
.panel-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.panel-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.panel-nav-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.panel-nav-item.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    font-weight: 500;
}

.panel-nav-icon {
    font-size: 16px;
    width: 16px;
    text-align: center;
}

/* App Content Area */
.app-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: var(--bg-secondary);
}

/* RAG-specific content adjustments */
.chat-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Ensure consistent base font */
body {
    font-size: 16px;
    line-height: 1.5;
}

/* Typography Scale */
.text-xs { font-size: 0.6875rem !important; }  /* 11px */
.text-sm { font-size: 0.8125rem !important; }  /* 13px */
.text-base { font-size: 0.875rem !important; } /* 14px */
.text-md { font-size: 1rem !important; }       /* 16px */
.text-lg { font-size: 1.125rem !important; }   /* 18px */
.text-xl { font-size: 1.25rem !important; }    /* 20px */
.text-2xl { font-size: 1.5rem !important; }    /* 24px */
.text-3xl { font-size: 1.875rem !important; }  /* 30px */

.chat-interface {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Responsive Design */
@media (max-width: 768px) {
    .universal-panel {
        display: none;
    }
    
    .header-nav {
        display: none;
    }
    
    .app-content {
        padding: 1rem;
    }
}

/* Utility Classes */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }

.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-l { border-left: 1px solid var(--border-color); }
.border-r { border-right: 1px solid var(--border-color); }

.rounded { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }

.shadow { box-shadow: var(--shadow); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.m-2 { margin: 0.5rem; }
.m-4 { margin: 1rem; }
.m-6 { margin: 1.5rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* Transitions */
.transition-all {
    transition: all 0.2s ease;
}

.transition-colors {
    transition: color 0.2s ease, background-color 0.2s ease;
}

/* Focus States */
.focus\:outline-none:focus {
    outline: none;
}

.focus\:ring-2:focus {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5);
}

/* =====================================
   MARK DESIGN SYSTEM - BUTTON COMPONENTS
   ===================================== */

/* Button Base */
.button-base {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    outline: none;
    position: relative;
}

.button-base:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.button-base:disabled {
    pointer-events: none;
    opacity: 0.5;
}

/* Button Variants */
.button-primary {
    background-color: var(--primary-color);
    color: white;
}

.button-primary:hover {
    background-color: rgba(37, 99, 235, 0.9);
}

.button-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.button-secondary:hover {
    background-color: rgba(243, 244, 246, 0.8);
}

.button-outline {
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.button-outline:hover {
    background-color: var(--bg-secondary);
}

.button-ghost {
    background-color: transparent;
    color: var(--text-primary);
}

.button-ghost:hover {
    background-color: var(--bg-secondary);
}

.button-destructive {
    background-color: var(--danger-color);
    color: white;
}

.button-destructive:hover {
    background-color: rgba(239, 68, 68, 0.9);
}

.button-link {
    background-color: transparent;
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 4px;
}

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

/* Button Sizes */
.button-sm {
    height: 2.25rem;
    border-radius: 6px;
    padding: 0 0.75rem;
    font-size: 0.875rem;
}

.button-md {
    height: 2.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.button-lg {
    height: 2.75rem;
    border-radius: 6px;
    padding: 0 2rem;
    font-size: 1rem;
}

.button-icon {
    height: 2.5rem;
    width: 2.5rem;
    padding: 0;
}

.button-icon-sm {
    height: 2rem;
    width: 2rem;
    padding: 0;
}

.button-compact {
    height: 1.75rem;
    padding: 0 0.5rem;
    font-size: 0.75rem;
}

/* Button with SVG Support */
.button-with-svg svg {
    pointer-events: none;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Semantic Button Classes */
.primary-button-with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-button-with-icon:hover {
    background-color: rgba(37, 99, 235, 0.9);
}

.outline-button-with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.outline-button-with-icon:hover {
    background-color: var(--bg-secondary);
}

/* Action Button - For suggested questions */
.action-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.action-button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Submit Button */
.submit-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 2.5rem;
    padding: 0 1.5rem;
}

.submit-button:hover {
    background-color: rgba(37, 99, 235, 0.9);
}

.submit-button:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}