/* Modern AI Chat Interface Styles */

/* CSS Variables for Theme Consistency */
:root {
    /* Colors */
    --primary-blue: #2563eb;
    --primary-blue-dark: #1d4ed8;
    --primary-blue-light: #3b82f6;
    --accent-amber: #f59e0b;
    --accent-amber-dark: #d97706;
    --accent-amber-light: #fbbf24;
    
    /* Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Success/Error Colors */
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Legacy Variables (for compatibility) */
    --primary-color: #2563eb;
    --dark-gray: #1e293b;
    --medium-gray: #64748b;
    --light-gray: #e2e8f0;
    --success-color: #10b981;
    
    /* Layout */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 60px;
    --header-height: 60px;
    
    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
                'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
                sans-serif;
    line-height: 1.6;
    color: var(--gray-800);
    background-color: var(--gray-50);
    font-size: 14px;
    overflow-x: hidden;
    transition: margin-left var(--transition-smooth);
}

/* Mobile Header */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: none;
    align-items: center;
    padding: 0 1rem;
    z-index: 1001;
    box-shadow: var(--shadow-sm);
}

.mobile-menu-toggle {
    background: none;
    border: none;
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.mobile-menu-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 1.1rem;
    margin-left: 1rem;
}

.mobile-logo i {
    font-size: 1.2rem;
}

.mobile-header-spacer {
    flex: 1;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    border-right: 1px solid var(--gray-200);
    z-index: 1000;
    transition: width var(--transition-smooth);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-info {
    display: none;
}

.sidebar.collapsed .logo {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem;
    justify-content: center;
}

.sidebar.collapsed .nav-list {
    padding: 0 0.75rem;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    min-width: 44px;
    min-height: 44px;
}

.sidebar.collapsed .nav-link i {
    margin: 0;
}

.sidebar.collapsed .user-section {
    padding: 1rem 0.75rem;
}

.sidebar.collapsed .user-profile {
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0;
}

.sidebar.collapsed .user-menu {
    display: none;
}

.sidebar.collapsed .storage-info {
    display: none;
}

.sidebar.collapsed .auth-links {
    align-items: center;
}

.sidebar.collapsed .auth-link {
    justify-content: center;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 1.1rem;
}

.logo i {
    font-size: 1.2rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.nav-list {
    list-style: none;
    padding: 0 1rem;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--gray-600);
    border-radius: 0.5rem;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.nav-link.active {
    background: var(--primary-blue);
    color: white;
}

.nav-link i {
    width: 1.25rem;
    text-align: center;
    font-size: 1.1rem;
}

/* User Section in Sidebar */
.user-section {
    border-top: 1px solid var(--gray-200);
    padding: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.user-avatar i {
    font-size: 2rem;
    color: var(--gray-400);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-storage {
    margin-top: 0.25rem;
}

.storage-bar {
    width: 100%;
    height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.storage-fill {
    height: 100%;
    border-radius: 2px;
    transition: width var(--transition-smooth), background-color var(--transition-smooth);
}

.storage-fill.storage-good {
    background: var(--success);
}

.storage-fill.storage-warning {
    background: var(--warning);
}

.storage-fill.storage-critical {
    background: var(--error);
}

.user-storage small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.user-storage .storage-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.375rem;
    color: var(--gray-400);
    font-size: 0.65rem;
    line-height: 1.2;
}

.user-storage .storage-info i {
    font-size: 0.6rem;
    flex-shrink: 0;
}

.user-menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--gray-500);
    transition: all var(--transition-fast);
}

.user-menu-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.user-menu-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    z-index: 1001;
}

.user-menu-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    text-decoration: none;
    color: var(--gray-700);
    transition: background var(--transition-fast);
}

.user-menu-dropdown a:hover {
    background: var(--gray-50);
}

.user-menu-dropdown a:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.user-menu-dropdown a:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Auth Links for Non-Authenticated Users */
.auth-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.login-link {
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
}

.login-link:hover {
    background: var(--primary-blue);
    color: white;
}

.register-link {
    background: var(--primary-blue);
    color: white;
}

