/* 
 * Inventory Manager - Modern UI
 * Clean, professional design inspired by Linear/Vercel/Stripe
 */

/* ===== CSS Variables ===== */
:root {
    /* Colors - Light Mode */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --bg-hover: #f0f0f0;
    
    --text-primary: #0a0a0a;
    --text-secondary: #525252;
    --text-muted: #a3a3a3;
    
    --border: #e5e5e5;
    --border-light: #f0f0f0;
    
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.1);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition: all 0.15s ease;
    
    /* Surface aliases (light mode) */
    --surface: #ffffff;
    --surface-alt: #f5f5f5;
    --surface-hover: #f0f0f0;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #262626;
    
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #525252;
    
    --border: #262626;
    --border-light: #1a1a1a;
    
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.15);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    
    /* Surface aliases (dark mode) */
    --surface: #141414;
    --surface-alt: #1a1a1a;
    --surface-hover: #262626;
}

/* Fix for native select/option elements in dark mode */
[data-theme="dark"] select,
[data-theme="dark"] select option {
    background-color: #1a1a1a;
    color: #fafafa;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea {
    background-color: #1a1a1a;
    color: #fafafa;
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo h1 .brand {
    color: var(--accent);
}

.logo-icon {
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-light);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

/* ===== Upload Section ===== */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-area h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.upload-hint {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
    margin-top: 0.5rem;
}

/* ===== Sample Data Section ===== */
.sample-data-section {
    margin-top: 1rem;
}

.sample-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.sample-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sample-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sample-group-header {
    background: var(--bg-tertiary);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition);
}

.sample-group-header:hover {
    background: var(--bg-hover);
}

.sample-group-header h4 {
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sample-group-header .chevron {
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.sample-group.expanded .chevron {
    transform: rotate(180deg);
}

.sample-group-files {
    display: none;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.sample-group.expanded .sample-group-files {
    display: block;
}

.sample-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sample-file:hover {
    background: var(--bg-tertiary);
}

.sample-file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sample-file-icon {
    font-size: 1.25rem;
}

.sample-file-details h5 {
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.sample-file-details span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sample-file-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

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

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 0.5rem;
}

/* ===== Chat Section ===== */
.chat-section {
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 95%;
    width: fit-content;
}

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

.message.assistant {
    align-self: flex-start;
    max-width: 100%;
}

.message-content {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

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

.message-content p {
    margin-bottom: 0.25rem;
}

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

.message-content ul {
    margin: 0.25rem 0;
    padding-left: 1rem;
}

.message-content li {
    margin-bottom: 0.125rem;
}

.message-content strong {
    font-weight: 600;
}

.message-content code {
    background: var(--bg-hover);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.875em;
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
}

#chatInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    resize: none;
    transition: var(--transition);
}

#chatInput:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

#chatInput::placeholder {
    color: var(--text-muted);
}

.btn-send {
    padding: 0.75rem 1.25rem;
}

/* ===== Sidebar ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Reports Section ===== */
.reports-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.reports-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.reports-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reports-body {
    padding: 1rem;
}

.report-group {
    margin-bottom: 1rem;
}

.report-group:last-child {
    margin-bottom: 0;
}

.report-group h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.625rem;
}

.report-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-report {
    width: 100%;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition);
}

.btn-report:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-report.btn-featured {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-report.btn-featured:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-report:disabled {
    opacity: 0.4;
}

/* ===== Quick Actions ===== */
.quick-actions {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.quick-actions h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.quick-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.quick-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Footer ===== */
.footer {
    padding: 1rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
}

/* ===== Loading ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

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

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

/* ===== Inline Button Spinner ===== */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.65;
}

/* ===== File Type Radio ===== */
.file-types {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: center;
}

.file-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-type input {
    accent-color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .upload-area {
        padding: 1.5rem;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ===== Demo Tour ===== */
.demo-banner {
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    color: white;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.demo-banner-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.demo-banner .btn {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.demo-banner .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}
