/* Custom styles for TestReportParser Web UI */

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Code block styling */
.font-mono {
    font-size: 0.75rem;
    line-height: 1.5;
}

/* HTMX loading states */
.htmx-request {
    opacity: 0.7;
    transition: opacity 200ms;
}

/* TipTap rendered content */
.tiptap-rendered {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.tiptap-rendered p.tiptap-text {
    margin: 0.25em 0;
}
.tiptap-rendered strong {
    font-weight: 700;
}
.tiptap-rendered em {
    font-style: italic;
}
.tiptap-rendered s {
    text-decoration: line-through;
}
.tiptap-rendered a {
    color: #2563eb;
    text-decoration: underline;
}
.dark .tiptap-rendered a {
    color: #60a5fa;
}
.tiptap-rendered ul.tiptap-text {
    list-style: disc;
    padding-left: 1.5em;
    margin: 0.25em 0;
}
.tiptap-rendered ul.tiptap-text li p {
    margin: 0;
}
.tiptap-rendered ol.tiptap-text {
    list-style: none;
    padding-left: 1.5em;
    margin: 0.25em 0;
}
.tiptap-rendered ol.tiptap-text li p {
    margin: 0;
}
.tiptap-rendered pre.tiptap-code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75em 1em;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin: 0.5em 0;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.tiptap-rendered pre.tiptap-code-block code {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    white-space: pre-wrap;
}

.tiptap-rendered img.tiptap-image {
    display: inline-block;
    vertical-align: middle;
}
.tiptap-rendered table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
}
.tiptap-rendered th,
.tiptap-rendered td {
    border: 1px solid #d1d5db;
    padding: 0.375rem 0.625rem;
    text-align: left;
    font-size: 0.8125rem;
    vertical-align: top;
}
.tiptap-rendered th {
    background: #f3f4f6;
    font-weight: 600;
}
.tiptap-rendered th p,
.tiptap-rendered td p {
    margin: 0;
}
.dark .tiptap-rendered th,
.dark .tiptap-rendered td {
    border-color: #4b5563;
}
.dark .tiptap-rendered th {
    background: #374151;
}

/* Image resize handles */
.tiptap-image-resizable { position: relative; display: inline-block; }
.tiptap-image-resizable:hover .resize-handle { opacity: 1; }
.resize-handle {
    position: absolute; width: 8px; height: 8px;
    background: #4f46e5; border-radius: 2px;
    opacity: 0; transition: opacity 0.2s; cursor: nwse-resize; z-index: 10;
}
.resize-handle-nw { top: -4px; left: -4px; }
.resize-handle-ne { top: -4px; right: -4px; cursor: nesw-resize; }
.resize-handle-sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.resize-handle-se { bottom: -4px; right: -4px; }

/* Step column borders */
.step-action {
    border-left: 2px solid #93c5fd;
    padding-left: 0.75rem;
}
.step-expected {
    border-left: 2px solid #86efac;
    padding-left: 0.75rem;
}

/* Custom checkbox */
.custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.custom-checkbox:checked {
    background-color: #4f46e5;
    border-color: #4f46e5;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}
.custom-checkbox:hover {
    border-color: #818cf8;
}
.custom-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Custom checkbox — dark */
.dark .custom-checkbox {
    background-color: #374151;
    border-color: #4b5563;
}
.dark .custom-checkbox:checked {
    background-color: #4f46e5;
    border-color: #4f46e5;
}
.dark .custom-checkbox:hover {
    border-color: #818cf8;
}

/* Custom radio */
.custom-radio {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background-color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    position: relative;
}
.custom-radio:checked {
    border-color: #4f46e5;
    background-color: #fff;
}
.custom-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4f46e5;
}
.custom-radio:hover {
    border-color: #818cf8;
}
.custom-radio:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dark .custom-radio {
    background-color: #374151;
    border-color: #4b5563;
}
.dark .custom-radio:checked {
    border-color: #818cf8;
    background-color: #374151;
}
.dark .custom-radio:checked::after {
    background-color: #818cf8;
}
.dark .custom-radio:hover {
    border-color: #818cf8;
}