.register-link:hover {
    background: var(--primary-blue-dark);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Navigation States */
body.mobile-nav-open {
    overflow: hidden;
}

body.mobile-nav-open .main-wrapper {
    pointer-events: none;
}

/* Main Content Area */
.main-wrapper {
    margin-left: 0;
    min-height: 100vh;
    transition: margin-left var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

body:not(.sidebar-collapsed) .main-wrapper {
    margin-left: var(--sidebar-width);
}

body.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Content Container Styles */
.main-content {
    flex: 1;
    padding: 2rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.search-section {
    max-width: 800px;
    margin: 0 auto;
}

.search-card {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

.subtitle {
    color: var(--gray-600);
    font-size: 1rem;
    margin: 1rem 0 2rem 0;
    text-align: center;
}

/* Page headers in form sections */
.search-section h1 {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

/* Chat Interface Styles */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
}

/* Chat separator (Previous conversation restored) */
.chat-separator {
    position: relative;
    z-index: 1;
}

.chat-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.chat-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.chat-header p {
    color: var(--gray-600);
    font-size: 1rem;
}

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    min-height: 200px;
}

.message {
    display: flex;
    gap: 1rem;
    animation: fadeInUp 0.4s ease-out;
}

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

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

.message-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--primary-blue);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.ai .message-content {
    background: white;
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
}

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

.message.user .message-avatar {
    background: var(--primary-blue-dark);
    color: white;
    order: 1;
}

.message.ai .message-avatar {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* Chat Input Area */
.chat-input-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    bottom: 2rem;
    z-index: 10;
}

/* User Tip for Non-Authenticated Users */
.user-tip {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--gray-600);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.user-tip i {
    font-size: 0.75rem;
    color: var(--accent-amber);
    flex-shrink: 0;
}

.user-tip span {
    line-height: 1.3;
}

.document-selector {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.document-selector label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.document-selector select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    background: white;
    font-size: 0.875rem;
    color: var(--gray-700);
    transition: border-color var(--transition-fast);
}

.document-selector select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-area {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-field {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 0.75rem;
    border: none;
    border-radius: 0.75rem;
    background: var(--gray-50);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    transition: background var(--transition-fast);
}

.input-field:focus {
    outline: none;
    background: var(--gray-100);
}

.input-field::placeholder {
    color: var(--gray-400);
}

.send-button {
    padding: 0.75rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
}

.send-button:hover:not(:disabled) {
    background: var(--primary-blue-dark);
    transform: translateY(-1px);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.send-button i {
    font-size: 1rem;
}

/* Loading Animation */
.loading-dots {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.loading-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: loadingPulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0; }

@keyframes loadingPulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Landing Page Styles */
.landing-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 50%, #60a5fa 100%);
}

.hero-section {
    padding: 6rem 2rem 4rem;
    text-align: center;
    color: white;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.1;
    background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 3rem;
    opacity: 0.9;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-amber);
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    border-radius: 3rem;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all var(--transition-smooth);
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.3);
    border: none;
    cursor: pointer;
}

.cta-button:hover {
    background: var(--accent-amber-dark);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(245, 158, 11, 0.4);
}

.cta-button.secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cta-button.secondary:hover {
    background: var(--gray-200);
    color: var(--gray-800);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Feature Grid */
.features-section {
    padding: 5rem 2rem;
    background: white;
}

.features-container {
    max-width: 1200px;
    margin: 0 auto;
}

.features-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 3rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--gray-200);
    transition: all var(--transition-smooth);
    text-align: center;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-blue-light);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-blue);
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.feature-description {
    color: var(--gray-600);
    line-height: 1.6;
}

/* Form Styles */
.form-container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

.form-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--gray-800);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    background: white;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-button {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.form-button:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-1px);
}

.form-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loader styles for form buttons */
.form-button .loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

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

/* Search/Action Button Styles */
.search-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-blue);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    min-height: 44px;
    box-sizing: border-box;
}

.search-button:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-1px);
    text-decoration: none;
}

.search-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.search-button.secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.search-button.secondary:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

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

.search-button.danger:hover {
    background: #dc2626;
}

