/* Kristall Home Admin Glassmorphism Theme */
:root {
    --bg-dark: #0b0f19;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --primary: #00D2FF;
    --primary-gradient: linear-gradient(135deg, #00D2FF 0%, #00F2FE 100%);
    --accent: #3b82f6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 210, 255, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

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

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

/* Sidebar */
.sidebar {
    width: 280px;
    margin: 16px;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--panel-border);

}

.logo-icon {
    font-size: 28px;
}

.logo-text .title {
    font-weight: 700;
    font-size: 18px;
    display: block;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text .subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

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

.nav-item.active {
    background: var(--primary-gradient);
    color: #0b0f19;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 210, 255, 0.4);
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.bot-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;

}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 16px 16px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-bar {
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title h1 {
    font-size: 22px;
    font-weight: 700;
}

.page-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tabs */
.tab-content {
    display: none;
}

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

.split-view {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
}

.card-section {
    padding: 28px;
}

.section-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Form Elements */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.field-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.field-title {
    font-weight: 600;
    font-size: 15px;
}

.field-key {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--primary);
    background: rgba(0, 210, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

textarea, input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

textarea:focus, input:focus {
    border-color: var(--primary);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #0b0f19;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 210, 255, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

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

.btn-logout {
    background: transparent;
    color: var(--danger);
    font-size: 13px;
    padding: 6px 12px;
}

/* Telegram Widget Preview */
.preview-panel {
    padding: 24px;
    position: sticky;
    top: 16px;
    height: fit-content;
}

.telegram-widget {
    background: #17212b;
    border-radius: 16px;
    overflow: hidden;
    margin-top: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.tg-header {
    background: #242f3d;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0088cc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tg-name {
    font-weight: 600;
    font-size: 14px;
    display: block;
}

.tg-sub {
    font-size: 11px;
    color: #7f91a4;
}

.tg-body {
    padding: 16px;
    background-image: radial-gradient(#202b36 1px, transparent 1px);
    background-size: 12px 12px;
}

.tg-bubble {
    background: #182533;
    padding: 12px;
    border-radius: 12px 12px 12px 2px;
    font-size: 13.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    margin-bottom: 12px;
    position: relative;
}

.tg-time {
    font-size: 10px;
    color: #6c7e90;
    float: right;
    margin-top: 6px;
}

.tg-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tg-btn {
    background: #242f3d;
    border: none;
    color: #6ab3f3;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: default;
}

/* CRM Table */
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.badge {
    background: rgba(0, 210, 255, 0.15);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 8px;
}

.search-bar {
    display: flex;
    gap: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--panel-border);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

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

/* Login Modal */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(20px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 380px;
    padding: 36px;
}

.login-card .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    margin-top: 12px;
}

.hidden {
    display: none !important;
}

/* Funnel Split & Accordion Styles */
.funnel-split {
    grid-template-columns: 460px 1fr;
    height: calc(100vh - 120px);
}

.funnel-tree-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    overflow-y: auto;
}

.funnel-toolbar {
    margin-bottom: 14px;
}

.accordion-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.accordion-stage {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: hidden;
}

.accordion-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: rgba(30, 41, 59, 0.5);
    user-select: none;
    transition: background 0.2s ease;
}

.accordion-header:hover {
    background: rgba(30, 41, 59, 0.8);
}

.accordion-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.accordion-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
}

.stage-1 .accordion-badge { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.stage-2 .accordion-badge { background: rgba(0, 210, 255, 0.2); color: #00D2FF; }
.stage-3 .accordion-badge { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.stage-4 .accordion-badge { background: rgba(236, 72, 153, 0.2); color: #ec4899; }

.accordion-title {
    font-weight: 600;
    font-size: 14px;
}

.accordion-count {
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 10px;
}

.accordion-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    max-height: 450px;
    overflow-y: auto;
}

.accordion-body.hidden {
    display: none;
}

.funnel-node-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.funnel-node-card:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: var(--primary);
}

.funnel-node-card.active {
    background: rgba(0, 210, 255, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.3);
}

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

.node-card-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
}

.node-card-snippet {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-card-meta {
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    align-items: center;
}

.module-badge-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(0, 210, 255, 0.15);
    color: var(--primary);
    border: 1px solid rgba(0, 210, 255, 0.3);
}

.btn-tag {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.view-mode-toggle {
    display: flex;
    gap: 4px;
    background: rgba(15, 23, 42, 0.6);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
}

.view-mode-toggle .btn {
    padding: 6px 12px;
    font-size: 12px;
    background: transparent;
    color: var(--text-muted);
}

.view-mode-toggle .btn.active {
    background: var(--primary-gradient);
    color: #0b0f19;
    font-weight: 600;
}

/* n8n Canvas & Slide-over Inspector Drawer Styles */
.n8n-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    position: relative;
    overflow: hidden;
}

.n8n-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    margin-bottom: 10px;
    border-radius: 12px;
}

.n8n-toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.n8n-select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.n8n-canvas-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    background-color: #0b0f19;
    border-radius: 16px;
    border: 1px solid var(--panel-border);
    overflow: hidden;
}

.n8n-cy-canvas {
    width: 100%;
    height: 100%;
}

.n8n-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: 440px;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--panel-border);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.n8n-drawer.open {
    transform: translateX(0);
}

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

.drawer-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-close-drawer:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.drawer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
}

/* Graph Split Screen Styles */
.graph-split {
    grid-template-columns: 1fr 420px;
    height: calc(100vh - 120px);
}

.graph-canvas-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.graph-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.graph-toolbar input, .graph-toolbar select {
    width: auto;
    padding: 8px 12px;
    font-size: 13px;
}

.cy-container {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    position: relative;
}

.node-editor-panel {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    max-height: 100%;
}

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

.editor-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.node-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.col-6 {
    flex: 1;
}

.buttons-section {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-title-row h4 {
    font-size: 13px;
    color: var(--text-muted);
}

.buttons-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid var(--panel-border);
}

.btn-item .target-tag {
    font-size: 11px;
    color: var(--primary);
    background: rgba(0, 210, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.btn-item-del {
    color: var(--danger);
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 14px;
}

.small-preview {
    margin-top: 10px;
}

/* Modals */
.hidden, .modal-overlay.hidden, .login-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card {
    width: 440px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-card h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-block {
    width: 100%;
}

