/* WayFlow Panel — Main Styles (Client Light Theme) */

@font-face {
    font-family: 'Onest Variable';
    font-weight: 100 900;
    src: url('/assets/fonts/onest/onest-cyrillic-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
    font-family: 'Onest Variable';
    font-weight: 100 900;
    src: url('/assets/fonts/onest/onest-cyrillic-wght-normal.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: 'Onest Variable';
    font-weight: 100 900;
    src: url('/assets/fonts/onest/onest-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Onest Variable';
    font-weight: 100 900;
    src: url('/assets/fonts/onest/onest-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Client design tokens */
    --wf-font: "Onest Variable", "Onest", system-ui, -apple-system, sans-serif;
    --wf-blue: #3b82f6;
    --wf-blue-light: #60a5fa;
    /* Акцент — графит (ядро WF v1, wf-core.css: --wf-accent/--wf-accent-dark).
       Синий (--wf-blue) остаётся СЕМАНТИЧЕСКИМ: info, бейджи продуктов, data-viz. */
    --wf-accent-grad: linear-gradient(135deg, #4b525c, #31363e);
    --wf-purple: #8b5cf6;
    --wf-amber: #f59e0b;
    --wf-green: #10b981;
    --wf-red: #ef4444;
    --wf-black: var(--wf-graphite, #3F454E);
    --wf-white: #ffffff;
    --wf-bg-light: #fafafa;
    --wf-bg-gray: #f0f0f5;
    --wf-text-primary: var(--wf-graphite, #3F454E);
    --wf-text-secondary: #4a505a;
    --wf-text-muted: #666666;
    --wf-text-gray: #6b7280;
    --wf-border: #d1d5db;

    /* Glass */
    --wf-glass-bg: linear-gradient(135deg, rgba(255,255,255,0.92) 0%, rgba(245,245,250,0.88) 100%);
    --wf-glass-border: 1px solid rgba(255,255,255,0.75);
    --wf-glass-blur: blur(28px) saturate(200%);
    --wf-shadow-glass:
        inset 0 1px 0 rgba(255,255,255,0.8),
        inset 0 -1px 0 rgba(0,0,0,0.04),
        0 12px 48px rgba(0,0,0,0.1),
        0 6px 16px rgba(0,0,0,0.06);
    --wf-shadow-glass-strong:
        inset 0 1px 0 rgba(255,255,255,0.9),
        0 20px 60px rgba(0,0,0,0.12),
        0 8px 24px rgba(0,0,0,0.08);

    /* Spacing */
    --wf-space-1: 4px;
    --wf-space-2: 8px;
    --wf-space-3: 12px;
    --wf-space-4: 16px;
    --wf-space-5: 20px;
    --wf-space-6: 24px;
    --wf-space-8: 32px;
    --wf-space-10: 40px;

    /* Radius */
    --wf-radius-sm: 10px;
    --wf-radius-md: 12px;
    --wf-radius-lg: 16px;
    --wf-radius-xl: 20px;
    --wf-radius-pill: 9999px;

    /* Legacy aliases — backward compat */
    --color-bg: var(--wf-bg-gray);
    --color-surface: #ffffff;
    --color-surface-hover: rgba(0,0,0,0.02);
    --color-border: var(--wf-border);
    --color-text: var(--wf-text-primary);
    --color-text-secondary: var(--wf-text-gray);
    --color-primary: var(--wf-accent, #3F454E);
    --color-primary-hover: var(--wf-accent-dark, #2e343c);
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-info: #3b82f6;
    --color-success-bg: #e6f5ed;
    --sidebar-width: 240px;
    --header-height: 60px;
    --radius: var(--wf-radius-lg);
    --radius-sm: var(--wf-radius-md);
    --shadow: var(--wf-shadow-glass);
}

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

body {
    font-family: var(--wf-font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[class^="ri-"],
[class*=" ri-"] {
    font-family: 'remixicon' !important;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-hover);
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    border-right: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.2s ease;
}

.sidebar__logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar__nav {
    flex: 1;
    padding: 12px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--wf-radius-md);
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.sidebar__link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar__link.active {
    /* тёмный сайдбар: активный пункт — светлый тинт (графит на тёмном не читается) */
    background: rgba(255,255,255,0.14);
    color: #fff;
}

.sidebar__link-icon {
    width: 20px;
    text-align: center;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar__link.active .sidebar__link-icon {
    color: #fff;
}

.sidebar__footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Main content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.header {
    height: var(--header-height);
    background: var(--wf-white);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--wf-text-primary);
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content {
    padding: 24px;
}

.stat-card__value--success {
    color: var(--color-success);
}

.stat-card__value--warning {
    color: var(--color-warning);
}

.stat-card__value--danger {
    color: var(--color-danger);
}

.stat-card__value--xl {
    font-size: 32px;
}

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

thead th {
    text-align: left;
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wf-text-gray);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    background: transparent;
}

tbody td {
    padding: 12px 20px;
    font-size: 14px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    color: var(--wf-text-primary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.badge--active {
    background: #e6f5ed;
    color: #1a8a4a;
}

.badge--suspended {
    background: #fef3cd;
    color: #92600e;
}

.badge--error {
    background: #fde8e8;
    color: #c53030;
}

.badge--wayflow_core {
    background: #e8eeff;
    color: #2563eb;
}

.badge--hilead_wp {
    background: #f3e8ff;
    color: #7c3aed;
}

.badge--hishield_wp {
    background: #d1fae5;
    color: #059669;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 22px;
    border-radius: var(--wf-radius-pill);
    font-family: var(--wf-font);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    letter-spacing: 0.01em;
}

.btn:hover {
    filter: brightness(1.08);
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

.btn:active {
    transform: scale(0.98);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.btn--primary {
    background: var(--wf-accent-grad);
    color: #fff;
}

.btn--primary:hover {
    color: #fff;
}

.btn--outline {
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.75);
    color: var(--wf-text-gray);
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.5), 0 2px 8px rgba(0,0,0,0.04);
}

.btn--outline:hover {
    background: var(--wf-white);
    color: var(--wf-accent);
    border-color: var(--wf-accent);
    box-shadow: var(--wf-focus-ring), 0 2px 8px rgba(0,0,0,0.06);
}

/* Button aliases used in some templates */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 22px;
    border-radius: var(--wf-radius-pill);
    font-family: var(--wf-font);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.12s ease;
    text-decoration: none;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    letter-spacing: 0.01em;
}

.button:hover {
    filter: brightness(1.08);
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}

.button-primary {
    background: var(--wf-accent-grad);
    color: #fff;
}

.button-primary:hover {
    color: #fff;
}

.button-block {
    width: 100%;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--wf-text-gray);
    margin-top: 4px;
}

.wizard__step--active {
    background: var(--wf-accent-grad);
    color: #fff;
    border-color: transparent;
}

.wizard__step--done {
    color: var(--wf-green);
}

.text-danger {
    color: var(--wf-red);
}

.mb-4 {
    margin-bottom: 16px;
}

/* Forms */
.form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--wf-text-gray);
    letter-spacing: 0.01em;
}

.form-control {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.75);
    border-radius: var(--wf-radius-lg);
    color: var(--color-text);
    font-family: var(--wf-font);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.12s ease;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.5), 0 2px 8px rgba(0,0,0,0.04);
}

.form-control::placeholder {
    color: var(--wf-text-muted);
    font-weight: 400;
}

.form-control:focus {
    outline: none;
    border-color: var(--wf-accent);
    background: var(--wf-white);
    box-shadow: var(--wf-focus-ring), 0 2px 8px rgba(0,0,0,0.06);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--wf-radius-lg);
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert:last-child {
    margin-bottom: 0;
}

.alert--error {
    background: #fde8e8;
    color: #c53030;
    border-color: rgba(239, 68, 68, 0.2);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-secondary);
}

.empty-state__title {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--color-text);
}

.empty-state__icon {
    font-size: 32px;
    margin-bottom: 12px;
    line-height: 1;
}

.empty-state__icon--lg {
    font-size: 48px;
}

.empty-state--boxed {
    text-align: left;
    padding: 24px;
}

.empty-state--boxed .empty-state__title {
    margin: 0 0 8px;
}

.empty-state__actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
}

/* API key display */
.api-key {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    background: var(--color-bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    color: var(--color-warning);
    display: inline-block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wf-bg-gray);
}

.login-card {
    background: var(--wf-glass-bg);
    border: var(--wf-glass-border);
    border-radius: var(--wf-radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--wf-shadow-glass-strong);
    backdrop-filter: var(--wf-glass-blur);
    -webkit-backdrop-filter: var(--wf-glass-blur);
}

.login-card__title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
    color: var(--wf-text-primary);
}

.login-card__subtitle {
    font-size: 14px;
    color: var(--wf-text-gray);
    text-align: center;
    margin-bottom: 32px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--wf-glass-bg);
    border: var(--wf-glass-border);
    border-radius: var(--wf-radius-lg);
    padding: 12px 16px;
    font-size: 14px;
    box-shadow: var(--wf-shadow-glass-strong);
    backdrop-filter: var(--wf-glass-blur);
    -webkit-backdrop-filter: var(--wf-glass-blur);
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--wf-text-primary);
}

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

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

