/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-success {
    color: var(--success) !important;
}

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #8b5cf6;

    /* Platform Colors */
    --maloum: #c026d3;
    --maloum-light: #e879f9;
    --maloum-bg: rgba(192, 38, 211, 0.2);
    --fourbased: #ef4444;
    --fourbased-light: #f87171;
    --fourbased-bg: rgba(239, 68, 68, 0.2);

    /* Light Theme (Default) */
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Dark Theme */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #0f172a;
        --bg-sidebar: #1e293b;
        --bg-card: #1e293b;
        --bg-card-hover: #334155;
        --bg-input: #0f172a;
        --text-primary: #f8fafc;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;
        --border: #334155;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.nav-menu {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    margin: 2px 8px;
}

.nav-section {
    margin-top: 1rem;
    padding: 0 0.75rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-section-header {
    padding: 1.25rem 1rem 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-section-header:first-child {
    border-top: none;
    padding-top: 0.5rem;
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-link.active[data-page="maloum-models"] {
    background: var(--maloum);
}

.nav-link.active[data-page="4based-models"] {
    background: var(--fourbased);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin: 1.5rem 1.5rem 0 1.5rem;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.control-group input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

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

/* Main Content */
.main-content {
    padding: 1.5rem;
    flex: 1;
}

.page-content {
    display: block;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

section.card {
    padding: 1.5rem;
}

section.card.chart-card {
    padding: 1.25rem;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    padding: 1.25rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Dashboard Grid for Stat Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.dashboard-grid:not(:first-child) {
    margin-top: 1rem;
}

.dashboard-grid:not(:last-child) {
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-content {
    display: flex;
    flex-direction: column;
}

.card-value-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 0;
    word-break: break-all;
}

.card-trend {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.card-trend.positive {
    color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

.card-trend.negative {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.card-trend.neutral {
    color: var(--text-secondary);
    background-color: rgba(100, 116, 139, 0.1);
}

.card-trend::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.card-trend.positive::before {
    border-bottom: 5px solid currentColor;
}

.card-trend.negative::before {
    border-top: 5px solid currentColor;
}

.card-trend.neutral::before {
    display: none;
}

.card-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Mobile Chart Navigation - Hidden on desktop */
.chart-nav-mobile {
    display: none;
}

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

.chart-card {
    padding: 1.25rem;
}

.chart-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 250px;
}

/* Heatmap */
.heatmap-section {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.heatmap-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: transform 0.15s;
    cursor: pointer;
    position: relative;
    background: var(--bg-card-hover);
}

.heatmap-cell:hover {
    transform: scale(1.15);
    z-index: 10;
}

.heatmap-cell.current {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.heatmap-cell .tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    margin-bottom: 4px;
}

.heatmap-cell:hover .tooltip {
    display: block;
}

/* Table Section */
.table-section {
    padding: 1.25rem;
}

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

.table-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.table-header input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    width: 200px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    color: var(--text-primary);
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background: var(--bg-card-hover);
}

th.sort-asc::after {
    content: ' \2191';
}

th.sort-desc::after {
    content: ' \2193';
}

td {
    font-size: 0.875rem;
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-card-hover);
}

/* Checkbox styling */
.checkbox-cell {
    text-align: center;
}

.checkbox-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Credential cells with copy button */
.credential-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.credential-cell span,
.credential-cell strong {
    flex: 1;
    word-break: break-all;
}

.password-field {
    font-family: monospace;
    font-size: 0.85rem;
}

.copy-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.copy-btn.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .header-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .date-shortcuts {
        order: 1;
        width: 100%;
    }

    .platform-filter {
        order: 2;
    }

    .control-group {
        order: 3;
    }
}

/* Hamburger Button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.hamburger-btn:hover {
    background: var(--bg-card-hover);
}

.hamburger-btn svg {
    width: 24px;
    height: 24px;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    /* Prevent horizontal scroll on the entire app */
    body {
        overflow-x: hidden;
    }

    .app-container {
        overflow-x: hidden;
    }

    /* Hamburger button visible on mobile */
    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-title {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Sidebar slides in from left */
    .sidebar {
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Show text in sidebar when open */
    .sidebar.open .sidebar-header h2,
    .sidebar.open .nav-link span:not(.nav-icon),
    .sidebar.open .nav-section-title {
        display: inline;
    }

    .sidebar.open .nav-link {
        justify-content: flex-start;
        padding: 0.625rem 0.75rem;
    }

    /* Main wrapper takes full width on mobile */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        padding: 0.75rem;
    }

    .header-title h1 {
        font-size: 1.1rem;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .platform-filter,
    .date-shortcuts {
        width: 100%;
        justify-content: center;
    }

    .platform-btn,
    .shortcut-btn {
        flex: 1;
        padding: 0.5rem 0.25rem;
        font-size: 0.7rem;
    }

    .control-group {
        flex: 1;
        min-width: 45%;
    }

    .control-group label {
        font-size: 0.75rem;
    }

    .control-group input {
        width: 100%;
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }

    #refreshBtn {
        width: 100%;
        margin-top: 0.25rem;
    }

    .main-content {
        padding: 0.75rem;
        overflow-x: hidden;
        max-width: 100%;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .summary-card {
        padding: 0.75rem;
    }

    .card-value {
        font-size: 1.25rem;
    }

    .card-label {
        font-size: 0.65rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        max-width: 100%;
        position: relative;
    }

    /* Mobile Chart Carousel */
    .chart-nav-mobile {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        padding: 0.5rem 0;
        margin-bottom: 0.5rem;
        grid-column: 1;
    }

    .chart-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-card);
        border: 1px solid var(--border);
        cursor: pointer;
        transition: all 0.15s;
        color: var(--text-primary);
    }

    .chart-nav-btn:hover {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
    }

    .chart-nav-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    .chart-nav-btn svg {
        width: 20px;
        height: 20px;
    }

    .chart-nav-dots {
        display: flex;
        gap: 0.5rem;
    }

    .chart-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: var(--border);
        cursor: pointer;
        transition: all 0.2s;
    }

    .chart-dot:hover {
        background: var(--text-muted);
    }

    .chart-dot.active {
        background: var(--primary);
        transform: scale(1.2);
    }

    /* Hide all charts except the active one on mobile */
    .charts-grid .chart-card {
        display: none;
    }

    .charts-grid .chart-card.active-chart {
        display: block;
    }

    .charts-grid-2 {
        grid-template-columns: 1fr;
    }

    .chart-card {
        padding: 0.75rem;
        max-width: 100%;
        overflow: hidden;
    }

    .chart-container {
        height: 200px;
        max-width: 100%;
    }

    /* Ensure cards don't overflow */
    .card {
        max-width: 100%;
        overflow: hidden;
    }

    .heatmap-section {
        padding: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .heatmap-container {
        grid-template-columns: repeat(24, 40px);
        gap: 6px;
        width: max-content;
        padding-bottom: 4px;
    }

    .heatmap-cell {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 0.7rem;
    }

    .table-section {
        padding: 0.75rem;
        overflow: hidden;
    }

    /* Ensure table container scrolls horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        position: relative;
    }

    /* Scroll hint gradient */
    .table-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 30px;
        height: 100%;
        background: linear-gradient(to right, transparent, var(--bg-card));
        pointer-events: none;
        opacity: 0.8;
    }

    .table-container.scrolled-right::after {
        opacity: 0;
    }

    .table-container table {
        min-width: 600px;
    }

    /* Different min-widths for tables with more columns */
    #dashboardMaloumModelTable,
    #dashboard4basedModelTable {
        min-width: 800px;
    }

    #setupTable {
        min-width: 700px;
    }

    #maloumSettingsTable,
    #4basedSettingsTable {
        min-width: 650px;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
    }

    .table-header h3 {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .table-header input {
        width: 100%;
    }

    .table-header-actions {
        flex-direction: column;
    }

    .table-header-actions input {
        width: 100%;
    }

    .table-header-actions button {
        width: 100%;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.5rem 0.375rem;
    }

    th {
        font-size: 0.65rem;
    }

    .credential-cell {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .copy-btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.65rem;
    }

    /* Modal responsive */
    .modal-container {
        max-height: 95vh;
        margin: 0.5rem;
    }

    .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }

    .json-editor-tabs {
        gap: 0.25rem;
    }

    .tab-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }

    .json-textarea,
    .text-textarea {
        min-height: 250px;
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    .platform-tabs {
        flex-wrap: wrap;
    }

    .platform-tab {
        flex: 1;
        text-align: center;
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Responsive - Small phones */
@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }

    .card-value {
        font-size: 1.1rem;
    }

    th, td {
        padding: 0.375rem 0.25rem;
        font-size: 0.7rem;
    }

    th {
        font-size: 0.6rem;
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    background: var(--bg-card);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

/* JSON Editor Tabs */
.json-editor-tabs {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.tab-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

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

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

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

.tab-content label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.json-textarea,
.text-textarea {
    width: 100%;
    min-height: 400px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.15s;
}

.json-textarea:focus,
.text-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.json-textarea.error {
    border-color: var(--danger);
}

.json-textarea.valid {
    border-color: var(--success);
}

.json-status {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.5rem;
    min-height: 1rem;
}

.json-status.error {
    color: var(--danger);
}

.json-status.valid {
    color: var(--success);
}

/* Script Editor */
.script-editor-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.ai-edit-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.ai-edit-section label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.ai-edit-section textarea {
    resize: vertical;
    min-height: 80px;
}

.ai-edit-section button {
    align-self: flex-start;
}

.json-editor-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.json-editor-section label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.toast.error {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Clickable model row */
.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: var(--bg-card-hover);
}

.clickable-row td:first-child {
    position: relative;
}

.clickable-row td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.15s;
}

.clickable-row:hover td:first-child::before {
    background: var(--primary);
}

/* Maloum model dropdown */
.maloum-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 120px;
    max-width: 180px;
}

.maloum-select:focus {
    outline: none;
    border-color: var(--primary);
}

.maloum-select:hover {
    border-color: var(--primary);
}

/* Proxy input field */
.proxy-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-family: monospace;
    min-width: 140px;
    max-width: 200px;
    width: 100%;
}

