:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #151520;
    --neon-green: #39ff14;
    --neon-orange: #ff8c00;
    --neon-blue: #00f3ff;
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --border-color: #2d2d3f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Neon Text Utilities */
.neon-text {
    color: var(--neon-green);
    text-shadow:
        0 0 5px var(--neon-green),
        0 0 15px var(--neon-green),
        0 0 30px var(--neon-green),
        0 0 60px var(--neon-green);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

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

.sidebar nav ul {
    list-style: none;
}

.sidebar nav ul li {
    padding: 12px 20px;
    margin-bottom: 15px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: linear-gradient(145deg, #181825, #11111a);
    box-shadow: 4px 4px 10px #08080c, -4px -4px 10px #222232;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
}

.sidebar nav ul li:hover, .sidebar nav ul li.active {
    color: var(--text-main);
    background: linear-gradient(145deg, #152210, #1b3510);
    border: 1px solid var(--neon-green);
    box-shadow: 
        inset 2px 2px 5px rgba(57, 255, 20, 0.2), 
        0 0 10px rgba(57, 255, 20, 0.4),
        0 0 20px rgba(57, 255, 20, 0.2);
    text-shadow: 0 0 5px var(--neon-green);
    transform: translateY(-2px);
}

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

.top-nav {
    height: 70px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
}

.content-area {
    padding: 40px;
    flex: 1;
    overflow-y: auto;
}

.panel {
    display: none;
    animation: fadeIn 0.4s ease;
}

.panel.active {
    display: block;
}

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

/* Cards & Stats */
.stats-grid, .connection-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.stat-card, .card {
    background-color: var(--bg-panel);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover, .card:hover {
    transform: translateY(-5px);
    border-color: var(--neon-orange);
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.4), inset 0 0 10px rgba(255, 140, 0, 0.1);
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.neon-number {
    font-size: 38px;
    font-weight: 700;
    color: var(--text-main);
    text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue), 0 0 40px var(--neon-blue);
}

/* Buttons */
.neon-btn {
    background: transparent;
    color: var(--neon-orange);
    border: 2px solid var(--neon-orange);
    padding: 10px 25px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    margin-top: 15px;
    box-shadow: 0 0 10px rgba(255, 140, 0, 0.2);
}

.neon-btn:hover {
    background: var(--neon-orange);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--neon-orange), 0 0 40px var(--neon-orange);
    text-shadow: none;
}

/* Bot Toggle Button */
.active-bot-btn {
    background: rgba(57, 255, 20, 0.1) !important;
    color: var(--neon-green) !important;
    border-color: var(--neon-green) !important;
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.3) !important;
}
.active-bot-btn:hover {
    background: var(--neon-green) !important;
    color: #000 !important;
    box-shadow: 0 0 20px var(--neon-green), 0 0 40px var(--neon-green) !important;
}

.inactive-bot-btn {
    background: rgba(255, 50, 50, 0.1) !important;
    color: #ff3232 !important;
    border-color: #ff3232 !important;
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.3) !important;
}
.inactive-bot-btn:hover {
    background: #ff3232 !important;
    color: #000 !important;
    box-shadow: 0 0 20px #ff3232, 0 0 40px #ff3232 !important;
}

/* Forms & Grid */
.neon-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.neon-form-grid .full-width {
    grid-column: 1 / -1;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
}
.neon-input {
    width: 100%;
    padding: 12px 15px;
    background: #11111a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.3s ease;
}
.neon-input:focus {
    outline: none;
    border-color: var(--neon-blue);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.neon-btn.small {
    padding: 8px 15px;
    font-size: 14px;
    margin-top: 0;
}

/* Live Chat Interface */
.chat-container {
    display: flex;
    height: 100%;
    min-height: calc(100vh - 200px); /* Fill most of the screen */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-dark);
}

.chat-sidebar {
    width: 300px;
    border-right: 1px solid var(--border-color);
    background: #11111a;
    display: flex;
    flex-direction: column;
}

.chat-contacts {
    flex: 1;
    overflow-y: auto;
}

.chat-contact {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: all 0.2s;
}

.chat-contact:hover, .chat-contact.active {
    background: rgba(57, 255, 20, 0.1);
    border-left: 3px solid var(--neon-green);
}

.chat-contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2a2a35;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-contact-info h4 {
    margin: 0 0 5px 0;
    color: var(--text-main);
    font-size: 14px;
}

.chat-contact-info p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent entire chat area from scrolling, only messages should scroll */
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    background: #11111a;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="1" fill="%23ffffff" fill-opacity="0.05"/></svg>');
}

