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

/* === CSS Variables === */
:root {
    /* LIGHT THEME (Default) */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #60a5fa;
    --secondary: #0ea5e9;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Backgrounds */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #f8fafc;
    /* Keep for backwards compatibility with any hardcoded classes */
    --bg-card: #ffffff;
    --bg-input: #ffffff;

    /* Text & Borders */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Shadows & Radii */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    /* DARK THEME - Modern Elegant Grey */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #71717a;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Backgrounds */
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-dark: #09090b;
    --bg-card: #18181b;
    --bg-input: #09090b;

    /* Text & Borders */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --border-color: #27272a;

    /* Shadows & Radii */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

/* === Layout === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--text-secondary);
    margin-top: 8px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-header .step-number {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

/* === Forms === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s, color 0.3s;
}

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

.form-group input::placeholder {
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* === Buttons === */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

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

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

.btn-block {
    width: 100%;
}

/* === Status Badges === */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-success {
    background: rgba(16, 185, 129, 0.2);
    /* success */
    color: var(--success);
}

.status-warning {
    background: rgba(245, 158, 11, 0.2);
    /* warning */
    color: var(--warning);
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    /* danger */
    color: var(--danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* === Module List === */
.module-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.module-item {
    padding: 14px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.module-item:hover {
    border-color: var(--primary-light);
    background: rgba(37, 99, 235, 0.05);
}

.module-item.selected {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
}

.module-item .module-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.module-item .module-technical {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* === Chat Interface === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
}

.message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
}

.message-user {
    flex-direction: row-reverse;
}

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

.message-user .message-avatar {
    background: var(--primary);
}

.message-assistant .message-avatar {
    background: var(--secondary);
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.5;
}

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

.message-assistant .message-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chat-input-container {
    padding: 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.chat-input-container input {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

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

.chat-input-container button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 0;
}

/* === Loading === */
.loading {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.loading.show {
    display: flex;
}

.loader {
    font-size: 44.8px;
    /* Default size, adjust via font-size */
    width: 1em;
    height: 1em;
    color: var(--primary);
    position: relative;
    background: radial-gradient(0.25em, currentColor 94%, transparent);
}

.loader-sm {
    font-size: 20px;
    color: currentColor;
    /* Match button text color */
}

.loader:before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(0.225em at bottom right, transparent 94%, currentColor) top left,
        radial-gradient(0.225em at bottom left, transparent 94%, currentColor) top right,
        radial-gradient(0.225em at top right, transparent 94%, currentColor) bottom left,
        radial-gradient(0.225em at top left, transparent 94%, currentColor) bottom right;
    background-size: 0.5em 0.5em;
    background-repeat: no-repeat;
    animation: loader 1.5s infinite cubic-bezier(0.3, 1, 0, 1);
}

@keyframes loader {
    33% {
        inset: -0.25em;
        transform: rotate(0deg);
    }

    66% {
        inset: -0.25em;
        transform: rotate(90deg);
    }

    100% {
        inset: 0;
        transform: rotate(90deg);
    }
}

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

/* === Alerts === */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-info {
    background: rgba(14, 165, 233, 0.15);
    border: 1px solid var(--secondary);
    color: var(--secondary);
}

/* === Steps Indicator === */
.steps-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.steps-container::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50px;
    right: 50px;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s;
}

.step-item.active .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.step-item.completed .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-item.active .step-label,
.step-item.completed .step-label {
    color: var(--text-primary);
}

/* === Hidden === */
.hidden {
    display: none !important;
}

/* === Session Info Bar === */
.session-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.session-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.session-info strong {
    color: var(--text-primary);
}

/* === Company Badge === */
.company-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(14, 165, 233, 0.15);
    padding: 4px 10px;
    border-radius: 16px;
    border: 1px solid var(--secondary);
    font-size: 0.85rem;
}

.company-badge label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.company-select {
    background: var(--bg-input);
    border: 1px solid var(--secondary);
    border-radius: 8px;
    color: var(--secondary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 4px 8px;
    cursor: pointer;
    max-width: 180px;
    outline: none;
}

.company-select:hover {
    background: rgba(14, 165, 233, 0.2);
}

.company-select:focus {
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.3);
}

.company-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.company-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(14, 165, 233, 0.2);
    color: var(--text-primary);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon.spinning svg {
    animation: spin 1s linear infinite;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* === Typing Indicator & Timer === */
.typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
}

.typing-dots::after {
    content: '';
    animation: dots 1.5s infinite;
    margin-left: 2px;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

.typing-timer {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    color: var(--secondary);
    background: rgba(14, 165, 233, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

/* === Message Time Info === */
.message-time {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Consolas', 'Monaco', monospace;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}