/* Custom select */
.custom-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1em;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.custom-select:hover {
    border-color: #a5b4fc;
}
.custom-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dark .custom-select {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}
.custom-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Custom dropdown — Alpine.js компонент */
.custom-dropdown {
    position: relative;
}
.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1em;
}
.custom-dropdown-trigger:hover {
    border-color: #a5b4fc;
}
.custom-dropdown-trigger:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.custom-dropdown-trigger.placeholder {
    color: #9ca3af;
}
.dark .custom-dropdown-trigger {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}
.dark .custom-dropdown-trigger.placeholder {
    color: #6b7280;
}
.custom-dropdown-menu {
    position: absolute;
    z-index: 60;
    top: 100%;
    left: 0;
    /* Меню не уже триггера, но растёт по содержимому до max-width — длинные опции не вызывают горизонтальный скрол */
    min-width: 100%;
    width: max-content;
    max-width: 24rem;
    margin-top: 0.25rem;
    max-height: 12rem;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}
.dark .custom-dropdown-menu {
    background-color: #1f2937;
    border-color: #374151;
}
/* Dropup — раскрытие вверх (для элементов внизу экрана) */
.custom-dropdown.dropup .custom-dropdown-menu {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 0.25rem;
}
.custom-dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: #111827;
    transition: background-color 0.1s ease;
    /* Сброс наследуемого whitespace-nowrap из ячеек таблицы — длинные значения переносятся при достижении max-width меню */
    white-space: normal;
    word-break: break-word;
}
.custom-dropdown-option:hover,
.custom-dropdown-option.highlighted {
    background-color: #eef2ff;
}
.custom-dropdown-option.selected {
    background-color: #e0e7ff;
    font-weight: 500;
}
.dark .custom-dropdown-option {
    color: #f9fafb;
}
.dark .custom-dropdown-option:hover,
.dark .custom-dropdown-option.highlighted {
    background-color: #374151;
}
.dark .custom-dropdown-option.selected {
    background-color: #312e81;
}
.custom-dropdown-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Ghost variant — прозрачный фон, граница по hover (для таблиц) */
.custom-dropdown.ghost .custom-dropdown-trigger {
    background-color: transparent;
    border-color: transparent;
    padding: 0.375rem 1.75rem 0.375rem 0.5rem;
}
.custom-dropdown.ghost .custom-dropdown-trigger:hover {
    border-color: #d1d5db;
    background-color: rgba(249, 250, 251, 0.5);
}
.custom-dropdown.ghost .custom-dropdown-trigger:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.dark .custom-dropdown.ghost .custom-dropdown-trigger {
    background-color: transparent;
    border-color: transparent;
}
.dark .custom-dropdown.ghost .custom-dropdown-trigger:hover {
    border-color: #4b5563;
    background-color: rgba(55, 65, 81, 0.3);
}
.custom-dropdown.ghost .custom-dropdown-menu {
    min-width: 10rem;
}

/* Compact variant — для маленьких контролов (пагинация, inline) */
.custom-dropdown.compact .custom-dropdown-trigger {
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1rem;
    background-size: 0.75em;
}
.custom-dropdown.compact .custom-dropdown-option {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}
.custom-dropdown.compact .custom-dropdown-menu {
    min-width: 5rem;
}

/* Dark-bar variant — для тёмных панелей (bulk action bar) */
.custom-dropdown.dark-bar .custom-dropdown-trigger {
    background-color: #1f2937;
    border-color: #4b5563;
    color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}
.custom-dropdown.dark-bar .custom-dropdown-trigger.placeholder {
    color: #9ca3af;
}
.custom-dropdown.dark-bar .custom-dropdown-trigger:hover {
    border-color: #6b7280;
}
.custom-dropdown.dark-bar .custom-dropdown-menu {
    background-color: #1f2937;
    border-color: #374151;
}
.custom-dropdown.dark-bar .custom-dropdown-option {
    color: #e5e7eb;
}
.custom-dropdown.dark-bar .custom-dropdown-option:hover,
.custom-dropdown.dark-bar .custom-dropdown-option.highlighted {
    background-color: #374151;
}
.custom-dropdown.dark-bar .custom-dropdown-option.selected {
    background-color: #312e81;
}