.toast--info {
    border-left: 3px solid var(--color-info);
}

.toast__close {
    margin-left: auto;
    cursor: pointer;
    color: var(--wf-text-gray);
    background: none;
    border: none;
    font-size: 16px;
    padding: 0 4px;
    font-family: var(--wf-font);
}

.toast__close:hover {
    color: var(--wf-text-primary);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* API Docs */
.api-endpoint {
    background: var(--wf-glass-bg);
    border: var(--wf-glass-border);
    border-radius: var(--wf-radius-xl);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--wf-shadow-glass);
    backdrop-filter: var(--wf-glass-blur);
    -webkit-backdrop-filter: var(--wf-glass-blur);
}

.api-endpoint__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.02);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.api-endpoint__desc {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--wf-text-gray);
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.api-endpoint__details {
    padding: 16px;
}

.api-endpoint__details strong {
    display: block;
    font-size: 13px;
    color: var(--wf-text-gray);
    margin-bottom: 8px;
    margin-top: 12px;
}

.api-endpoint__details strong:first-child {
    margin-top: 0;
}

.api-code {
    background: #f9fafb;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--wf-radius-md);
    padding: 12px 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    color: var(--wf-text-primary);
    overflow-x: auto;
    white-space: pre;
    display: block;
    margin-bottom: 4px;
}

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.hidden {
    display: none !important;
}

