/**
 * Shared Styles - App Header, Navigation, and Common Components
 * Used across all pages for consistency
 */

/* ========== CSS Variables ========== */
:root {
    /* Colors - Light Mode */
    --app-primary: #3b82f6;
    --app-primary-hover: #2563eb;
    --app-primary-light: #dbeafe;

    --app-bg: #f8fafc;
    --app-surface: #ffffff;
    --app-border: #e2e8f0;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Chat specific colors */
    --chat-user-bg: #3b82f6;
    --chat-assistant-bg: #f1f5f9;

    /* Spacing */
    --header-height: 64px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

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

/* Dark Mode Variables */
html.dark-mode,
html.dark-mode body,
body.dark-mode {
    --app-primary: #60a5fa;
    --app-primary-hover: #3b82f6;
    --app-primary-light: #1e3a5f;

    --app-bg: #0a0a0a;
    --app-surface: #141414;
    --app-border: #2a2a2a;

    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --text-tertiary: #6b6b6b;

    --success: #22c55e;
    --warning: #fbbf24;
    --error: #ef4444;

    --chat-user-bg: #3b82f6;
    --chat-assistant-bg: #1f1f1f;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.8);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.9);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.95);
}

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

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--app-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

/* ========== App Header ========== */
#app-header {
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.app-header-content {
    max-width: 100%;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

/* ========== App Brand ========== */
.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* ========== Navigation ========== */
.app-nav {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-link svg {
    flex-shrink: 0;
}

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

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

.nav-link.active:hover {
    background: var(--app-primary-hover);
}

/* ========== Dark Mode Toggle ========== */
.dark-mode-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.dark-mode-toggle:hover {
    background: var(--app-bg);
    border-color: var(--app-primary);
    color: var(--app-primary);
}

.dark-mode-toggle svg {
    width: 20px;
    height: 20px;
}

/* ========== Chatbot Selector ========== */
.chatbot-selector-wrapper {
    min-width: 280px;
}

.chatbot-search-container {
    position: relative;
    width: 100%;
}

.chatbot-search-input {
    width: 100%;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--app-surface);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.chatbot-search-input:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

/* ========== Chatbot Dropdown ========== */
.chatbot-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chatbot-dropdown.show {
    display: block;
}

.chatbot-option {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--app-bg);
    transition: all 0.3s ease;
}

.chatbot-option:last-child {
    border-bottom: none;
}

.chatbot-option:hover {
    background: var(--app-bg);
}

.chatbot-option.selected {
    background: var(--app-primary-light);
}

.chatbot-option-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chatbot-option-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.chatbot-option-stats {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ========== Page Container ========== */
.page-container {
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .app-header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
    }

    #app-header {
        height: auto;
    }

    .app-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .chatbot-selector-wrapper {
        min-width: 200px;
    }

    .page-container {
        height: calc(100vh - 120px);
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 16px;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 13px;
    }

    .nav-link svg {
        display: none;
    }
}

/* ========== Scrollbar Styling ========== */
.chatbot-dropdown::-webkit-scrollbar {
    width: 6px;
}

.chatbot-dropdown::-webkit-scrollbar-track {
    background: var(--app-bg);
}

.chatbot-dropdown::-webkit-scrollbar-thumb {
    background: var(--app-border);
    border-radius: 3px;
}

.chatbot-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}
