/*
 * SmartBiz AI - Premium Glassmorphic UI CSS Framework
 * Supporting Modern Dark/Light Theme Switching
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette - HSL Tailwind Tailored Styles */
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Light Theme Settings */
    --bg-primary: #F8FAFC;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-glass-input: rgba(255, 255, 255, 0.8);
    --border-glass: #E2E8F0;
    --border-glass-subtle: rgba(226, 232, 240, 0.5);
    
    --text-main: #0F172A;
    --text-muted: #64748b;
    --text-white: #ffffff;
    
    --accent-primary: #2563EB;
    --accent-primary-hover: #1d4ed8;
    --accent-secondary: #06B6D4;
    --accent-glow: rgba(37, 99, 235, 0.15);
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    
    --shadow-main: 0 4px 20px 0 rgba(15, 23, 42, 0.05);
    --shadow-hover: 0 10px 30px 0 rgba(15, 23, 42, 0.1);
    
    --glass-blur: blur(16px);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-sidebar: #111827;
    --bg-card: #1E293B;
    --bg-glass-input: rgba(30, 41, 59, 0.8);
    --border-glass: #334155;
    --border-glass-subtle: rgba(51, 65, 85, 0.5);
    
    --text-main: #F8FAFC;
    --text-muted: #94a3b8;
    
    --accent-glow: rgba(37, 99, 235, 0.3);
    --shadow-main: 0 4px 20px 0 rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 30px 0 rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Base Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Glassmorphism Classes */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-main);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: rgba(99, 102, 241, 0.25);
    transform: translateY(-2px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel {
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-glass);
}

/* Core Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    min-height: 100vh;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    margin-bottom: 32px;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.nav-item a:hover, .nav-item.active a {
    color: var(--text-main);
    background: rgba(99, 102, 241, 0.1);
    border-left: 3px solid var(--accent-primary);
    padding-left: 13px;
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Main Content Area */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Header UI Elements */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--text-muted);
    font-size: 14px;
}

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

/* Glass Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-family: var(--font-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-hover) 100%);
    color: var(--text-white);
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.6);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Theme Toggle Slider */
.theme-switch {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.theme-switch:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

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

.stat-value {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

/* Grid Layouts for views */
.grid-2col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .grid-2col {
        grid-template-columns: 1fr;
    }
}

/* Kanban Board Styling */
.kanban-container {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: 70vh;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 300px;
    width: 300px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    max-height: 75vh;
}

.column-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    border-bottom: 1px solid var(--border-glass);
}

.column-header h3 {
    font-size: 15px;
    font-family: var(--font-heading);
}

.stage-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
}

.kanban-cards-container {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 150px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass-subtle);
    border-radius: 12px;
    padding: 16px;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.1);
}

.kanban-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.kanban-card .company-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-glass-subtle);
    padding-top: 10px;
    font-size: 12px;
}

.lead-value {
    font-weight: 700;
    color: var(--accent-success);
}

/* Tables and Lists */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass-subtle);
    font-size: 14px;
}

.custom-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

/* Badges styling */
.badge {
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}

.badge-high { background: rgba(239, 68, 68, 0.1); color: var(--accent-danger); }
.badge-medium { background: rgba(245, 158, 11, 0.1); color: var(--accent-warning); }
.badge-low { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); }

/* Forms Elements & Inputs */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: var(--bg-glass-input);
    border: 1px solid var(--border-glass);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-main);
    font-family: var(--font-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Unified Inbox View styling */
.inbox-layout {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    height: 78vh;
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
}

@media (max-width: 1200px) {
    .inbox-layout {
        grid-template-columns: 280px 1fr;
    }
    .inbox-sidebar-details {
        display: none;
    }
}

.inbox-threads {
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-sidebar);
}

.thread-search-box {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
}

.thread-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass-subtle);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thread-item:hover, .thread-item.active {
    background: rgba(99, 102, 241, 0.08);
}

.thread-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
}

.thread-msg-prev {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-bubble {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble.inbound {
    align-self: flex-start;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-glass);
    border-bottom-left-radius: 4px;
}

.message-bubble.outbound {
    align-self: flex-end;
    background: var(--accent-primary);
    color: var(--text-white);
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-input-row {
    display: flex;
    gap: 12px;
}

/* AI reply suggestion container */
.ai-suggestion-box {
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed var(--accent-primary);
    border-radius: 12px;
    padding: 12px;
    display: none;
    font-size: 13px;
}

.ai-header-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 6px;
}

/* Interactive Visual Workflow Builder Styles */
.workflow-editor {
    display: flex;
    gap: 24px;
    height: 75vh;
}

.workflow-sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.action-drag-item {
    padding: 12px;
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    background: var(--bg-card);
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
}

.workflow-canvas {
    flex-grow: 1;
    border: 2px dashed var(--border-glass);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.02);
    overflow: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    position: relative;
}

.wf-node {
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    text-align: center;
    box-shadow: var(--shadow-main);
}

.wf-connector-line {
    width: 2px;
    height: 30px;
    background: var(--accent-primary);
}

/* Toast notifications popups */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    border-left: 4px solid var(--accent-primary);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-main);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    font-size: 13px;
    font-weight: 500;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Animations declarations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* Responsive sidebar drawers for mobile */
@media (max-width: 768px) {
    .sidebar {
        display: none; /* In production, toggles into navigation topbar */
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
}