.text-warning {
    color: var(--wf-amber);
}

.text-success {
    color: var(--wf-green);
}

/* Mobile menu toggle */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--wf-radius-md);
    color: var(--wf-text-primary);
    font-size: 18px;
    cursor: pointer;
    margin-right: 12px;
    transition: all 0.12s ease;
}

.mobile-menu-btn:hover {
    background: rgba(0,0,0,0.06);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 99;
}

body.sidebar-open .sidebar-overlay {
    display: block;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive */
@media (max-width: 1024px) {

    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .main {
        margin-left: 0;
    }

    .header {
        padding: 0 20px;
    }

    .header__title {
        font-size: 16px;
    }

    .content {
        padding: 20px;
    }

    .content [style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
    }

    .content [style*="auto-fit"],
    .content [style*="auto-fill"] {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    /* Topbar actions (page buttons/filters + icons) can exceed the viewport on
       narrow screens; let the header wrap the actions onto their own row and let
       those actions wrap/shrink so the document never scrolls sideways. */
    .header {
        padding: 8px 16px;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-height);
        row-gap: 10px;
    }

    .header__title {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header__actions {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
        min-width: 0;
        gap: 8px;
    }

    .header__actions > * {
        min-width: 0;
        max-width: 100%;
    }

    .content {
        padding: 16px;
    }

    table {
        min-width: 640px;
    }

    .form {
        max-width: 100%;
    }

    .form-control,
    .btn {
        min-height: 44px;
        font-size: 16px;
    }

    .btn {
        padding: 10px 16px;
    }

    .toast-container {
        left: 16px;
        right: 16px;
        top: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    .content [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .content [style*="display: flex"] {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 24px;
        margin: 16px;
    }

    .login-card__title {
        font-size: 20px;
    }

    thead th,
    tbody td {
        padding: 10px 12px;
    }
}

.lifecycle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border, #d5d5dd);
    flex-shrink: 0;
}
.lifecycle-dot--done { background: var(--color-primary, #3F454E); }
.lifecycle-line {
    width: 16px;
    height: 2px;
    background: var(--color-border, #d5d5dd);
    flex-shrink: 0;
}
.lifecycle-line--done { background: var(--color-primary, #3F454E); }

/* ===== Focus mode: collapsible panel sidebar (analysis studio) ===== */
body.wf-focus-mode .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
body.wf-focus-mode .main { margin-left: 0; }
.sidebar { transition: transform 0.25s ease; }
.main { transition: margin-left 0.25s ease; }
#wf-focus-toggle {
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 1200;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--color-border, #d5d5dd);
    background: var(--color-surface, #fff);
    color: var(--color-text, #222);
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

