/* ==========================================
   MENAITECH-ABUALI - Apple Corporate Style
   Modern, Clean, Minimal Design System
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;500;600;700&display=swap');

:root {
    /* Apple Color System */
    --apple-white: #FFFFFF;
    --apple-bg: #FBFBFD;
    --apple-bg-secondary: #F5F5F7;
    --apple-bg-tertiary: #FAFAFA;
    
    /* Text Colors */
    --apple-text-primary: #1D1D1F;
    --apple-text-secondary: #6E6E73;
    --apple-text-tertiary: #86868B;
    
    /* Borders */
    --apple-border: #D2D2D7;
    --apple-border-light: #E5E5EA;
    
    /* Accent Colors */
    --apple-blue: #0071E3;
    --apple-blue-hover: #0077ED;
    --apple-blue-light: #E8F2FF;
    --apple-success: #34C759;
    --apple-error: #FF3B30;
    --apple-warning: #FF9500;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px 0 rgba(0, 0, 0, 0.12);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--apple-bg);
    color: var(--apple-text-primary);
    letter-spacing: -0.01em;
}

/* ==========================================
   Typography System
   ========================================== */

.apple-h1 {
    font-size: 3rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.015em;
    color: var(--apple-text-primary);
}

.apple-h2 {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.012em;
    color: var(--apple-text-primary);
}

.apple-h3 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--apple-text-primary);
}

.apple-body {
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--apple-text-secondary);
}

.apple-caption {
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.4;
    color: var(--apple-text-tertiary);
    letter-spacing: 0.002em;
}

/* ==========================================
   Button System
   ========================================== */

.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: none;
    outline: none;
    letter-spacing: -0.005em;
}

.apple-btn-primary {
    background-color: var(--apple-blue);
    color: white;
}

.apple-btn-primary:hover {
    background-color: var(--apple-blue-hover);
}

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

.apple-btn-secondary {
    background-color: var(--apple-bg-secondary);
    color: var(--apple-text-primary);
    border: 1px solid var(--apple-border);
}

.apple-btn-secondary:hover {
    background-color: var(--apple-border-light);
    border-color: var(--apple-text-tertiary);
}

.apple-btn-ghost {
    background-color: transparent;
    color: var(--apple-text-secondary);
}

.apple-btn-ghost:hover {
    background-color: var(--apple-bg-secondary);
    color: var(--apple-text-primary);
}

/* ==========================================
   Card System
   ========================================== */

.apple-card {
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: all 0.2s ease;
}

.apple-card-hover:hover {
    border-color: var(--apple-border);
    box-shadow: var(--shadow-sm);
}

.apple-card-flat {
    background-color: var(--apple-bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

/* ==========================================
   Navigation
   ========================================== */

.apple-nav {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--apple-border-light);
    height: 3.5rem;
}

.apple-nav-link {
    color: var(--apple-text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    letter-spacing: -0.005em;
}

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

.apple-nav-link-active {
    color: var(--apple-blue);
    background-color: var(--apple-blue-light);
}

/* ==========================================
   Input System
   ========================================== */

.apple-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--apple-text-primary);
    background-color: var(--apple-bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    outline: none;
}

.apple-input::placeholder {
    color: var(--apple-text-tertiary);
}

.apple-input:focus {
    background-color: var(--apple-white);
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.apple-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--apple-text-primary);
    background-color: var(--apple-bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    outline: none;
    resize: none;
    font-family: var(--font-family);
    line-height: 1.5;
}

.apple-textarea::placeholder {
    color: var(--apple-text-tertiary);
}

.apple-textarea:focus {
    background-color: var(--apple-white);
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* ==========================================
   Icon System
   ========================================== */

.apple-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--apple-text-secondary);
}

.apple-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background-color: var(--apple-bg-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.apple-icon-container-sm {
    width: 2.5rem;
    height: 2.5rem;
}

/* ==========================================
   Status Indicators
   ========================================== */

.apple-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    letter-spacing: 0.005em;
}

.apple-status-success {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--apple-success);
}

.apple-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: var(--radius-full);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ==========================================
   Message Bubbles - Modern ChatGPT Style
   ========================================== */

.chat-message-wrapper {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 0;
    width: 100%;
}

.chat-message-wrapper.user-message {
    background-color: transparent;
}