.proxy-input:focus {
    outline: none;
    border-color: var(--primary);
}

.proxy-input:hover {
    border-color: var(--primary);
}

.proxy-input::placeholder {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Style page dropdown */
.style-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 140px;
    max-width: 200px;
}

.style-select:focus {
    outline: none;
    border-color: var(--primary);
}

.style-select:hover {
    border-color: var(--primary);
}

/* Date shortcuts */
.date-shortcuts {
    display: flex;
    gap: 0.25rem;
}

.shortcut-btn {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.shortcut-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

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

/* Trend indicators */
.trend-up {
    color: #10b981;
    font-weight: 600;
    font-size: 0.85rem;
}

.trend-down {
    color: #ef4444;
    font-weight: 600;
    font-size: 0.85rem;
}

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

/* Style row colors */
.style-reif { background-color: rgba(157, 23, 77, 0.15) !important; }
.style-obsessiv { background-color: rgba(219, 39, 119, 0.15) !important; }
.style-sarkastisch { background-color: rgba(100, 116, 139, 0.15) !important; }
.style-flirty { background-color: rgba(168, 85, 247, 0.15) !important; }
.style-dominant { background-color: rgba(239, 68, 68, 0.15) !important; }
.style-romantic { background-color: rgba(236, 72, 153, 0.15) !important; }
.style-perfect { background-color: rgba(59, 130, 246, 0.15) !important; }
.style-wild { background-color: rgba(245, 158, 11, 0.15) !important; }
.style-sweet { background-color: rgba(251, 146, 60, 0.15) !important; }
.style-shy { background-color: rgba(16, 185, 129, 0.15) !important; }

.style-reif td,
.style-obsessiv td,
.style-sarkastisch td,
.style-flirty td,
.style-dominant td,
.style-romantic td,
.style-perfect td,
.style-wild td,
.style-sweet td,
.style-shy td {
    background: transparent !important;
}

/* Platform Filter */
.platform-filter {
    display: flex;
    gap: 0.25rem;
}

.platform-btn {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.platform-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

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

.platform-btn.active[data-platform="maloum"] {
    background: var(--maloum);
    border-color: var(--maloum);
}

.platform-btn.active[data-platform="4based"] {
    background: var(--fourbased);
    border-color: var(--fourbased);
}

/* Status Indicators */
.status-cell {
    text-align: center;
    width: 50px;
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-green {
    background-color: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.status-green.status-stale {
    animation: none;
    opacity: 0.7;
}

.status-blue {
    background-color: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
    animation: none;
}

.status-red {
    background-color: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    animation: pulse 1.5s infinite;
}

.status-loading {
    background-color: transparent;
    border: 2px solid #e5e7eb;
    border-top-color: #6b7280;
    animation: spin 0.8s linear infinite;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Modal Small */
.modal-small {
    max-width: 480px;
}

/* Form Groups for Modal */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.625rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Button Spinner */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.btn-spinner.hidden {
    display: none;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Table Header Actions */
.table-header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.table-header-actions input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    width: 200px;
}

/* Dashboard Model Tables Margin */
#dashboardMaloumTable,
#dashboard4basedTable {
    margin-top: 1.5rem;
}

/* Platform-specific table header accents */
#dashboardMaloumTable .table-header h3::before,
#page-maloum-models .table-header h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--maloum);
    margin-right: 0.5rem;
    border-radius: 2px;
    vertical-align: middle;
}

#dashboard4basedTable .table-header h3::before,
#page-4based-models .table-header h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--fourbased);
    margin-right: 0.5rem;
    border-radius: 2px;
    vertical-align: middle;
}

/* Platform Tabs for Modal */
.platform-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.platform-tab {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.platform-tab:hover {
    background: var(--border);
    color: var(--text-primary);
}

.platform-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.platform-tab.active[data-platform="maloum"] {
    background: var(--maloum);
    border-color: var(--maloum);
}

.platform-tab.active[data-platform="4based"] {
    background: var(--fourbased);
    border-color: var(--fourbased);
}

.platform-content {
    display: none;
}

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

/* Modal Wide */
.modal-wide {
    max-width: 1100px;
}

/* Styles Editor Page */
.styles-section {
    padding: 1.25rem;
    min-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.styles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.styles-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.styles-category-tabs {
    display: flex;
    gap: 0.25rem;
}

.category-tab {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.category-tab:hover {
    background: var(--border);
    color: var(--text-primary);
}

.category-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.styles-content {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 400px;
}

.styles-list {
    background: var(--bg-body);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    overflow-y: auto;
    max-height: 500px;
}

.style-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.style-item:hover {
    background: var(--bg-card-hover);
}

.style-item.active {
    background: var(--primary);
    color: white;
}

.style-item-name {
    font-weight: 500;
    font-size: 0.875rem;
    flex: 1;
}

.style-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.style-item:hover .style-item-delete {
    opacity: 1;
}

.style-item.active .style-item-delete {
    color: white;
}

.usage-badges {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.usage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.125rem 0.4rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 1.25rem;
    line-height: 1;
}

.usage-badge.usage-maloum {
    background: #3b82f6;
    color: white;
}

.usage-badge.usage-4based {
    background: #ef4444;
    color: white;
}

.usage-badge.usage-total {
    background: #a855f7;
    color: white;
}

.style-item.active .usage-badge {
    opacity: 0.9;
}

.styles-editor {
    background: var(--bg-body);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
    max-height: 500px;
}

.editor-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
}

.editor-field {
    margin-bottom: 1rem;
}

.editor-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* n8n Status Badges */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

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

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

.status-badge.running, .status-badge.waiting {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* Workflow Table */
.workflow-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.workflow-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
    display: inline-block;
}

.workflow-link:hover {
    text-decoration: underline;
}

/* Modal sizing */
.modal-sm {
    max-width: 400px;
}

/* JSON view in modal */
#executionDataView {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 0.5rem;
    width: 100%;
}

.editor-field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
}

.editor-field textarea {
    min-height: 100px;
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.editor-field input:focus,
.editor-field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.styles-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Add Style Modal */
.add-style-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.add-style-modal.active {
    display: flex;
}

/* Responsive Styles Editor */
@media (max-width: 768px) {
    .styles-content {
        grid-template-columns: 1fr;
    }

    .styles-list {
        max-height: 200px;
    }

    .styles-category-tabs {
        flex-wrap: wrap;
        width: 100%;
    }

    .category-tab {
        flex: 1;
        text-align: center;
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ===== Skeleton Loading Animations ===== */

/* Skeleton text placeholder */
.skeleton-text {
    display: inline-block;
    width: 60%;
    height: 1.2em;
    background: linear-gradient(
        90deg,
        var(--bg-card-hover) 25%,
        var(--border) 50%,
        var(--bg-card-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

/* Skeleton row for tables */
.skeleton-row td {
    padding: 0.75rem 1rem;
}

.skeleton-row .skeleton-text {
    width: 80%;
    height: 1rem;
}

/* Skeleton cell for heatmap */
.skeleton-cell {
    background: linear-gradient(
        90deg,
        var(--bg-card-hover) 25%,
        var(--border) 50%,
        var(--bg-card-hover) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

/* Shimmer animation */
@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Chart card loading state */
.chart-card.is-loading {
    position: relative;
}

.chart-card.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chart-card.is-loading .chart-container {
    opacity: 0.3;
    pointer-events: none;
}

/* Table section loading state */
.table-section.is-loading {
    position: relative;
}

.table-section.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10;
}

.table-section.is-loading .table-container {
    opacity: 0.3;
    pointer-events: none;
}

/* Styles list loading */
.styles-loading {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}

.styles-error {
    color: var(--danger);
    text-align: center;
    padding: 2rem 1rem;
}

/* Summary card loading state */
.summary-card .card-value .skeleton-text {
    width: 70%;
    height: 1.5rem;
}

/* Generic loading element */
.is-loading {
    position: relative;
    pointer-events: none;
}

/* Fade in animation for loaded content */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loaded {
    animation: fadeIn 0.3s ease-in-out;
}

/* ===== CUSTOMER ANALYSIS PAGE ===== */

.charts-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

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

.platform-select,
.model-select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.platform-select:focus,
.model-select:focus {
    outline: none;
    border-color: var(--primary);
}

.revenue-cell {
    font-weight: 600;
    color: var(--success);
}

/* ===== FUNNEL ANALYSIS PAGE ===== */

.funnel-section {
    padding: 1.25rem;
}

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

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.funnel-controls {
    display: flex;
    gap: 0.5rem;
}

.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
    min-height: 500px;
}

.funnel-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Funnel Layout - Clean Minimalist Design */
.funnel-visual {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.funnel-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0.375rem;
}

.funnel-row:hover {
    background: var(--bg-card-hover);
}

.funnel-bar-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
}

.funnel-bar {
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--success));
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    transition: width 0.3s ease, transform 0.15s;
    position: relative;
}

.funnel-row:hover .funnel-bar {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.funnel-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    border-radius: 4px;
}

.funnel-label {
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    white-space: nowrap;
    padding: 0 0.75rem;
}

.funnel-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 140px;
    justify-content: flex-end;
}

.funnel-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 50px;
    text-align: right;
}

.funnel-percent {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 45px;
}

.funnel-dropoff {
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 600;
    min-width: 40px;
}

/* Funnel Summary Compact */
.funnel-summary-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.25rem;
    margin-top: 1.5rem;
    background: var(--bg-card-hover);
    border-radius: 0.5rem;
}

.funnel-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.funnel-summary-item .summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.funnel-summary-item .summary-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.funnel-summary-item.highlight .summary-value {
    color: var(--success);
}

.funnel-summary-divider {
    font-size: 1.25rem;
    color: var(--text-muted);
}

/* Legacy funnel styles - keep for compatibility */
.funnel-stages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
}

.funnel-stage {
    width: 100%;
    display: flex;
    justify-content: center;
}

.funnel-stage.clickable {
    cursor: pointer;
}

.funnel-stage-dropoff-neutral {
    color: var(--text-muted);
}

/* Funnel Stage Modal Tabs */
.funnel-stage-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.funnel-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.funnel-tab:hover {
    background: var(--border);
    color: var(--text-primary);
}

.funnel-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.funnel-tab-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.funnel-tab-icon.passed {
    background: var(--success);
}

.funnel-tab-icon.failed {
    background: var(--danger);
}

.funnel-tab.active .funnel-tab-icon {
    background: white;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-indicator.status-passed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-indicator.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Ready status column */
.ready-status {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
}

.ready-status.ready-yes {
    color: var(--success);
}

.ready-status.ready-no {
    color: var(--danger);
    opacity: 0.6;
}

/* Failed chat row styling */
.chat-row-failed {
    opacity: 0.7;
}

.chat-row-failed:hover {
    opacity: 1;
}

/* Funnel Summary Stats */
.funnel-summary {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
    background: var(--bg-card-hover);
    border-radius: 0.5rem;
    flex-wrap: wrap;
}

.funnel-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
}

.funnel-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.funnel-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.funnel-stat-highlight {
    background: var(--bg-card);
    border-radius: 0.5rem;
    border: 2px solid var(--success);
}

.funnel-stat-highlight .funnel-stat-value {
    color: var(--success);
}

/* Responsive funnel */
@media (max-width: 600px) {
    .funnel-visual {
        max-width: 100%;
    }

    .funnel-row {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 0.5rem;
    }

    .funnel-bar-wrapper {
        width: 100%;
    }

    .funnel-bar {
        height: 36px;
    }

    .funnel-label {
        font-size: 0.75rem;
    }

    .funnel-stats {
        width: 100%;
        justify-content: center;
        min-width: auto;
    }

    .funnel-summary-compact {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .funnel-summary-item .summary-value {
        font-size: 1.25rem;
    }

    .funnel-summary-divider {
        display: none;
    }

    /* Legacy styles */
    .funnel-container {
        min-height: 400px;
    }

    .funnel-summary {
        gap: 1rem;
        padding: 1rem;
    }

    .funnel-stat {
        padding: 0.5rem 1rem;
    }

    .funnel-stat-value {
        font-size: 1.25rem;
    }
}

/* ===== MODEL CHATS MODAL ===== */

/* Clickable rows in dashboard model table */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background-color: var(--bg-card-hover);
}

/* Converted chat row (green) */
.chat-row-converted {
    background-color: rgba(16, 185, 129, 0.15);
}

.chat-row-converted:hover {
    background-color: rgba(16, 185, 129, 0.25);
}

/* Sale indicator */
.chat-row-converted td:last-child {
    color: var(--success);
    font-weight: 600;
}

/* Timewaster row */
.chat-row-timewaster {
    background-color: rgba(239, 68, 68, 0.15);
}

.chat-row-timewaster:hover {
    background-color: rgba(239, 68, 68, 0.25);
}

/* Chat ID cell with copy button */
.chat-id-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-id-text {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
    opacity: 0.6;
}

.copy-btn:hover {
    opacity: 1;
    background: var(--bg-card-hover);
    color: var(--primary);
    border-color: var(--primary);
}

.lookup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
    opacity: 0.6;
    margin-left: 0.25rem;
}