/* Custom multi-dropdown — Alpine.js multi-select компонент */
.custom-multi-dropdown {
    position: relative;
}
.custom-multi-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1em;
}
.custom-multi-dropdown-trigger:hover {
    border-color: #a5b4fc;
}
.custom-multi-dropdown-trigger:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.custom-multi-dropdown-trigger.placeholder {
    color: #9ca3af;
}
.dark .custom-multi-dropdown-trigger {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
}
.dark .custom-multi-dropdown-trigger.placeholder {
    color: #6b7280;
}
.custom-multi-dropdown-menu {
    position: absolute;
    z-index: 60;
    top: 100%;
    left: 0;
    /* Меню не уже триггера, но растёт по содержимому до max-width — длинные опции не вызывают горизонтальный скрол */
    min-width: 100%;
    width: max-content;
    max-width: 24rem;
    margin-top: 0.25rem;
    max-height: 14rem;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}
.dark .custom-multi-dropdown-menu {
    background-color: #1f2937;
    border-color: #374151;
}
.custom-multi-dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: #111827;
    transition: background-color 0.1s ease;
    /* Сброс наследуемого whitespace-nowrap — длинные значения переносятся в пределах max-width меню */
    white-space: normal;
    word-break: break-word;
}
.custom-multi-dropdown-option:hover,
.custom-multi-dropdown-option.highlighted {
    background-color: #eef2ff;
}
.custom-multi-dropdown-option.selected {
    background-color: #e0e7ff;
}
.dark .custom-multi-dropdown-option {
    color: #f9fafb;
}
.dark .custom-multi-dropdown-option:hover,
.dark .custom-multi-dropdown-option.highlighted {
    background-color: #374151;
}
.dark .custom-multi-dropdown-option.selected {
    background-color: #312e81;
}
.custom-multi-dropdown-checkbox {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 1.5px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}
.custom-multi-dropdown-checkbox.checked {
    background-color: #6366f1;
    border-color: #6366f1;
}
.dark .custom-multi-dropdown-checkbox {
    border-color: #4b5563;
}
.dark .custom-multi-dropdown-checkbox.checked {
    background-color: #6366f1;
    border-color: #6366f1;
}
.custom-multi-dropdown-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 9999px;
    background-color: #6366f1;
    color: #fff;
    margin-left: auto;
}
.custom-multi-dropdown-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: #6b7280;
    cursor: pointer;
    border-top: 1px solid #e5e7eb;
    transition: background-color 0.1s ease;
}
.custom-multi-dropdown-clear:hover {
    background-color: #fef2f2;
    color: #ef4444;
}
.dark .custom-multi-dropdown-clear {
    color: #9ca3af;
    border-top-color: #374151;
}
.dark .custom-multi-dropdown-clear:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: #f87171;
}
.custom-multi-dropdown-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Bubble toolbar */
.bubble-toolbar {
    position: fixed;
    z-index: 100;
    display: flex;
    gap: 2px;
    padding: 4px 6px;
    background: #1e293b;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transform: translate(-50%, -100%);
    opacity: 0;
    transition: opacity 150ms ease, transform 150ms ease;
    pointer-events: none;
}
.bubble-toolbar.visible {
    opacity: 1;
    pointer-events: auto;
}
.bubble-toolbar button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #e2e8f0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.bubble-toolbar button:hover {
    background: #334155;
}
.bubble-toolbar button.active {
    background: #4f46e5;
    color: #fff;
}
.bubble-toolbar .separator {
    width: 1px;
    background: #475569;
    margin: 4px 2px;
    align-self: stretch;
}

/* Custom number stepper — hide native spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* Form validation */
.field-error { border-color: #ef4444 !important; }
.field-error-text { color: #ef4444; font-size: 0.75rem; margin-top: 0.25rem; }

/* TipTap editor wrapper */
.ProseMirror {
    outline: none;
    min-height: 2em;
}
.ProseMirror:focus {
    outline: none;
}

/* Static toolbar above editor */
.tiptap-static-toolbar {
    display: flex;
    gap: 2px;
    padding: 3px 4px;
    background: #f1f5f9;
    border: 1px solid #d1d5db;
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
}
.tiptap-static-toolbar + .ProseMirror {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.tiptap-static-toolbar button {
    width: 26px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: #475569;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0;
}
.tiptap-static-toolbar button:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.tiptap-static-toolbar button.is-active {
    background: #4f46e5;
    color: #fff;
}

/* Step controls */
.step-controls {
    display: inline-flex;
    gap: 2px;
    margin-left: 8px;
}
.step-controls button {
    width: 24px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0;
    line-height: 1;
    transition: all 0.15s ease;
}
.step-controls button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}
.step-controls button.step-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Drag handle */
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 22px;
    color: #94a3b8;
    cursor: grab;
    font-size: 0.85rem;
    border-radius: 3px;
    border: 1px solid transparent;
    user-select: none;
    padding: 0;
    line-height: 1;
}
.drag-handle:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}
.drag-handle:active {
    cursor: grabbing;
}

