/* ============================================
   CobraBot Mission Control — Styles
   ============================================ */

/* === Base === */
body {
    font-family: 'Inter', sans-serif;
    background-color: #0f172a;
    color: #f8fafc;
    overflow-x: hidden;
}

/* === Cards === */
.card {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 16px;
}

/* === Scrollbar === */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

#user-inline-block {
    min-width: 0;            /* не вылезает за пределы flex-контейнера */
    overflow: hidden;       /* обрезаем всё что выходит за родителя */
    flex-shrink: 1;         /* позволяет сжиматься при нехватке места */
    box-sizing: border-box;
}
#user-inline-body {
    min-width: 0;
    overflow-x: hidden;      /* горизонтальный скролл только внутри, контент не роляет */
}
#inline-console-body {
    min-width: 0;            /* чтобы monospace-текст не растягивал блок */
    overflow-x: auto;        /* при необходимости горизонтальный скролл именно в логе */
}

.console-line {
    padding: 8px 12px;
    border-bottom: 1px solid #1e293b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    -webkit-user-select: text;
    user-select: text;
}
.console-line ::selection, .console-line::selection {
    background: #f43f5e;
    color: #fff;
}
#console-body ::selection {
    background: #f43f5e;
    color: #fff;
}
.console-role {
    font-weight: 700;
    margin-right: 8px;
    text-transform: uppercase;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
}
.role-user {
    background: #1e3a5f;
    color: #60a5fa;
}
.role-assistant {
    background: #1a3329;
    color: #34d399;
}
.role-system {
    background: #3b1f51;
    color: #c084fc;
}
.role-toolResult {
    background: #1e293b;
    color: #64748b;
}

/* === Status indicators === */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
}
.type-Message   { color: #3b82f6; }
.type-Tool-Use  { color: #f59e0b; }
.type-Reply     { color: #10b981; }
.type-Tool-Result { color: #64748b; }
.type-Thinking  { color: #a855f7; }

/* === Modal === */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 50;
}
.modal.active {
    display: flex;
}

/* === User profile tabs === */
.user-tab {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
}
.user-tab:hover { color: #cbd5e1; }
.user-tab.active {
    color: #22d3ee;
    border-bottom-color: #22d3ee;
}

/* Hint icon (?) — тёмно-синяя */
.hint-icon {
    display: inline-block;
    width: 13px;
    height: 13px;
    line-height: 13px;
    text-align: center;
    font-size: 10px;
    font-weight: 900;
    color: #93c5fd;                   /* blue-300 — тусклый */
    background: #1e3a8a;              /* blue-900 */
    border: 1px solid #1e40af;        /* blue-800 */
    border-radius: 50%;
    margin-left: 4px;
    cursor: help;
    user-select: none;
    transition: all .15s;
    box-shadow: 0 0 0 1px rgba(30, 58, 138, 0.25);
    vertical-align: middle;
}
.hint-icon:hover,
.hint-icon:focus,
.hint-icon:active {
    background: #1e40af;              /* blue-800 чуть светлее */
    border-color: #2563eb;
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
    outline: none;
}
@media (hover: none) {
    .hint-icon:active {
        background: #1e40af;
        border-color: #2563eb;
        transform: scale(1.15);
        box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
    }
}

/* Inline profile (for non-owner users) — вкладки в 2 раза крупнее */
#user-inline-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    padding-bottom: 4px;
}
#user-inline-tabs::-webkit-scrollbar {
    height: 4px;
}
#user-inline-tabs::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 2px;
}
#user-inline-tabs .user-tab {
    padding: 12px 20px;
    font-size: 15px;
    white-space: nowrap;
    flex-shrink: 0;
}
#user-inline-tabs .user-tab.active {
    border-bottom-width: 3px;
}

/* === Thought bubble (for AI thinking logs) === */
.thought-bubble {
    background: #1e293b;
    border-radius: 8px;
    padding: 10px;
    border-left: 4px solid #a855f7;
    margin: 10px 0;
    font-style: italic;
    color: #d8b4fe;
}

/* === Animations: pulse ring === */
@keyframes pulse-ring {
    0%          { transform: scale(.33); opacity: 1; }
    80%, 100%   { opacity: 0; }
}

/* === Working indicator (green pulse) === */
.working-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    margin-right: 4px;
    vertical-align: middle;
    position: relative;
}
.working-indicator::before {
    content: '';
    position: absolute;
    width: 300%;
    height: 300%;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    left: -100%;
    top: -100%;
}

/* === Waiting indicator (amber pulse) === */
.waiting-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    margin-right: 4px;
    vertical-align: middle;
    position: relative;
}
.waiting-indicator::before {
    content: '';
    position: absolute;
    width: 300%;
    height: 300%;
    border-radius: 50%;
    background: #f59e0b;
    animation: pulse-ring 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    left: -100%;
    top: -100%;
}

/* === Form elements === */
select {
    background-image: none !important;
}

.model-select {
    background: #0f172a;
    border: 1px solid #334155;
    color: #94a3b8;
    font-size: 10px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    transition: all 0.2s;
}
.model-select:hover {
    border-color: #60a5fa;
    color: #e2e8f0;
}
.model-select:focus {
    outline: none;
    border-color: #3b82f6;
}
.model-select.loading {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%2360a5fa' d='M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8 8 0 0 1-8 8z' opacity='.3'/%3E%3Cpath fill='%2360a5fa' d='M20 12h2A10 10 0 0 0 12 2v2a8 8 0 0 1 8 8z'%3E%3CanimateTransform attributeName='transform' dur='.6s' from='0 12 12' repeatCount='indefinite' to='360 12 12' type='rotate'/%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    color: transparent !important;
}

/* === Loading button (universal) ===
.btn-loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}
.btn-loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}
.btn-loading:not(:has(::after))::after {
    display: none;
}
/* Кнопка-лоудер без текста — только спиннер */
.btn-loading:empty::after,
.btn-loading.btn-icon::after {
    position: static;
    transform: none;
    margin-left: 0;
}

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

/* === Initial Loader === */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}
.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.loader-icon {
    font-size: 48px;
    animation: loader-float 2s ease-in-out infinite;
}
@keyframes loader-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #1e293b;
    border-top-color: #f43f5e;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-text {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #64748b;
}
.loader-dots {
    display: flex;
    gap: 6px;
}
.loader-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f43f5e;
    animation: loader-pulse 1.4s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loader-pulse {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* === Operation Loader (long-running actions) === */
.op-loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.op-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 32px 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.op-loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #1e293b;
    border-top-color: #f43f5e;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.op-loader-text {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
}
.op-loader-timeout {
    font-size: 11px;
    color: #f43f5e;
    font-family: 'JetBrains Mono', monospace;
    min-height: 14px;
}
.op-loader-timeout.warn { color: #f59e0b; }
.op-loader-timeout.ok { color: #10b981; }

/* Owner row pinned-style: subtle amber accent + sticky top within scrollable table */
tr.owner-row {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
    border-left: 3px solid rgba(245, 158, 11, 0.5);
}
tr.owner-row:hover {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.14) 0%, transparent 50%);
}