.lookup-btn:hover {
    opacity: 1;
    background: var(--bg-card-hover);
    color: var(--success);
    border-color: var(--success);
}

/* Log badge */
.log-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: var(--text-secondary);
}

/* Platform badge */
.platform-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 0.25rem;
}

.platform-badge.maloum {
    background: var(--maloum-bg);
    color: var(--maloum-light);
}

.platform-badge.4based {
    background: var(--fourbased-bg);
    color: var(--fourbased-light);
}

/* Clickable heatmap cell */
.heatmap-cell.clickable:hover {
    box-shadow: 0 0 0 2px var(--primary);
}

.heatmap-cell .tooltip small {
    display: block;
    margin-top: 0.25rem;
    color: var(--primary);
    font-style: italic;
}

/* Modal summary in footer */
.modal-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-right: auto;
}

/* Loading/empty/error cells */
.loading-cell,
.empty-cell,
.error-cell {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.error-cell {
    color: var(--danger);
}

/* Make modal table scrollable */
#modelChatsModal .table-container {
    max-height: 400px;
    overflow-y: auto;
}

#modelChatsModal table {
    width: 100%;
}

#modelChatsModal th,
#modelChatsModal td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#modelChatsModal thead {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

/* Card Headers with Actions */
.card > h3:first-child {
    padding: 1.25rem 1.5rem;
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header-with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header-with-action h3 {
    padding: 0;
    margin: 0;
    border: none;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Icon Buttons */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 0.375rem;
    transition: all 0.15s;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon:hover {
    transform: translateY(-1px);
}

/* Quit Reasons Section */
.quit-reasons-section {
    margin-bottom: 1.5rem;
}

.quit-reasons-chart-container {
    height: 400px;
    max-width: 100%;
    padding: 1rem 1.5rem 1.5rem;
}

/* Quit Reasons Editor Modal */
.modal-medium {
    max-width: 600px;
}

.modal-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    padding: 0.875rem 1rem;
    background: var(--bg-card-hover);
    border-radius: 0.5rem;
    border-left: 3px solid var(--primary);
}

.quit-reasons-editor-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quit-reason-editor-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.15s;
}