/* Drag-and-drop step states */
.step-dragging {
    opacity: 0.35;
    background: #f8fafc;
}
.step-drag-over {
    border-top: 2px solid #6366f1 !important;
    margin-top: -1px;
}

/* ---- Dark theme: Chrome autofill fix ---- */
.dark input:-webkit-autofill,
.dark input:-webkit-autofill:hover,
.dark input:-webkit-autofill:focus,
.dark textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #374151 inset !important;
    -webkit-text-fill-color: #f9fafb !important;
    border-color: #4b5563 !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* ---- Dark theme: element-level overrides ---- */

/* Scrollbar */
.dark ::-webkit-scrollbar-track { background: #1f2937; }
.dark ::-webkit-scrollbar-thumb { background: #4b5563; }
.dark ::-webkit-scrollbar-thumb:hover { background: #6b7280; }

/* Form inputs & textareas */
.dark input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]),
.dark textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}
.dark input::placeholder,
.dark textarea::placeholder {
    color: #9ca3af;
}

/* <dialog> modals */
.dark dialog {
    background-color: #1f2937;
    color: #e5e7eb;
}

/* CodeMirror */
.dark .CodeMirror {
    background: #1f2937;
    color: #e5e7eb;
    border-color: #4b5563;
}

/* Static toolbar dark */
.dark .tiptap-static-toolbar {
    background: #1e293b;
    border-color: #4b5563;
}
.dark .tiptap-static-toolbar button {
    color: #9ca3af;
}
.dark .tiptap-static-toolbar button:hover {
    background: #334155;
    color: #e5e7eb;
}

/* Step controls dark */
.dark .step-controls button {
    border-color: #4b5563;
    background: #374151;
    color: #9ca3af;
}
.dark .step-controls button:hover {
    background: #4b5563;
    border-color: #6b7280;
    color: #e5e7eb;
}
.dark .step-controls button.step-delete:hover {
    background: #451a1a;
    border-color: #f87171;
    color: #f87171;
}

/* Drag handle dark */
.dark .drag-handle {
    color: #6b7280;
}
.dark .drag-handle:hover {
    background: #374151;
    border-color: #4b5563;
    color: #9ca3af;
}

/* ============================================================
   UI-Kit extension — switch, tooltip, button-group segments
   ============================================================ */

/* Switch (toggle) — стилизованный track + thumb через peer-checked.
   Использовать макрос forms.switch(): скрытый input + .tf-switch-track. */
.tf-switch-track {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background-color: #d1d5db;
    border-radius: 9999px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}
.tf-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: #fff;
    border-radius: 9999px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}