/* Messages */
.messages {
    margin: 1rem 0;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-error {
    background: var(--error-light);
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border-color: #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border-color: #bfdbfe;
}

/* Footer */
.footer {
    background: var(--gray-800);
    color: var(--gray-300);
    padding: 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer p {
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --sidebar-width: min(280px, 80vw);
    }
    
    /* Mobile Header Visibility */
    .mobile-header {
        display: flex;
    }
    
    /* Mobile-first main content adjustment */
    .main-wrapper {
        margin-left: 0 !important;
        padding-top: var(--header-height);
    }
    
    /* Mobile Sidebar Behavior */
    .sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-smooth);
        z-index: 1000;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Reset desktop collapsed behavior on mobile */
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    
    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }
    
    /* Always show full sidebar content on mobile when open */
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .user-info {
        display: block;
    }
    
    .sidebar.collapsed .logo {
        display: flex;
    }
    
    .sidebar.collapsed .sidebar-header {
        padding: 1rem;
        justify-content: space-between;
    }
    
    .sidebar.collapsed .nav-list {
        padding: 0 1rem;
    }
    
    .sidebar.collapsed .nav-link {
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        border-radius: 0.5rem;
        min-width: auto;
        min-height: 44px;
    }
    
    .sidebar.collapsed .nav-link i {
        margin-right: 0.75rem;
    }
    
    .sidebar.collapsed .user-section {
        padding: 1rem;
    }
    
    .sidebar.collapsed .user-profile {
        justify-content: flex-start;
    }
    
    .sidebar.collapsed .user-avatar {
        margin-right: 0.75rem;
    }
    
    .sidebar.collapsed .user-menu {
        display: block;
    }
    
    .sidebar.collapsed .storage-info {
        display: flex;
    }
    
    .sidebar.collapsed .auth-links {
        align-items: stretch;
    }
    
    .sidebar.collapsed .auth-link {
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        min-width: auto;
        min-height: 44px;
    }
    
    .chat-container {
        padding: 1rem 0.75rem;
    }
    
    .chat-header {
        padding: 1rem 0.5rem 2rem;
    }
    
    .chat-header h1 {
        font-size: 1.75rem;
    }
    
    .message-content {
        max-width: 85%;
        padding: 0.875rem 1rem;
    }
    
    .message {
        gap: 0.75rem;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }
    
    .chat-input-container {
        padding: 0.875rem;
        margin: 0 0.5rem 1rem;
    }
    
    .user-tip {
        font-size: 0.7rem;
        gap: 0.25rem;
        margin-bottom: 0.375rem;
    }
    
    .user-tip i {
        font-size: 0.7rem;
    }
    
    .document-selector {
        margin-bottom: 0.875rem;
        padding-bottom: 0.875rem;
    }
    
    .input-area {
        gap: 0.625rem;
    }
    
    .input-field {
        min-height: 40px;
        padding: 0.625rem 0.75rem;
    }
    
    .send-button {
        min-width: 40px;
        height: 40px;
        padding: 0.625rem;
    }
    
    .hero-section {
        padding: 3rem 1rem 2rem;
    }
    
    .hero-title {
        font-size: clamp(1.75rem, 4vw, 2.5rem);
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .features-section {
        padding: 2.5rem 1rem;
    }
    
    .features-title {
        font-size: 2rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .form-container {
        margin: 1rem 0.75rem;
        padding: 1.5rem;
    }
    
    .main-content {
        padding: 1rem 0.5rem;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .search-card {
        padding: 1.5rem;
    }
    
    .user-info {
        display: block; /* Show user info on mobile */
    }
    
    /* Optimize user info layout for mobile */
    .user-name {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .user-storage {
        margin-top: 0.5rem;
    }
    
    .user-storage small {
        font-size: 0.7rem;
    }
    
    .storage-info {
        margin-top: 0.25rem;
    }
    
    .storage-info span {
        font-size: 0.65rem;
        line-height: 1.1;
    }
    
    .sidebar-header {
        padding: 0.875rem;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .nav-list {
        padding: 0 0.75rem;
    }
    
    .nav-link {
        padding: 0.625rem 0.875rem;
    }
    
    .user-section {
        padding: 0.875rem;
    }
}

@media (max-width: 480px) {
    .chat-container {
        padding: 0.75rem 0.5rem;
    }
    
    .chat-input-container {
        margin: 0 0.25rem 0.75rem;
        border-radius: 0.75rem;
        padding: 0.75rem;
    }
    
    .input-area {
        gap: 0.5rem;
    }
    
    .input-field {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 36px;
        padding: 0.5rem 0.625rem;
    }
    
    .send-button {
        min-width: 36px;
        height: 36px;
        padding: 0.5rem;
    }
    
    .message-content {
        max-width: 90%;
        padding: 0.75rem 0.875rem;
        font-size: 0.9rem;
    }
    
    .message {
        gap: 0.5rem;
    }
    
    .message-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .hero-section {
        padding: 2rem 0.75rem 1.5rem;
    }
    
    .cta-button {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .feature-card {
        padding: 1.25rem;
    }
    
    .feature-icon {
        font-size: 2.5rem;
    }
    
    .main-content {
        padding: 0.75rem 0.25rem;
    }
    
    .container {
        padding: 0 0.25rem;
    }
    
    .search-card {
        padding: 1.25rem;
    }
    
    .sidebar {
        font-size: 0.875rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .sidebar-overlay,
    .chat-input-container,
    .footer {
        display: none !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
    }
    
    .chat-messages {
        margin-bottom: 0;
    }
}

/* Touch Device Optimizations */
@media (pointer: coarse) {
    .nav-link,
    .send-button,
    .cta-button,
    .form-button,
    .sidebar-toggle,
    .user-menu-toggle {
        min-height: 44px; /* iOS/Android touch target minimum */
        min-width: 44px;
    }
    
    .input-field {
        min-height: 44px;
    }
    
    .feature-card {
        cursor: default; /* Remove hover cursor on touch devices */
    }
}

/* Focus Visible for Keyboard Navigation */
.nav-link:focus-visible,
.send-button:focus-visible,
.cta-button:focus-visible,
.form-button:focus-visible,
.sidebar-toggle:focus-visible,
.mobile-menu-toggle:focus-visible,
.auth-link:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Enhanced Mobile Focus States */
@media (max-width: 768px) {
    .mobile-menu-toggle:focus {
        background: var(--primary-blue);
        color: white;
    }
    
    .nav-link:focus,
    .auth-link:focus {
        background: var(--primary-blue-light);
        color: white;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --gray-200: #000000;
        --gray-600: #000000;
        --gray-800: #000000;
    }
    
    .nav-link:hover,
    .nav-link:focus,
    .form-input:focus,
    .form-select:focus,
    .form-textarea:focus {
        border: 2px solid #000000;
        box-shadow: 0 0 0 2px #000000;
    }
    
    .sidebar {
        border-right: 3px solid #000000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   FEEDBACK WIDGET STYLES
   ============================================ */

/* Feedback Button */
.feedback-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    
    /* Button styling */
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-smooth);
    
    /* Icon spacing */
    display: flex;
    align-items: center;
    gap: 8px;
    
    /* Animation */
    animation: feedbackPulse 3s infinite;
}

.feedback-button:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.feedback-button:active {
    transform: translateY(0);
}

@keyframes feedbackPulse {
    0%, 70%, 100% { 
        transform: scale(1);
        box-shadow: var(--shadow-lg);
    }
    35% { 
        transform: scale(1.05);
        box-shadow: var(--shadow-xl);
    }
}

/* Feedback Panel */
.feedback-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    
    /* Panel dimensions */
    width: 320px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    
    /* Animation */
    transform: translateY(100%) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

.feedback-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Panel Header */
.feedback-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 12px 12px 0 0;
}

.feedback-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.feedback-close-btn {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.feedback-close-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* Panel Body */
.feedback-panel-body {
    padding: 20px;
}

/* Form Styles */
.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feedback-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.feedback-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.feedback-input,
.feedback-textarea {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition-fast);
    background: white;
}

.feedback-input:focus,
.feedback-textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.feedback-input.readonly {
    background: var(--gray-50);
    color: var(--gray-600);
    cursor: not-allowed;
}

.feedback-textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 120px;
    font-family: inherit;
}

.feedback-checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.feedback-checkbox {
    margin: 0;
}

.feedback-checkbox-label {
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
    margin: 0;
}

/* Form Actions */
.feedback-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.feedback-submit-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex: 1;
    
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.feedback-submit-btn:hover:not(:disabled) {
    background: var(--primary-blue-dark);
}

.feedback-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.feedback-cancel-btn {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Status Messages */
.feedback-message {
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.feedback-message.success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.feedback-message.error {
    background: var(--error-light);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.feedback-message.show {
    display: block;
}

/* Loading State */
.feedback-loading .feedback-submit-btn {
    pointer-events: none;
}

.feedback-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

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

/* Character Counter */
.feedback-char-counter {
    font-size: 12px;
    color: var(--gray-500);
    text-align: right;
    margin-top: 4px;
}

.feedback-char-counter.warning {
    color: var(--warning);
}

.feedback-char-counter.danger {
    color: var(--error);
}

/* Responsive Design */
@media (max-width: 768px) {
    .feedback-button {
        bottom: 16px;
        right: 16px;
        padding: 12px;
        border-radius: 50px;
    }
    
    .feedback-button .feedback-button-text {
        display: none;
    }
    
    .feedback-panel {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }
    
    .feedback-form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .feedback-submit-btn,
    .feedback-cancel-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .feedback-panel-body {
        padding: 16px;
    }
    
    .feedback-panel-header {
        padding: 12px 16px;
    }
}