.chat-message-wrapper.assistant-message {
    background-color: var(--apple-bg-secondary);
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.chat-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.chat-avatar.user-avatar {
    background: linear-gradient(135deg, var(--apple-blue) 0%, #0077ED 100%);
    color: white;
}

.chat-avatar.assistant-avatar {
    background-color: var(--apple-text-primary);
    color: white;
}

.chat-message-content {
    flex: 1;
    min-width: 0;
    max-width: 48rem;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.chat-message-role {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--apple-text-primary);
}

.chat-message-time {
    font-size: 0.75rem;
    color: var(--apple-text-tertiary);
}

.chat-message-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--apple-text-primary);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-message-text p {
    margin: 0 0 0.75rem 0;
}

.chat-message-text p:last-child {
    margin-bottom: 0;
}

.chat-message-text code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
}

.chat-message-text pre {
    background-color: var(--apple-text-primary);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.75rem 0;
}

.chat-message-text pre code {
    background: none;
    padding: 0;
    color: white;
}

/* Message Sources */
.chat-message-sources {
    margin-top: 0.75rem;
    padding: 0.875rem 1rem;
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-sm);
}

.assistant-message .chat-message-sources {
    background-color: rgba(255, 255, 255, 0.6);
}

.chat-sources-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--apple-text-secondary);
}

.chat-sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-source-item {
    display: flex;
    align-items: start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--apple-text-secondary);
}

.chat-source-item i {
    margin-top: 0.125rem;
    color: var(--apple-blue);
    flex-shrink: 0;
}

/* ==========================================
   Animations
   ========================================== */

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

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

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

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

.cursor-blink {
    animation: cursorBlink 1s ease-in-out infinite;
    font-weight: 300;
    color: var(--apple-blue);
}

.apple-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.apple-slide-up {
    animation: slideUp 0.4s ease-out;
}

/* ==========================================
   Chat Layout - Centered Empty State
   ========================================== */

#chatContainer.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

#chatContainer.empty-state #chatMessages {
    display: none;
}

#chatContainer.empty-state #chatInputContainer {
    border-top: none;
    max-width: 48rem;
    width: 100%;
    margin: 0 auto;
}

.empty-state-welcome {
    text-align: center;
    padding: 0 1.5rem;
    display: none;
}

#chatContainer.empty-state .empty-state-welcome {
    display: block;
}

.empty-state-welcome h2 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--apple-text-primary);
    margin-bottom: 0.5rem;
}

.empty-state-welcome p {
    font-size: 1rem;
    color: var(--apple-text-secondary);
}

@media (max-width: 640px) {
    .empty-state-welcome h2 {
        font-size: 1.5rem;
    }
    
    .empty-state-welcome p {
        font-size: 0.9375rem;
    }
}

/* ==========================================
   Utility Classes
   ========================================== */

.apple-scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.apple-scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.apple-glass {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.apple-divider {
    height: 1px;
    background-color: var(--apple-border-light);
    border: none;
}

/* ==========================================
   Responsive Helpers
   ========================================== */

@media (max-width: 640px) {
    .apple-h1 {
        font-size: 2rem;
    }
    
    .apple-h2 {
        font-size: 1.5rem;
    }
    
    .apple-h3 {
        font-size: 1.25rem;
    }
    
    .chat-message-wrapper {
        padding: 1rem 0;
    }
    
    .chat-message-wrapper.assistant-message {
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .chat-avatar {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }
    
    .chat-message-text {
        font-size: 0.875rem;
    }
}

/* ==========================================
   Loading States
   ========================================== */

.apple-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--apple-border-light);
    border-top-color: var(--apple-blue);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

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

/* ==========================================
   Modal System
   ========================================== */

.apple-modal-overlay {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.apple-modal {
    background-color: var(--apple-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    max-width: 28rem;
    width: 100%;
}

/* ==========================================
   Toast Notifications
   ========================================== */

.apple-toast {
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 20rem;
    animation: slideUp 0.3s ease-out;
}

.apple-toast-success {
    border-left: 3px solid var(--apple-success);
}

.apple-toast-error {
    border-left: 3px solid var(--apple-error);
}

.apple-toast-info {
    border-left: 3px solid var(--apple-blue);
}

/* ==========================================
   Feature Cards
   ========================================== */

.apple-feature-card {
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.apple-feature-card:hover {
    border-color: var(--apple-border);
    transform: translateY(-2px);
}

.apple-feature-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--apple-bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

/* ==========================================
   File Item
   ========================================== */

.apple-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.apple-file-item:hover {
    border-color: var(--apple-border);
    background-color: var(--apple-bg-tertiary);
}

/* ==========================================
   Stats Card
   ========================================== */

.apple-stat-card {
    background-color: var(--apple-white);
    border: 1px solid var(--apple-border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.apple-stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.apple-stat-value {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--apple-text-primary);
    line-height: 1;
}

.apple-stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--apple-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}