.tf-switch:checked + .tf-switch-track {
    background-color: #4f46e5;
}
.tf-switch:checked + .tf-switch-track::after {
    transform: translateX(16px);
}
.tf-switch:focus-visible + .tf-switch-track {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.tf-switch:disabled + .tf-switch-track {
    opacity: 0.5;
    cursor: not-allowed;
}
.dark .tf-switch-track {
    background-color: #4b5563;
}
.dark .tf-switch-track::after {
    background-color: #f9fafb;
}
.dark .tf-switch:checked + .tf-switch-track {
    background-color: #6366f1;
}

/* Tooltip — CSS-only через data-tooltip атрибут. Без JS, без зависимостей. */
.tf-tooltip {
    position: relative;
    display: inline-flex;
}
.tf-tooltip::before,
.tf-tooltip::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 70;
}
.tf-tooltip::before {
    content: attr(data-tooltip);
    padding: 4px 8px;
    background-color: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.tf-tooltip::after {
    content: '';
    width: 0;
    height: 0;
    border: 4px solid transparent;
}
/* Top (default) */
.tf-tooltip[data-tooltip-side="top"]::before,
.tf-tooltip:not([data-tooltip-side])::before {
    bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(2px);
}
.tf-tooltip[data-tooltip-side="top"]::after,
.tf-tooltip:not([data-tooltip-side])::after {
    bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%);
    border-top-color: #1e293b;
}
/* Bottom */
.tf-tooltip[data-tooltip-side="bottom"]::before {
    top: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(-2px);
}
.tf-tooltip[data-tooltip-side="bottom"]::after {
    top: calc(100% + 2px); left: 50%; transform: translateX(-50%);
    border-bottom-color: #1e293b;
}
/* Left */
.tf-tooltip[data-tooltip-side="left"]::before {
    right: calc(100% + 6px); top: 50%; transform: translateY(-50%) translateX(2px);
}
.tf-tooltip[data-tooltip-side="left"]::after {
    right: calc(100% + 2px); top: 50%; transform: translateY(-50%);
    border-left-color: #1e293b;
}
/* Right */
.tf-tooltip[data-tooltip-side="right"]::before {
    left: calc(100% + 6px); top: 50%; transform: translateY(-50%) translateX(-2px);
}
.tf-tooltip[data-tooltip-side="right"]::after {
    left: calc(100% + 2px); top: 50%; transform: translateY(-50%);
    border-right-color: #1e293b;
}
.tf-tooltip:hover::before,
.tf-tooltip:hover::after,
.tf-tooltip:focus-within::before,
.tf-tooltip:focus-within::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.tf-tooltip[data-tooltip-side="left"]:hover::before,
.tf-tooltip[data-tooltip-side="right"]:hover::before {
    transform: translateY(-50%) translateX(0);
}

/* Button group — соединённые сегменты. */
.tf-btn-group > * {
    border-radius: 0;
    box-shadow: none;
}
.tf-btn-group > *:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}
.tf-btn-group > *:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}
.tf-btn-group > * + * {
    margin-left: -1px;
}
.tf-btn-group > *:hover,
.tf-btn-group > *:focus-visible {
    z-index: 1;
}

/* =============================================================
   KB Portal styles (.kb-prose-content, .kb-toc, .kb-search, etc.)
   ПЕРЕНЕСЕНЫ в app/web/static/css/kb-portal.css (I1).
   Подключается ТОЛЬКО на /kb/* страницах через kb/base.html — не
   увеличивает initial bundle для остальных страниц TestFlow.
   ============================================================= */

/* line-clamp utility — нужна вне KB (используется в category/domain
   и потенциально других местах). Оставлена в app.css. */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}



/* I6 (kb-portal-redesign): KB-link icon в /profile «Быстрые ссылки».
   Идентичный logo-icon в kb/_topbar.html — gradient square с menu-svg
   внутри. Применяется на TestFlow chrome (app.css), а не KB-shell. */
.profile-kb-icon {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 0.25rem;
    background: linear-gradient(140deg, #4f7cff, #c478e6);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

/* Jaga Gantt — общий CSS Grid компонент для planning и release report. */
.jaga-gantt-container {
    gap: 0;
}

.jaga-gantt-cell {
    min-width: 0;
}

.jaga-gantt-weekend {
    background: rgb(249 250 251);
}

.dark .jaga-gantt-weekend {
    background: rgb(31 41 55 / 0.7);
}

.jaga-gantt-weekend-cell {
    background: rgb(249 250 251);
}

.dark .jaga-gantt-weekend-cell {
    background: rgb(31 41 55 / 0.5);
}

.jaga-gantt-today {
    border-left: 2px solid rgb(239 68 68);
    border-right: 2px solid rgb(239 68 68);
}

.jaga-gantt-today-line {
    border-left: 2px solid rgb(239 68 68);
}

.jaga-gantt-day-bg {
    min-height: 34px;
}

.jaga-gantt-bar-in-progress {
    background-image: repeating-linear-gradient(
        45deg,
        rgb(59 130 246),
        rgb(59 130 246) 6px,
        rgb(37 99 235) 6px,
        rgb(37 99 235) 12px
    );
}

/* Tailwind build fix: missing md: responsive utilities (md:flex, md:block).
   Tailwind.min.css содержит md:hidden, md:grid-cols-* но НЕ md:flex/md:block.
   Добавляем вручную — affect projects/detail.html tabs + admin panels. */
@media (min-width: 768px) {
    .md\:flex { display: flex; }
    .md\:block { display: block; }
    .md\:grid { display: grid; }
    .md\:inline { display: inline; }
    .md\:inline-block { display: inline-block; }
}
