/* ========================================
   Smartie Chat Interface - CSS Styles
   Smart Technologies Limited
   ======================================== */

/* CSS Variables / Design Tokens */
:root {
    /* Colors */
    --primary-deep: #1e3a8a;
    --primary-medium: #2563eb;
    --primary-light: #3b82f6;
    --primary-pale: #93c5fd;
    --primary-ghost: #dbeafe;
    
    --secondary-cyan: #06b6d4;
    --accent-teal: #14b8a6;
    
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --bg-gray: #f1f5f9;
    --bg-dark: #e2e8f0;
    
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-dark) 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* ========================================
   Chat Container
   ======================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-white);
    box-shadow: var(--shadow-xl);
}

@media (min-width: 1024px) {
    .chat-container {
        margin: 2rem auto;
        height: calc(100vh - 4rem);
        border-radius: var(--radius-xl);
        overflow: hidden;
    }
}

/* ========================================
   Header
   ======================================== */
.chat-header {
    background: linear-gradient(135deg, var(--primary-deep) 0%, var(--primary-medium) 50%, var(--primary-light) 100%);
    padding: var(--space-md) var(--space-lg);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: 10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: white;
    border-radius: 50%;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.logo-icon svg,
.logo-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--bg-white);
    letter-spacing: -0.5px;
    margin-bottom: 0.125rem;
}

.logo-text p {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
}

.stl-brand {
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

.info-btn,
.clear-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.15);
    color: var(--bg-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
}

.info-btn:hover,
.clear-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.info-btn:active,
.clear-btn:active {
    transform: translateY(0);
}

.info-btn svg,
.clear-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Modal Styles
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    padding: var(--space-lg);
}

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

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 480px;
    width: 100%;
    position: relative;
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.help-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.help-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-light);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.help-list li:hover {
    background: var(--bg-gray);
}

.help-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.help-list strong {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.help-list p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Confirmation Modal */
.modal-confirm {
    text-align: center;
    max-width: 400px;
}

.modal-confirm h2 {
    margin-bottom: var(--space-sm);
}

.modal-confirm > p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: var(--space-xl);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.btn-cancel,
.btn-confirm {
    padding: 0.625rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.btn-cancel {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: var(--bg-dark);
}

.btn-confirm {
    background: var(--error);
    color: var(--bg-white);
}

.btn-confirm:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ========================================
   Chat Messages Area
   ======================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ========================================
   Welcome Screen
   ======================================== */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    animation: fadeInUp 0.6s ease-out;
}

.welcome-screen.hidden {
    display: none;
}

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

.welcome-avatar {
    width: 80px;
    height: 80px;
    margin-bottom: var(--space-lg);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.welcome-avatar svg,
.welcome-avatar img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.3));
    border-radius: 20px;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.welcome-text {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 500px;
    line-height: 1.7;
    margin-bottom: var(--space-xl);
}

.suggested-questions {
    width: 100%;
    max-width: 600px;
}

.suggested-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.question-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-sm);
}

.question-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.question-btn:hover {
    background: var(--primary-ghost);
    border-color: var(--primary-pale);
    color: var(--primary-deep);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.question-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ========================================
   Messages
   ======================================== */
.message {
    display: flex;
    gap: var(--space-sm);
    animation: messageSlideIn 0.3s ease-out;
    max-width: 85%;
}

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

/* User Messages */
.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-medium) 100%);
    color: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
}

.message-user .message-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

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

.message-user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Smartie Messages */
.message-smartie {
    align-self: flex-start;
}

.message-smartie .message-content {
    background: var(--bg-gray);
    color: var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
    padding: var(--space-md) var(--space-lg);
    position: relative;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-avatar svg,
.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.message-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Markdown Styles in Messages */
.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

.message-text code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.875em;
}

.message-text pre {
    background: rgba(0, 0, 0, 0.08);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-sm) 0;
}

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

.message-text ul,
.message-text ol {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.message-text li {
    margin-bottom: 0.25rem;
}

.message-text a {
    color: var(--primary-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-user .message-text a {
    color: var(--bg-white);
}

.message-text p {
    margin-bottom: var(--space-sm);
}

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

.message-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

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

.copy-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    opacity: 0;
}

.message-smartie:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--bg-dark);
    color: var(--text-secondary);
}

.copy-btn.copied {
    color: var(--success);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Typing Indicator
   ======================================== */
.typing-indicator .message-content {
    padding: var(--space-md) var(--space-lg);
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: var(--text-light);
    }
    30% {
        transform: translateY(-8px);
        background: var(--primary-light);
    }
}

/* ========================================
   Error Message
   ======================================== */
.message-error {
    align-self: center;
    max-width: 400px;
}

.message-error .message-content {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
}

.error-icon {
    width: 40px;
    height: 40px;
    color: var(--error);
}

.error-icon svg {
    width: 100%;
    height: 100%;
}

.error-text {
    font-size: 0.9375rem;
    color: #b91c1c;
}

.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.5rem 1rem;
    background: var(--bg-white);
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--error);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.retry-btn:hover {
    background: var(--error);
    color: var(--bg-white);
    border-color: var(--error);
}

.retry-btn svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   Input Area
   ======================================== */
.chat-input-area {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
}

.input-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.input-wrapper {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    background: var(--bg-light);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-sm);
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: 0.9375rem;
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-md);
    resize: none;
    min-height: 44px;
    max-height: 150px;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-light);
}

.message-input:focus {
    outline: none;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-medium) 100%);
    color: var(--bg-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:disabled {
    background: var(--bg-dark);
    color: var(--text-light);
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.send-btn:not(:disabled):active {
    transform: translateY(0);
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
}

/* ========================================
   Toast Notification
   ======================================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-white);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

/* ========================================
   Loading Skeleton
   ======================================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-gray) 25%, var(--bg-dark) 50%, var(--bg-gray) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .chat-header {
        padding: var(--space-md);
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-text h1 {
        font-size: 1.25rem;
    }
    
    .logo-text p {
        font-size: 0.75rem;
    }
    
    .chat-messages {
        padding: var(--space-md);
    }
    
    .welcome-screen {
        padding: var(--space-lg) var(--space-md);
    }
    
    .welcome-avatar {
        width: 64px;
        height: 64px;
    }
    
    .welcome-screen h2 {
        font-size: 1.25rem;
    }
    
    .welcome-text {
        font-size: 0.9375rem;
    }
    
    .question-buttons {
        grid-template-columns: 1fr;
    }
    
    .question-btn {
        font-size: 0.875rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input-area {
        padding: var(--space-sm) var(--space-md) var(--space-md);
    }
    
    .input-hint {
        display: none;
    }
}

@media (max-width: 480px) {
    .logo-text p .stl-brand {
        display: none;
    }
    
    .logo-text p::after {
        content: 'STL';
    }
    
    .header-actions {
        gap: var(--space-xs);
    }
    
    .info-btn,
    .clear-btn {
        width: 36px;
        height: 36px;
    }
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-light: #000;
        --border-medium: #000;
    }
    
    .message-smartie .message-content {
        border: 2px solid var(--text-primary);
    }
    
    .message-user .message-content {
        border: 2px solid var(--bg-white);
    }
}

