/* ══════════════════════════════════════════════════════════════════════
   GLISSEVOLVE CHATBOT - Chat Interface
   ══════════════════════════════════════════════════════════════════════ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --white: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════════════════════ */

.app {
    max-width: 900px;
    margin: 0 auto;
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════════════════ */

.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.header .tagline {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 400;
}

.header-links {
    display: flex;
    gap: 8px;
}

.header-link {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.header-link:hover {
    color: var(--primary);
    background: var(--gray-100);
}

/* ══════════════════════════════════════════════════════════════════════
   MAIN
   ══════════════════════════════════════════════════════════════════════ */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

/* ══════════════════════════════════════════════════════════════════════
   CONFIG PANEL
   ══════════════════════════════════════════════════════════════════════ */

.config-panel {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 24px;
    flex-shrink: 0;
}

.config-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.config-item {
    flex: 1;
    min-width: 150px;
}

.config-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.config-item select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

/* ══════════════════════════════════════════════════════════════════════
   INITIAL INPUTS
   ══════════════════════════════════════════════════════════════════════ */

.initial-inputs {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.initial-inputs.hidden {
    display: none;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-group .optional {
    font-weight: 400;
    color: var(--gray-400);
}

.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

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

/* ══════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════ */

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* ══════════════════════════════════════════════════════════════════════
   CHAT ZONE
   ══════════════════════════════════════════════════════════════════════ */

.chat-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-zone.hidden {
    display: none;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant,
.message.client-request {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.6;
}

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

.message.assistant .message-content {
    background: var(--gray-100);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
}

.message.client-request .message-content {
    background: var(--gray-50);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
}

.message-header {
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 4px;
    opacity: 0.7;
}

.message.user .message-header {
    text-align: right;
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ══════════════════════════════════════════════════════════════════════
   CHAT INPUT ZONE
   ══════════════════════════════════════════════════════════════════════ */

.chat-input-zone {
    border-top: 1px solid var(--gray-200);
    padding: 16px 24px;
    background: var(--white);
    flex-shrink: 0;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input-container textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.btn-send {
    background: var(--primary);
    color: var(--white);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-hover);
}

.chat-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

/* ══════════════════════════════════════════════════════════════════════
   METRICS BAR
   ══════════════════════════════════════════════════════════════════════ */

.metrics-bar {
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    padding: 8px 24px;
    flex-shrink: 0;
}

.metrics-content {
    display: flex;
    gap: 24px;
    justify-content: flex-start;
}

.metric {
    display: flex;
    align-items: center;
    gap: 6px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 500;
}

.metric-value {
    font-size: 0.75rem;
    color: var(--gray-700);
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════════
   LOADING
   ══════════════════════════════════════════════════════════════════════ */

.loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 100;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading span {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════════
   ERROR
   ══════════════════════════════════════════════════════════════════════ */

.error-container {
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 101;
    animation: slideDown 0.3s ease;
}

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

.error-container.hidden {
    display: none;
}

.error-icon {
    font-size: 1.25rem;
}

.error-container span:not(.error-icon) {
    flex: 1;
    font-size: 0.875rem;
    color: #991B1B;
}

.error-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #991B1B;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* ══════════════════════════════════════════════════════════════════════
   HIDDEN UTILITY
   ══════════════════════════════════════════════════════════════════════ */

.hidden {
    display: none !important;
}

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .header h1 {
        font-size: 1.125rem;
    }

    .header-links {
        width: 100%;
        justify-content: flex-start;
    }

    .config-panel {
        padding: 12px 16px;
    }

    .config-row {
        gap: 12px;
    }

    .config-item {
        min-width: 120px;
    }

    .initial-inputs {
        padding: 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-zone {
        padding: 12px 16px;
    }

    .metrics-bar {
        padding: 8px 16px;
    }

    .metrics-content {
        flex-wrap: wrap;
        gap: 12px;
    }

    .message {
        max-width: 90%;
    }
}