:root {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-cable: #ef4444;
    --accent-nameplate: #eab308;
    --accent-plastic: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 250px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-item.active {
    border-left: 3px solid var(--primary);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0 2rem;
}

.user-profile {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    border: 1px solid var(--glass-border);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    overflow: hidden;
}

.lead-input-section {
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

.lead-input-section h3,
.panel-header h3 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.3rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    padding: 0.85rem 1.5rem;
    width: 100%;
    font-size: 1rem;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.btn-icon:hover {
    color: white;
    transform: rotate(180deg);
}

.recent-leads-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.leads-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.lead-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s;
}

.lead-card:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.lead-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lead-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.tag-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.tag-badge.tag-cable {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-cable);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.tag-badge.tag-nameplate {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-nameplate);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.tag-badge.tag-plastic {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-plastic);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.tag-badge.tag-unknown {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.lead-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.lead-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.generate-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex: 1;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 600px;
    max-width: 90%;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.hover-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.hidden {
    display: none !important;
}
/* Additional Styles for v2.0 */

/* View Content */
.view-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.view-content.hidden {
    display: none;
}

/* Template View - ensure hidden works */
#templates-view.hidden {
    display: none !important;
}

/* Status Messages */
.status-msg {
    font-size: 13px;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
}

.status-msg.success {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.status-msg.error {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Console Log */
.console-log {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: #cbd5e1;
    overflow-y: auto;
    max-height: 200px;
    line-height: 1.5;
}

/* Data Table */
.data-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}

.data-table th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 14px;
    padding: 12px 8px;
}

.data-table td {
    padding: 12px 8px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Form Select */
select {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
}

select option {
    color: #000;
}

/* Log Entry */
.log-entry {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.log-entry .timestamp {
    color: var(--text-muted);
    font-size: 11px;
}

.log-entry .level-info { color: #3b82f6; }
.log-entry .level-success { color: #10b981; }
.log-entry .level-error { color: #ef4444; }
.log-entry .level-warning { color: #f59e0b; }

/* Button Secondary */
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Auto Parts Tag */
.tag-auto {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

/* Source Badge */
.source-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

/* Contact Info Highlight */
.contact-highlight {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
    padding: 8px;
    margin: 8px 0;
    border-radius: 4px;
}

/* Generic Email Warning */
.generic-warning {
    color: #f59e0b;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Template Tabs */
.tab-btn {
    padding: 8px 16px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: #fff;
}

.template-tab-content {
    display: block;
}

.template-tab-content.hidden {
    display: none;
}

/* Variable Chips */
.var-chip {
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    color: #a5b4fc;
    font-size: 11px;
    font-family: 'Monaco', 'Menlo', monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.var-chip:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: #6366f1;
}

/* Upload Dropzone */
#upload-dropzone:hover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}

#upload-dropzone.dragover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

/* File Item */
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 8px;
}

.file-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