.quit-reason-editor-item:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.quit-reason-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 0.375rem 0.625rem;
    background: var(--primary);
    color: white;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.quit-reason-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.quit-reason-input:focus {
    outline: none;
    border-color: var(--primary);
}

.quit-reason-original {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Spinner for buttons */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-spinner.hidden {
    display: none;
}

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


/* Funnel Chart Styles */
.funnel-container {
    height: 400px;
    padding: 1.5rem;
}

.funnel-summary {
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.funnel-summary-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.funnel-stat {
    text-align: center;
    color: white;
}

.funnel-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.funnel-stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.funnel-stat-arrow {
    font-size: 2rem;
    color: white;
    opacity: 0.7;
}

.funnel-stat.highlight .funnel-stat-value {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .funnel-summary-content {
        flex-direction: column;
        gap: 1.5rem;
    }

    .funnel-stat-arrow {
        transform: rotate(90deg);
    }
}

/* ===== SCRIPT CREATOR PAGE ===== */

.script-creator-section {
    padding: 2rem;
}

.script-creator-steps {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step-number {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
}

.step-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.step.active .step-label {
    color: var(--text-primary);
}

/* Step Content */
.step-content {
    display: none;
}

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

.step-content h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Folders Grid */
.folders-container {
    margin-top: 2rem;
}

.folders-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.folder-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.folder-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.folder-card.selected {
    background: rgba(var(--primary-rgb), 0.2);
    border-color: var(--primary);
}

.folder-card.used {
    opacity: 0.5;
    filter: grayscale(0.7);
}

.folder-card.used:hover {
    opacity: 0.6;
}

.folder-thumbnail {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    filter: blur(3px);
}

.folder-thumbnail-placeholder {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.folder-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.folder-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-counts {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.folder-select-indicator {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.folder-card.selected .folder-select-indicator {
    opacity: 1;
}

/* Folder Scraped Status Icon */
.folder-scraped-status {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    z-index: 2;
}

.folder-scraped-status.scraped-yes {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.folder-scraped-status.scraped-no {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

/* Folder Analyse Button */
.folder-analyse-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    z-index: 2;
}

.folder-analyse-btn:hover {
    background: rgba(37, 99, 235, 1);
    transform: scale(1.1);
}

.folder-analyse-btn:active {
    transform: scale(0.95);
}

/* Selected Folders */
.selected-folders-container {
    margin-top: 2rem;
}

.selected-folders-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.selected-folders-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.selected-folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(var(--primary-rgb), 0.2);
    border: 1px solid var(--primary);
    border-radius: 2rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.remove-folder-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

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

.theme-input-group {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Script Response */
.script-response-container {
    margin-top: 2rem;
}

.script-response-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.script-response {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    max-height: 500px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .step-indicator {
        gap: 1rem;
        padding: 1rem;
    }

    .step-number {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }

    .step-label {
        font-size: 0.75rem;
    }

    .folders-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .theme-input-group {
        grid-template-columns: 1fr;
    }
}

/* Progress Bar */
.script-progress-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
}

.script-progress-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.progress-bar-container {
    width: 100%;
    height: 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.progress-bar-striped {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
}

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

.progress-text {
    text-align: center;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.progress-details {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Packets Editor */
.packets-editor-container {
    margin-top: 1.5rem;
}

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

.packet-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.packet-card:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.packet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}

.packet-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.packet-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.875rem;
}

.packet-name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    max-width: 400px;
}

.packet-name-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.15);
}

.packet-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.packet-media-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.packet-body {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.packet-description {
    margin-bottom: 1.5rem;
}

.packet-description label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.packet-description-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.packet-description-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.packet-media-section label {
    display: block;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.packet-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.packet-media-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    overflow: hidden;
}

.packet-media-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.packet-media-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.packet-media-info {
    padding: 0.75rem;
}

.packet-media-type {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.packet-media-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
    line-height: 1.4;
}

.packet-media-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.step-description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .packet-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .packet-title {
        width: 100%;
    }

    .packet-name-input {
        max-width: 100%;
    }

    .packet-media-grid {
        grid-template-columns: 1fr;
    }

    .step-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .step-actions button {
        width: 100%;
    }
}

/* Option Groups */
.option-group {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    overflow: hidden;
}

.option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: rgba(var(--primary-rgb), 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.option-header h4 {
    margin: 0;
    color: var(--primary);
    font-size: 1.25rem;
}

.option-package-count {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.option-packages {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Package Cards */
.package-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.package-card:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
}

.package-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.package-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.75rem;
}

.package-code-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    flex: 1;
    max-width: 400px;
}

.package-code-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.15);
}

.package-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.package-media-count {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.package-body {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.package-description {
    margin-bottom: 1rem;
}

.package-description label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.package-description-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
    padding: 0.625rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
}

.package-description-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.package-uploads {
    margin-top: 1rem;
}

.package-uploads label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.upload-ids-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.upload-id-chip {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--accent);
}

/* Responsive for Options */
@media (max-width: 768px) {
    .option-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .package-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .package-title {
        width: 100%;
    }

    .package-code-input {
        max-width: 100%;
    }
}

/* Accordion Design for Packet Options */
.packet-options-accordion-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 2rem;
}

/* Accordion Category Container */
.accordion-category {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: var(--bg-card);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.accordion-category.selected {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

/* Accordion Header */
.accordion-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #fafafa;
    transition: background 0.2s ease;
}

.accordion-category.selected .accordion-header {
    background: #f0f7ff;
}

.accordion-header:hover {
    background: #f0f0f0;
}

.accordion-category.selected .accordion-header:hover {
    background: #e8f2ff;
}

/* Checkbox Square */
.checkbox-square {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.checkbox-square:hover {
    border-color: #999;
}

.accordion-category.selected .checkbox-square {
    background: #007bff;
    border-color: #007bff;
}

/* Checkmark SVG */
.checkmark {
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.checkmark.visible {
    opacity: 1;
}

/* Accordion Title Wrapper */
.accordion-title-wrapper {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.accordion-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.accordion-arrow {
    font-size: 14px;
    color: #666;
    transition: transform 0.2s ease;
}

.accordion-category.open .accordion-arrow {
    transform: rotate(180deg);
}

/* Accordion Content */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-top: 1px solid #f0f0f0;
}

.accordion-category.open .accordion-content {
    max-height: 2000px;
}

.accordion-packet-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Packet Item */
.accordion-packet-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.packet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.packet-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.packet-media-count {
    font-size: 13px;
    font-weight: 400;
    color: #666;
}

.packet-description {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}

.packet-description:focus {
    outline: 2px solid #007bff;
    outline-offset: 0;
    border-color: #007bff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .accordion-header {
        padding: 15px;
    }

    .accordion-title {
        font-size: 16px;
    }

    .packet-name {
        font-size: 13px;
    }

    .packet-media-count {
        font-size: 12px;
    }

    .accordion-packet-list {
        padding: 15px;
    }
}

/* Dark Mode Support for Accordion */
@media (prefers-color-scheme: dark) {
    .accordion-category {
        border-color: rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.05);
    }

    .accordion-category.selected {
        border-color: #4a9eff;
        box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
    }

    .accordion-header {
        background: rgba(255, 255, 255, 0.08);
    }

    .accordion-category.selected .accordion-header {
        background: rgba(74, 158, 255, 0.15);
    }

    .accordion-header:hover {
        background: rgba(255, 255, 255, 0.12);
    }

    .accordion-category.selected .accordion-header:hover {
        background: rgba(74, 158, 255, 0.2);
    }

    .checkbox-square {
        border-color: rgba(255, 255, 255, 0.3);
    }

    .checkbox-square:hover {
        border-color: rgba(255, 255, 255, 0.5);
    }

    .accordion-category.selected .checkbox-square {
        background: #4a9eff;
        border-color: #4a9eff;
    }

    .accordion-title {
        color: var(--text-primary);
    }

    .accordion-arrow {
        color: var(--text-muted);
    }

    .accordion-content {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .accordion-packet-item {
        background: rgba(255, 255, 255, 0.05);
    }

    .packet-name {
        color: var(--text-primary);
    }

    .packet-media-count {
        color: var(--text-muted);
    }

    .packet-description {
        background: rgba(0, 0, 0, 0.3);
        border-color: rgba(255, 255, 255, 0.2);
        color: var(--text-primary);
    }

    .packet-description:focus {
        outline-color: #4a9eff;
        border-color: #4a9eff;
    }
}

.packet-description-compact:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.3);
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

/* ===== WHALE SCRIPTS PAGE ===== */

.whale-scripts-container {
    padding: 1rem;
}

.whale-script-model {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.whale-script-model:hover {
    box-shadow: var(--shadow-lg);
}

.whale-script-header {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    user-select: none;
}

.whale-script-header:hover {
    background: var(--bg-card-hover);
}

.whale-script-header.expanded {
    border-bottom: 1px solid var(--border);
}

.whale-script-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.whale-script-model-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.whale-script-counters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.script-counter {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-card-hover);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.script-counter:hover {
    transform: translateY(-2px);
}

.dropdown-arrow {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.whale-script-header.expanded .dropdown-arrow {
    transform: rotate(180deg);
}

.whale-script-list {
    padding: 0.5rem;
}

.whale-script-list.hidden {
    display: none;
}

.whale-script-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-card);
}

.whale-script-item:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.script-emoji {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.script-name {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.script-type-badge {
    padding: 0.25rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .whale-script-counters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .script-counter {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    .whale-script-model-name {
        font-size: 1rem;
    }
}


/* ===== Execution Finder Full Screen ===== */
.execution-finder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-body);
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.execution-finder-overlay.hidden {
    display: none;
}

.execution-finder-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.execution-finder-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.execution-finder-header h2 {
    margin: 0;
    font-size: 1.5rem;
    white-space: nowrap;
}

.execution-finder-search {
    display: flex;
    gap: 1rem;
    flex: 1;
    max-width: 600px;
}

.execution-finder-search input {
    flex: 1;
}

.execution-finder-header .modal-close {
    margin-left: auto;
}

.execution-finder-body {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

/* Left Panel: Executions List */
.execution-list-panel {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.execution-list {
    display: flex;
    flex-direction: column;
}

.execution-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.execution-item:hover {
    background: var(--bg-card-hover);
}

.execution-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid var(--primary);
}

.execution-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.execution-item-time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.execution-item-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.execution-item-workflow {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.execution-item-workflow-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.execution-item-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.execution-item-link:hover {
    text-decoration: underline;
}

.execution-item-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
}

.no-results {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* Right Panel: Details */
.execution-details-panel {
    background: var(--bg-body);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.details-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 1rem;
}

.details-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.details-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

.details-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.details-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.chat-detail-section {
    margin-bottom: 2rem;
}

.chat-detail-section:last-child {
    margin-bottom: 0;
}

.chat-detail-section h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.chat-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.chat-info-item {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.chat-info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.chat-info-value {
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
}

.chat-info-value.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.logs-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-entry {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.log-entry:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.log-entry-name {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.log-entry-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.log-entry-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.log-entry-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.log-entry-detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.log-entry-detail-value {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.log-entry-detail-value.highlight {
    color: var(--success);
    font-weight: 600;
}

.json-raw {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Status badges */
.execution-item-status.success {
    background: rgba(34, 197, 94, 0.2);
    color: rgb(34, 197, 94);
}

.execution-item-status.error,
.execution-item-status.crashed {
    background: rgba(239, 68, 68, 0.2);
    color: rgb(239, 68, 68);
}

.execution-item-status.running {
    background: rgba(59, 130, 246, 0.2);
    color: rgb(59, 130, 246);
}

.execution-item-status.waiting {
    background: rgba(251, 191, 36, 0.2);
    color: rgb(251, 191, 36);
}

/* Loading state */
.execution-list-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    .execution-finder-body {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 768px) {
    .execution-finder-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .execution-finder-search {
        max-width: 100%;
    }

    .execution-finder-body {
        grid-template-columns: 1fr;
    }

    .execution-details-panel {
        display: none;
    }

    .execution-finder-body.show-details .execution-list-panel {
        display: none;
    }

    .execution-finder-body.show-details .execution-details-panel {
        display: flex;
    }
}

/* Chat Details Editing Styles */
.section-header-with-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.section-header-with-actions h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-header-with-actions .btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Chat Type Card */
.chat-type-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.chat-type-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.chat-type-value {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.chat-type-value.editing {
    background: var(--bg-body);
    border-color: var(--primary);
}

/* Logs Timeline */
.logs-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.log-entry {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s ease;
}

.log-entry:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.log-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.log-entry-name {
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--primary);
}

.log-entry-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.log-entry-actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.log-entry-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-entry-field {
    display: flex;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.log-entry-field strong {
    min-width: 80px;
    color: var(--text-muted);
    font-weight: 500;
}

.log-entry-field span {
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    word-break: break-all;
}

/* JSON Editor */
.json-editor {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s ease;
}

.json-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.json-editor.invalid {
    border-color: var(--danger);
}

/* Button Variants */
.btn-danger {
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

/* Modal Size Variant */
.modal-medium {
    max-width: 800px;
}

.modal-medium .modal-content {
    max-height: 80vh;
    overflow-y: auto;
}

/* Edit Log Modal */
.edit-log-modal .modal-body {
    padding: 1.5rem;
}

.edit-log-modal textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    resize: vertical;
}

.edit-log-modal textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* JSON Validation Error */
.json-error {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

/* ===== N8N SEARCH INPUT ===== */

.n8n-search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 250px;
    transition: all 0.2s ease;
}

.n8n-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

@media (max-width: 768px) {
    .n8n-search-input {
        width: 180px;
    }
}

/* ===== WORKFLOW CARDS GRID ===== */

.workflows-cards-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive: 4 columns on tablets, 3 on small tablets, 2 on mobile */
@media (max-width: 1600px) {
    .workflows-cards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .workflows-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .workflows-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .workflows-cards-grid {
        grid-template-columns: 1fr;
    }
}

.workflow-card {
    position: relative;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s ease;
    cursor: default;
}

.workflow-card.pinned {
    border-color: var(--warning);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, var(--bg-card) 50%);
}

.workflow-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

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

.workflow-card-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex: 1;
}

.workflow-card-emoji {
    font-size: 1.75rem;
    line-height: 1;
}

.workflow-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

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

.workflow-card-pin-btn,
.workflow-card-edit-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.workflow-card-pin-btn:hover,
.workflow-card-edit-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.workflow-card-pin-btn.pinned {
    color: var(--warning);
}

.workflow-card-platforms {
    display: flex;
    gap: 0.5rem;
}

.workflow-platform-link {
    flex: 1;
    padding: 0.625rem 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.workflow-platform-link.maloum {
    background: var(--maloum-bg);
    color: var(--maloum);
    border-color: var(--maloum);
}

.workflow-platform-link.maloum:hover {
    background: var(--maloum);
    color: white;
}

.workflow-platform-link.fourbased {
    background: var(--fourbased-bg);
    color: var(--fourbased);
    border-color: var(--fourbased);
}

.workflow-platform-link.fourbased:hover {
    background: var(--fourbased);
    color: white;
}

.workflow-platform-link.f2f {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    border-color: var(--primary);
}

.workflow-platform-link.f2f:hover {
    background: var(--primary);
    color: white;
}

.workflow-platform-link.disabled {
    background: var(--bg-card-hover);
    color: var(--text-muted);
    border-color: var(--border);
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== SINGLE TAG WORKFLOWS SECTION ===== */

.single-tag-workflows-section {
    margin-top: 2rem;
    border-top: 2px solid var(--border);
    padding-top: 1.5rem;
}

.single-tag-toggle {
    width: 100%;
    padding: 1rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

.single-tag-toggle:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.single-tag-toggle .chevron-icon {
    transition: transform 0.3s ease;
}

.single-tag-toggle.open .chevron-icon {
    transform: rotate(180deg);
}

.single-tag-content {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.single-tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.single-tag-workflow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.single-tag-workflow:hover {
    border-color: var(--primary);
}

.single-tag-workflow-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.single-tag-workflow-name {
    font-weight: 500;
    color: var(--text-primary);
}

.single-tag-workflow-platform {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.single-tag-workflow-platform.maloum {
    background: var(--maloum-bg);
    color: var(--maloum);
}

.single-tag-workflow-platform.fourbased {
    background: var(--fourbased-bg);
    color: var(--fourbased);
}

.single-tag-workflow-platform.f2f {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
}

.single-tag-workflow-link {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.single-tag-workflow-link:hover {
    background: var(--primary-hover);
}

/* ===== EMOJI PICKER ===== */

.emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.emoji-btn {
    width: 100%;
    aspect-ratio: 1;
    padding: 0.5rem;
    background: var(--bg-card-hover);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.emoji-btn.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.emoji-preview {
    padding: 1rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 2rem;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .workflow-card.pinned {
        background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, var(--bg-card) 50%);
    }
}

/* ============================================
   Authentication Styles
   ============================================ */

/* Login Container */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-box {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    animation: fadeInUp 0.3s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.login-header p {
    color: var(--text-secondary);
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.login-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.error-message {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: #ef4444;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn-login {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

/* Sidebar Footer (User Info & Logout) */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout svg {
    width: 18px;
    height: 18px;
}

.btn-logout:hover {
    background: var(--bg-card-hover);
    border-color: var(--danger);
    color: var(--danger);
}

/* User Management Page */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Permissions Grid */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.permissions-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.permissions-grid label:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.permissions-grid input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* User Actions */
.user-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Permission Tags */
.permission-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.permission-tag {
    padding: 0.25rem 0.5rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Section permission labels in user modal */
.section-permission-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.75rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.section-permission-label:has(input:checked) {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.section-permission-label .section-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.section-permission-label .section-pages {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.section-permission-label input[type="checkbox"] {
    display: none;
}

.role-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.admin {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge.user {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Adjust sidebar to make room for footer */
.sidebar {
    padding-bottom: 80px; /* Height of footer */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .login-box {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }

    .permissions-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .permission-tags {
        max-width: 100%;
        overflow-x: auto;
    }
}
