/* View Management */
.view {
    display: none;
}

.view.active {
    display: block;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --background: #f8fafc;
    --sidebar: #ffffff;
    --sidebar-text: #64748b;
    --sidebar-active: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --purple: #8b5cf6;
    --blue: #3b82f6;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --glass: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-gradient: radial-gradient(circle at top left, #eef2ff 0%, #f1f5f9 50%, #e0e7ff 100%);
}

:root[data-theme="dark"] {
    --background: #0f172a;
    --sidebar: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #334155;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --glass: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --bg-gradient: radial-gradient(circle at top left, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-main);
    overflow-x: hidden;
    transition: var(--transition);
    min-height: 100vh;
}

* {
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

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

/* Sidebar */
.sidebar {
    width: 80px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0.5rem;
    position: fixed;
    height: calc(100vh - 2rem);
    margin: 1rem;
    border-radius: 1.5rem;
    z-index: 100;
    box-shadow: var(--glass-shadow);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar:hover {
    width: 260px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    min-width: 200px;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .logo-text-group {
    opacity: 1;
}

.logo-name {
    font-size: 1.5rem;
    font-weight: 700;
}

.brand-accent-1 {
    color: #1a202c;
    /* Dark Navy/Blue */
}

.brand-accent-2 {
    color: #48bb78;
    /* Vibrant Green */
}

/* Dark mode overrides for brand colors */
:root[data-theme="dark"] .brand-accent-1 {
    color: #f1f5f9;
}

.logo-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0.75rem;
    justify-content: center;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    border-radius: 0.75rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0.5rem;
    width: 100%;
    font-size: 0;
}

.sidebar:hover .nav-item {
    gap: 1.25rem;
    padding: 0.75rem 1rem;
    justify-content: flex-start;
    font-size: 0.875rem;
}

.nav-item:hover {
    background: var(--sidebar-active);
    color: var(--primary);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.nav-item i {
    width: 20px;
    height: 20px;
    min-width: 20px;
}

.user-profile {
    margin-top: auto;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:hover .user-profile {
    padding: 1rem;
    gap: 0.75rem;
    justify-content: flex-start;
}

.user-info {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .user-info {
    opacity: 1;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}


.user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-theme-toggle:hover {
    color: var(--primary) !important;
    transform: rotate(15deg);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 100px;
    padding: 2.5rem;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.header-tag:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.header-tag:active {
    transform: scale(0.95);
}

.btn-outline {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-main);
    text-decoration: none;
}

.btn-outline:hover {
    background: var(--background);
}

/* Modern Stats Cards */
.stats-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.stat-card-modern {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card-modern:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.15);
}

.stat-progress {
    width: 60px;
    height: 60px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: var(--sidebar-active);
    stroke-width: 2.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.circular-chart.purple .circle {
    stroke: var(--purple);
}

.circular-chart.blue .circle {
    stroke: var(--blue);
}

.stat-icon-overlay {
    position: absolute;
    color: var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-overlay i {
    width: 20px;
    height: 20px;
}

.stat-icon-simple {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #f3f0ff;
    color: var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-simple.purple {
    background: #f3f0ff;
    color: var(--purple);
}

.stat-info-modern {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label-modern {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.stat-value-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.stat-value-modern {
    font-size: 1.125rem;
    font-weight: 700;
}

.stat-percent-modern {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-upgrade {
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    background: white;
    border: 1px solid var(--purple);
    color: var(--purple);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-upgrade:hover {
    background: var(--purple);
    color: white;
}

/* Usage Progress Bars */
.usage-bars-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
}

.usage-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.usage-title {
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.usage-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.dot.purple {
    background: var(--purple);
}

.dot.blue {
    background: #00bcd4;
}

.progress-bar-thin {
    height: 10px;
    background: #f1f5f9;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1s ease-out;
}

.progress-fill.purple {
    background: var(--purple);
}

.progress-fill.blue {
    background: #00bcd4;
}

/* Section */
.section {
    margin-bottom: 2.5rem;
}

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

.link-more {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.data-table th {
    padding: 1rem 1.5rem;
    background: var(--sidebar-active);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    max-height: 90vh;
    overflow-y: auto;
    color: var(--text-main);
}

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

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background-color: var(--sidebar-active);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background-color: var(--card-bg);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 1rem;
    border: 2px dashed var(--border);
}

.empty-state i {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-muted);
}

/* Header Tags */
/* Dynamic Data Section */
#headers-group {
    background: var(--sidebar-active);
    padding: 1.25rem;
    border-radius: 1rem;
    border: 1px dashed var(--border);
    margin-bottom: 2rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.headers-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.header-tag {
    padding: 0.35rem 0.85rem;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.header-tag:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.header-tag:active {
    transform: scale(0.95);
}

/* Workflow Builder Visuals */
.workflow-canvas {
    padding: 3rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center nodes */
    gap: 0;
    overflow-x: auto;
    min-height: 250px;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    z-index: 2;
}

.btn-delete-node {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
    font-size: 14px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
}

.node-wrapper:hover .btn-delete-node {
    opacity: 1;
}

.btn-delete-node:hover {
    transform: scale(1.1);
    background: #b91c1c;
}

.node-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--card-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid var(--border);
    position: relative;
}

.node-circle:hover {
    transform: scale(1.1);
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.1);
}

.node-circle.active {
    border-color: var(--primary);
    background: var(--sidebar-active);
}

.node-icon {
    width: 40px;
    height: 40px;
}

.node-label {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Badges */
.badge {
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: capitalize;
}

.badge-success {
    background: #ecfdf5;
    color: #10b981;
    border: 1px solid #a7f3d0;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 9999;
}

.toast {
    min-width: 300px;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    animation: slideIn 0.3s ease-out forwards;
    transition: all 0.3s ease;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.fade-out {
    transform: translateX(100%);
    opacity: 0;
}

.node-sublabel {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.connector {
    flex-grow: 1;
    min-width: 80px;
    height: 4px;
    border-top: 5px dotted var(--border);
    margin-top: -30px;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
}

.connector::after {
    content: '🔧';
    position: absolute;
    top: 10px;
    font-size: 0.75rem;
    background: white;
    padding: 2px;
    border-radius: 4px;
    opacity: 0.6;
}

.add-module-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 1rem;
    transition: all 0.2s;
    border: none;
}

.add-module-btn:hover {
    transform: scale(1.1);
    background: var(--success-hover);
}

.pulse-node {
    animation: nodePulse 2s infinite;
}

@keyframes nodePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

/* Config Sidebar/Panel - now always visible in right panel */
.config-drawer {
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    display: block;
}

.config-drawer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    border: 2px dashed var(--border);
    border-radius: 1rem;
    background: var(--sidebar-active);
}

.app-selector-menu {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    margin-top: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.app-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: white;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.app-option:hover {
    border-color: var(--primary);
    background: var(--sidebar-active);
    transform: translateY(-2px);
}

.app-option i {
    width: 32px;
    height: 32px;
}

.app-option span {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* Floating App Selector Popup - Updated for Readability & Scrolling */
.app-selector-popup {
    position: fixed;
    z-index: 9999;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.1);
    min-width: 300px; /* Wider for better readability */
    max-width: 340px;
    padding: 0.75rem 0.25rem 0.75rem 0.75rem; /* Space for scrollbar */
    animation: popupFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popupFadeIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.app-selector-popup-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem 0.35rem;
}

#app-list-items {
    max-height: 400px; /* Limit height to trigger scrolling */
    overflow-y: auto;
    padding-right: 0.5rem; /* Space for scrollbar */
    margin-top: 0.25rem;
}

/* Custom Scrollbar for App List */
#app-list-items::-webkit-scrollbar {
    width: 5px;
}
#app-list-items::-webkit-scrollbar-track {
    background: transparent;
}
#app-list-items::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
#app-list-items::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.app-selector-popup-item {
    display: flex;
    align-items: center;
    gap: 1rem; /* Clear identifiable icon/text spacing */
    padding: 0.65rem 0.75rem; /* Increased hit area */
    border-radius: 0.625rem;
    cursor: pointer;
    font-size: 1rem; /* Highly legible app names */
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-selector-popup-item:hover {
    background: var(--sidebar-active);
    color: var(--primary);
    transform: translateX(2px);
}

.app-selector-popup-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.app-selector-popup-icon i {
    width: 18px;
    height: 18px;
}

.app-selector-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem 0.2rem;
    opacity: 0.7;
}

/* Settings View Styles */
.settings-layout {
    display: flex;
    gap: 2rem;
    background: var(--card-bg);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    overflow: hidden;
    min-height: 600px;
    margin-top: 1rem;
}

.settings-tabs {
    width: 240px;
    background: var(--sidebar);
    padding: 1.5rem;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.s-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.s-tab-btn:hover {
    background: var(--sidebar-active);
    color: var(--primary);
}

.s-tab-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.settings-content {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
}

.s-tab-content {
    display: none;
}

.s-tab-content h3 {
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.s-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* redundant form styles removed - using global defaults above */

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.connections-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.connection-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--card-bg);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 1rem;
}

.connection-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.conn-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.conn-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.conn-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.conn-card-actions {
    display: flex;
    gap: 0.5rem;
}

.conn-action-btn {
    padding: 0.4rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--sidebar);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conn-action-btn:hover {
    background: var(--sidebar-active);
    color: var(--primary);
    border-color: var(--primary);
}

.conn-action-btn.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.status-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-expired {
    background: #fee2e2;
    color: #991b1b;
}

.connection-card-OLD {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--card-bg);
}

.account-info {
    margin-top: 0.5rem;
}

.account-email {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

.permissions-group {
    margin-top: 1rem;
}

.permissions-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.permissions-list-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.p-tag {
    font-size: 0.7rem;
    background: var(--sidebar-active);
    color: var(--text-main);
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge-expired {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-disconnected {
    background: var(--sidebar-active);
    color: var(--text-muted);
}
/* Dashboard Footer Sections */
.dashboard-footer-sections {
    margin-top: 3rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.tips-card {
    background: var(--card-bg);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.tips-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: #fcfcfc;
}

.tips-tab {
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tips-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--purple);
}

.sparkle {
    margin-left: 0.25rem;
}

.tips-content {
    padding: 2rem;
}

.tips-content h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.checklist-item:last-child {
    border-bottom: none;
}

.check-circle-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checklist-item.done .check-circle-icon {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.checklist-item.done .check-circle-icon i {
    width: 12px;
    height: 12px;
}

.check-info {
    flex: 1;
}

.check-title {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.check-desc {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.btn-check-action {
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-check-action:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.promo-cards {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.promo-card {
    background: #fdf2f8; 
    border-radius: 1rem;
    padding: 2rem;
    border: 1px solid #fce7f3;
}

.promo-card.ai-agents {
    background: #f5f3ff;
    border-color: #ede9fe;
}

.promo-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.promo-body {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-top: 1rem;
}

.promo-main {
    flex: 1;
}

.promo-main h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.promo-main p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.promo-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge-workshop {
    background: #fed7aa;
    color: #9a3412;
    padding: 0.2rem 0.5rem;
    border-radius: 0.5rem;
    font-weight: 700;
}

.promo-video-thumb {
    position: relative;
    width: 200px;
    height: 125px;
    border-radius: 0.75rem;
    overflow: hidden;
    flex-shrink: 0;
}

.promo-video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-watch {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: white;
    border: none;
    padding: 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Floating Help Bubble */
.floating-help {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #2563eb;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
}

.floating-help:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px -5px rgba(37, 99, 235, 0.4);
    background: #1d4ed8;
}

/* Dark Mode Adjustments */
:root[data-theme="dark"] .tips-tabs {
    background: #1e293b;
}

:root[data-theme="dark"] .tips-tab.active {
    color: white;
}

:root[data-theme="dark"] .promo-card {
    background: #2d1b24; 
    border-color: #4b2c3a;
}

:root[data-theme="dark"] .promo-card.ai-agents {
    background: #1e1b4b; 
    border-color: #312e81;
}

:root[data-theme="dark"] .checklist-item {
    border-bottom-color: #334155;
}

:root[data-theme="dark"] .btn-watch {
    background: #1e293b;
    color: white;
}

:root[data-theme="dark"] .usage-bars-container {
    background: var(--card-bg);
}

:root[data-theme="dark"] .progress-bar-thin {
    background: #334155;
}

/* Automation Cards in Rules List */
.automation-card {
    background: var(--card-bg);
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.automation-card:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.automation-card .actions {
    display: flex;
    gap: 0.5rem;
}

.automation-card .btn-outline {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.automation-card .btn-outline i {
    width: 16px;
    height: 16px;
}

/* ===== Full-Page Workflow Builder Layout ===== */
#view-workflow {
    display: none;
    flex-direction: column;
    height: calc(100vh - 5rem);
}

#view-workflow.active {
    display: flex !important;
}

#view-workflow > .header {
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

#view-workflow .workflow-page-layout {
    display: grid !important;
    grid-template-columns: 1fr 380px !important;
    gap: 1.25rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#view-workflow .workflow-left-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
}

#view-workflow .workflow-left-panel .workflow-canvas {
    flex: 1;
    min-height: 300px;
    border-radius: 1.25rem;
}

#view-workflow .workflow-right-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#view-workflow .workflow-right-panel .config-drawer {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}



/* Node Actions Bar */
.node-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.node-actions-bar {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
    min-height: 22px;
    position: relative;
    z-index: 10;
}

.node-tag {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
}

.node-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* Slightly larger for easier clicking */
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
    pointer-events: auto !important; /* Ensure it responds to clicks */
}

.node-action-btn i {
    pointer-events: none; /* Let clicks pass through icons to the parent button */
}

.node-action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.node-action-btn.danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ============================================
   Node Status States (Test Run UI)
   ============================================ */

/* Running: animated blue pulse */
.node-circle.node-status-running {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6);
    animation: pulse-running 1s ease-in-out infinite;
}

/* Success: green glow */
.node-circle.node-status-success {
    border-color: #16a34a !important;
    box-shadow: 0 0 14px 4px rgba(22, 163, 74, 0.35);
    transition: border-color 0.4s, box-shadow 0.4s;
}

/* Error: red glow */
.node-circle.node-status-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 14px 4px rgba(220, 38, 38, 0.35);
    transition: border-color 0.4s, box-shadow 0.4s;
}

@keyframes pulse-running {
    0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); }
    50%  { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* Node status badge (small icon overlay) */
.node-status-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card-bg);
    font-size: 9px;
}

.node-badge-success {
    background: #16a34a;
    color: #fff;
}

.node-badge-error {
    background: #dc2626;
    color: #fff;
}

.node-badge-running {
    background: #3b82f6;
    color: #fff;
}

/* Connector flow colors */
.connector {
    transition: background 0.4s, box-shadow 0.4s;
}

.connector-success {
    background: linear-gradient(90deg, #16a34a, #4ade80) !important;
    box-shadow: 0 0 6px 1px rgba(22, 163, 74, 0.4);
}

.connector-error {
    background: linear-gradient(90deg, #dc2626, #f87171) !important;
    box-shadow: 0 0 6px 1px rgba(220, 38, 38, 0.4);
}

/* Automation card status dot */
.rule-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-active {
    background: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.25);
    animation: blink-dot 2s ease-in-out infinite;
}

.dot-paused {
    background: #94a3b8;
}

@keyframes blink-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Workflow Node Configuration Content Container */
#node-config-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Test button hover */
.btn-test:hover {
    background: #fef3c7 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25);
}