/* Media styling for chats */
.chat-media-preview {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    margin-bottom: 5px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message .bubble {
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.message.received .bubble {
    background: #1e1e2d;
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.message.sent .bubble {
    background: rgba(0, 243, 255, 0.15);
    color: var(--neon-blue);
    border-bottom-right-radius: 2px;
    border: 1px solid rgba(0, 243, 255, 0.3);
}

.message.sent.bot .bubble {
    background: rgba(57, 255, 20, 0.15);
    color: var(--neon-green);
    border: 1px solid rgba(57, 255, 20, 0.3);
}

.message .time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 5px;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background: #11111a;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.attachment-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.send-btn {
    background: var(--neon-blue);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 10px var(--neon-blue);
}

/* Lockout Overlay */
#lockout-overlay, #pdf-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lockout-content {
    background: #151520;
    padding: 50px;
    border-radius: 12px;
    border: 1px solid #ff3232;
    box-shadow: 0 0 50px rgba(255, 50, 50, 0.2);
    text-align: center;
    max-width: 500px;
}

.pdf-modal-content {
    background: #151520;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--neon-blue);
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.2);
    width: 90%;
    max-width: 800px;
}

/* Neon Clock */
.neon-clock {
    font-family: 'Courier New', monospace;
    font-size: 24px !important;
    font-weight: bold;
    color: var(--neon-cyan) !important;
    text-shadow: 0 0 5px var(--neon-cyan), 0 0 15px var(--neon-cyan);
    margin-bottom: 5px;
}

/* Tables */
.neon-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.neon-table th, .neon-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.neon-table th {
    color: var(--text-muted);
    font-weight: 600;
}

.neon-table tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

/* Forms */
textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-size: 15px;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--neon-purple);
    box-shadow: 0 0 10px rgba(188, 19, 254, 0.2);
}

.mt-4 {
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
    .sidebar nav ul { display: flex; overflow-x: auto; }
    .sidebar nav ul li { white-space: nowrap; }
}
/* Image Slots */
.img-slot {
    width: 100px;
    height: 100px;
    border: 1px dashed var(--neon-cyan);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    background: rgba(0, 255, 255, 0.05);
    overflow: hidden;
}
.img-slot:hover {
    border-color: var(--neon-purple);
    background: rgba(176, 38, 255, 0.1);
}
.img-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}
.plus-icon {
    font-size: 24px;
    color: var(--text-muted);
}
.remove-img {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modal Styles */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.7); backdrop-filter: blur(5px); }
.modal-content { background-color: var(--bg-dark); margin: 10% auto; padding: 20px; border: 1px solid var(--neon-blue); width: 80%; border-radius: 10px; box-shadow: 0 0 20px var(--neon-blue); position: relative; }
.close-btn { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.close-btn:hover { color: #fff; text-decoration: none; cursor: pointer; }

/* Fix dropdown option visibility */
select {
    color: var(--text-main);
    background-color: var(--surface-light);
}
select option {
    background-color: var(--bg-dark);
    color: #ffffff;
}
/* Mobile Responsiveness */
.mobile-header {
    display: none;
    background: var(--bg-color);
    padding: 15px 20px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.mobile-menu-btn {
    background: transparent;
    border: none;
    color: var(--neon-blue);
    font-size: 24px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 60px; /* Below mobile header */
        height: calc(100vh - 60px);
        width: 250px;
        z-index: 999;
        background: var(--bg-color);
        transition: left 0.3s ease;
        border-right: 1px solid var(--border-color);
    }
    
    .sidebar.active-mobile {
        left: 0;
    }
    
    .main-content {
        margin-top: 60px;
        padding: 15px;
        width: 100%;
    }
    
    /* Grids to single column */
    .neon-form-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
    }
    
    .neon-table {
        min-width: 600px;
    }
    
    /* Generic flex containers that need to stack */
    div[style*="display: flex"][style*="gap"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .mobile-header h2 {
        font-size: 16px !important;
    }
}


.typing-indicator {
    background-color: var(--glass-bg);
    will-change: transform;
    width: auto;
    border-radius: 10px;
    padding: 8px 15px;
    display: inline-block;
    border: 1px solid var(--glass-border);
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: var(--text-color);
    display: block;
    border-radius: 50%;
    opacity: 0.4;
    animation: 1s blink infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0.3333s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.6666s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.9999s; }

@keyframes blink {
    50% { opacity: 1; }
}
