/* ═══════════════════════════════════════════════════════════════════════════
   ExaGuard Remote PowerShell — powershell.css  (Light Theme)
   Add to _Host.cshtml: <link rel="stylesheet" href="css/powershell.css" />
═══════════════════════════════════════════════════════════════════════════ */

/* ── Root ────────────────────────────────────────────────────────────────── */

.ps-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    background: #f4f4f7;
    color: #1a1a2e;
    font-family: inherit;
    overflow: hidden;
}

/* ═══ TOP BAR ════════════════════════════════════════════════════════════ */

.ps-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    flex-shrink: 0;
    background: #ffffff;
    border-bottom: 1px solid #e2e2ec;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    gap: 12px;
}

.ps-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ps-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ps-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    border: 1px solid #7dd3fc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #0369a1;
    flex-shrink: 0;
}

.ps-agent-meta {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1;
}

.ps-agent-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: #111128;
}

.ps-agent-sub {
    font-size: 0.68rem;
    color: #9090a8;
    display: flex;
    align-items: center;
    gap: 3px;
}

.ps-status-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ps-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ps-pill-on {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

    .ps-pill-on .ps-status-dot {
        background: #0ea5e9;
    }

.ps-pill-running {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

    .ps-pill-running .ps-status-dot {
        background: #22c55e;
        animation: ps-pulse 1s ease-in-out infinite;
    }

.ps-pill-off {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

    .ps-pill-off .ps-status-dot {
        background: #ef4444;
    }

@keyframes ps-pulse {
    0%,100% {
        opacity: 1
    }

    50% {
        opacity: 0.4
    }
}

.ps-ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #e2e2ec;
    background: #f8f8fc;
    color: #555570;
    font-size: 0.73rem;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
    white-space: nowrap;
    text-decoration: none;
}

    .ps-ctrl-btn:hover {
        background: #ededf4;
        border-color: #c8c8dc;
        color: #111128;
    }

/* ═══ BODY ════════════════════════════════════════════════════════════════ */

.ps-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
}

/* ── Terminal column ─────────────────────────────────────────────────────── */

.ps-terminal-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #ffffff;
    border-right: 1px solid #e8e8f0;
}

/* ── Output area ─────────────────────────────────────────────────────────── */

.ps-output {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 8px;
    scrollbar-width: thin;
    scrollbar-color: #d0d0e0 transparent;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-family: 'Cascadia Code', 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    background: #fafafa;
}

/* Banner */
.ps-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #b0b0c8;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eeeef6;
    font-family: system-ui, sans-serif;
}

.ps-banner-icon {
    color: #0369a1;
    font-size: 0.85rem;
}

.ps-banner-sep {
    color: #d0d0e0;
}

.ps-banner-id {
    font-family: monospace;
    font-size: 0.65rem;
    color: #c0c0d8;
}

/* ── Terminal entry ──────────────────────────────────────────────────────── */

.ps-entry {
    margin-bottom: 14px;
    border-left: 2px solid #e8e8f4;
    padding-left: 12px;
}

    .ps-entry:hover {
        border-color: #c4b5fd;
    }

.ps-cmd-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.ps-prompt {
    color: #0369a1;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.ps-cmd-text {
    color: #1a1a2e;
    font-size: 0.82rem;
    word-break: break-all;
    flex: 1;
    font-weight: 500;
}

.ps-cmd-time {
    font-size: 0.6rem;
    color: #c0c0d0;
    flex-shrink: 0;
    font-family: system-ui, sans-serif;
}

/* Output lines */
.ps-out-line {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    padding: 1px 0;
    font-size: 0.78rem;
    line-height: 1.55;
    color: #333348;
    word-break: break-word;
    white-space: pre-wrap;
}

.ps-err {
    color: #dc2626;
}

.ps-err-icon {
    font-size: 0.7rem;
    flex-shrink: 0;
    margin-top: 2px;
    color: #dc2626;
}

/* Running dots */
.ps-running {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.68rem;
    color: #b0b0c8;
    margin-top: 4px;
    font-family: system-ui, sans-serif;
}

.ps-dots {
    display: flex;
    gap: 3px;
}

    .ps-dots span {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #0ea5e9;
        animation: ps-bounce 1.2s ease-in-out infinite;
    }

        .ps-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .ps-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes ps-bounce {
    0%,80%,100% {
        transform: translateY(0);
        opacity: .4
    }

    40% {
        transform: translateY(-4px);
        opacity: 1
    }
}

/* Entry footer */
.ps-entry-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    font-size: 0.65rem;
    font-family: system-ui, sans-serif;
}

.ps-ok {
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.ps-fail {
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.ps-dur {
    color: #c0c0d0;
}

/* ── Input bar ───────────────────────────────────────────────────────────── */

.ps-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 16px;
    background: #ffffff;
    border-top: 2px solid #e8e8f4;
    flex-shrink: 0;
}

.ps-prompt-inline {
    color: #0369a1;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    /* Align with first line of textarea */
    padding-bottom: 6px;
}

/* Textarea replaces the old single-line input */
.ps-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none; /* no manual resize handle */
    overflow-y: hidden; /* JS controls this */
    min-height: 32px;
    height: 32px; /* starts at 1 line; JS expands up to 10 */
    padding: 6px 0;
    color: #1a1a2e;
    font-size: 0.82rem;
    line-height: 1.5;
    font-family: 'Cascadia Code', 'Consolas', 'Fira Code', monospace;
    caret-color: #0369a1;
    background: transparent;
    scrollbar-width: thin;
    scrollbar-color: #c8c8e0 transparent;
    word-break: break-all;
    white-space: pre-wrap;
}

    .ps-input::placeholder {
        color: #c0c0d0;
    }

    .ps-input:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

/* Keep run/stop buttons aligned to bottom of the input bar */
.ps-run-btn, .ps-stop-btn {
    align-self: flex-end;
    margin-bottom: 2px;
}

.ps-run-btn {
    width: 32px;
    height: 32px;
    border-radius: 7px;
    border: 1px solid #bae6fd;
    background: #f0f9ff;
    color: #0369a1;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    flex-shrink: 0;
}

    .ps-run-btn:hover:not(:disabled) {
        background: #e0f2fe;
        border-color: #0369a1;
    }

    .ps-run-btn:disabled {
        opacity: 0.35;
        cursor: not-allowed;
    }

.ps-run-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #bae6fd;
    border-top-color: #0369a1;
    border-radius: 50%;
    animation: ps-spin 0.7s linear infinite;
}

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

/* Hint bar */
.ps-hint {
    text-align: center;
    padding: 3px 0 5px;
    font-size: 0.62rem;
    color: #c8c8e0;
    font-family: system-ui, sans-serif;
    flex-shrink: 0;
    background: #ffffff;
}

/* ═══ RIGHT PANEL ════════════════════════════════════════════════════════ */

.ps-right-panel {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background: #ffffff;
    border-left: 1px solid #e8e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ps-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1a1a2e;
    border-bottom: 1px solid #eeeef6;
    background: #fafafa;
    flex-shrink: 0;
}

    .ps-panel-header i {
        color: #0369a1;
        font-size: 0.85rem;
    }

/* Search */
.ps-panel-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #eeeef6;
    flex-shrink: 0;
    background: #ffffff;
}

.ps-panel-search-icon {
    color: #b0b0c8;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.ps-panel-search {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.74rem;
    color: #333348;
    font-family: inherit;
}

    .ps-panel-search::placeholder {
        color: #c8c8e0;
    }

/* Scrollable body */
.ps-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #d0d0e8 transparent;
}

/* ── Quick categories ────────────────────────────────────────────────────── */

.ps-qcat {
    border-bottom: 1px solid #f0f0f8;
}

.ps-qcat-hdr {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 8px 12px;
    background: #fafafa;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: #333348;
    text-align: left;
    transition: background 0.1s;
}

    .ps-qcat-hdr:hover {
        background: #f4f4f8;
    }

.ps-qcat-icon {
    color: #0369a1;
    font-size: 0.78rem;
    flex-shrink: 0;
}

.ps-qcat-caret {
    font-size: 0.5rem;
    color: #c0c0d0;
    margin-left: auto;
}

/* Command list */
.ps-qlist {
    padding: 3px 6px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ps-qcmd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all 0.1s;
    width: 100%;
}

    .ps-qcmd:hover {
        background: #f0f9ff;
        border-color: #bae6fd;
    }

        .ps-qcmd:hover .ps-qcmd-run {
            opacity: 1;
            color: #0369a1;
        }

.ps-qcmd-label {
    font-size: 0.71rem;
    color: #333348;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.ps-qcmd-run {
    font-size: 0.65rem;
    color: #c8c8e0;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.1s;
}

/* ── Stop button ─────────────────────────────────────────────────────────── */

.ps-stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 12px;
    height: 32px;
    border-radius: 7px;
    border: 1px solid #fca5a5;
    background: #fef2f2;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: all 0.12s;
    animation: ps-stop-pulse 1.5s ease-in-out infinite;
}

    .ps-stop-btn:hover {
        background: #dc2626;
        border-color: #dc2626;
        color: #ffffff;
        animation: none;
    }

    .ps-stop-btn i {
        font-size: 0.8rem;
    }

@keyframes ps-stop-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220,38,38,0);
    }

    50% {
        box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
    }
}

/* Cancelled entry style */
.ps-cancelled {
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

/* ── Agent offline pill ──────────────────────────────────────────────────── */

.ps-pill-agent-off {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

    .ps-pill-agent-off .ps-status-dot {
        background: #f59e0b;
        animation: ps-pulse 1s ease-in-out infinite;
    }

/* ── Agent offline banner (above input bar) ──────────────────────────────── */

.ps-agent-offline-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    border-bottom: 1px solid #fde68a;
    font-size: 0.78rem;
    color: #92400e;
    flex-shrink: 0;
}

    .ps-agent-offline-banner i {
        color: #f59e0b;
        font-size: 1rem;
        flex-shrink: 0;
    }

/* ── System line (agent connected/disconnected notices) ──────────────────── */

.ps-system-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 10px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 0.72rem;
    color: #0369a1;
    font-family: system-ui, sans-serif;
}

    .ps-system-line i {
        flex-shrink: 0;
    }

/* ── Improved quick commands panel ──────────────────────────────────────── */

/* Override previous category styles for accordion */
.ps-qcat-hdr {
    padding: 9px 12px;
    font-size: 0.73rem;
    font-weight: 600;
    color: #1a1a2e;
    border-radius: 0;
    letter-spacing: 0.01em;
}

    .ps-qcat-hdr:hover {
        background: #eef2ff;
        color: #4f46e5;
    }

        .ps-qcat-hdr:hover .ps-qcat-icon {
            color: #4f46e5;
        }

.ps-qcat-icon {
    transition: color 0.1s;
}

/* Active (open) category header */
.ps-qcat:has(.ps-qlist) .ps-qcat-hdr {
    background: #f5f3ff;
    color: #5b21b6;
    border-left: 3px solid #7c3aed;
}

    .ps-qcat:has(.ps-qlist) .ps-qcat-hdr .ps-qcat-icon {
        color: #7c3aed;
    }

/* Command list */
.ps-qlist {
    padding: 4px 8px 8px;
    background: #fafafa;
    border-bottom: 1px solid #eeeef6;
}

.ps-qcmd {
    border-radius: 5px;
    padding: 5px 8px;
}

    .ps-qcmd:hover {
        background: #ede9fe;
        border-color: #c4b5fd;
    }

.ps-qcmd-label {
    font-size: 0.7rem;
    color: #333348;
}

.ps-qcmd:hover .ps-qcmd-label {
    color: #5b21b6;
}

.ps-qcmd:hover .ps-qcmd-run {
    opacity: 1;
    color: #7c3aed;
}

/* Disabled quick command when agent is offline */
.ps-qcmd:disabled,
.ps-qcmd[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Quick label badge on command line ───────────────────────────────────── */

.ps-quick-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #5b21b6;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    border-radius: 4px;
    padding: 1px 6px;
    flex-shrink: 0;
    font-family: system-ui, sans-serif;
}

    .ps-quick-badge i {
        font-size: 0.55rem;
    }

/* ── Fix scroll — padding so last entry is never hidden behind input bar ── */

.ps-output {
    padding-bottom: 16px !important;
}

/* ═══════════════════════════════════════════════════════════════════
   AUTO RUN COMMAND TOGGLE
═══════════════════════════════════════════════════════════════════ */

.ps-autorun-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px 6px;
    border-bottom: 1px solid #e8e8f0;
    background: #f9f9fc;
    flex-shrink: 0;
}

.ps-autorun-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #444460;
    user-select: none;
}

.ps-autorun-icon {
    font-size: 0.8rem;
}

.ps-autorun-on .ps-autorun-icon {
    color: #16a34a;
}

.ps-autorun-off .ps-autorun-icon {
    color: #7c3aed;
}

.ps-autorun-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.ps-autorun-state {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    width: 22px;
    text-align: left;
}

.ps-autorun-on .ps-autorun-state {
    color: #16a34a;
}

.ps-autorun-off .ps-autorun-state {
    color: #9090b0;
}

/* Toggle track */
.ps-autorun-track {
    width: 34px;
    height: 18px;
    border-radius: 999px;
    position: relative;
    transition: background 0.18s;
    flex-shrink: 0;
}

.ps-autorun-on .ps-autorun-track {
    background: #16a34a;
}

.ps-autorun-off .ps-autorun-track {
    background: #d0d0e0;
}

/* Toggle knob */
.ps-autorun-knob {
    position: absolute;
    top: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: left 0.18s;
}

.ps-autorun-on .ps-autorun-knob {
    left: 18px;
}

.ps-autorun-off .ps-autorun-knob {
    left: 2px;
}

/* Pencil-mode quick command button */
.ps-qcmd-load {
    background: #faf8ff !important;
    border-color: #c4b5fd !important;
}

    .ps-qcmd-load .ps-qcmd-run {
        color: #7c3aed !important;
    }

    .ps-qcmd-load:hover {
        background: #f0eeff !important;
    }

/* ── Copy response button ─────────────────────────────────────────────── */
.ps-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid #e0e0ec;
    background: transparent;
    color: #9090b8;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
    flex-shrink: 0;
}

    .ps-copy-btn:hover {
        background: #f0eeff;
        border-color: #c4b5fd;
        color: #6d28d9;
    }

    .ps-copy-btn:active {
        background: #ede9fe;
        transform: scale(0.96);
    }

/* ── Line numbers ──────────────────────────────────────────────────────── */

.ps-line-no {
    display: inline-block;
    min-width: 36px;
    text-align: right;
    padding-right: 12px;
    color: #b0b0cc;
    font-size: 0.68rem;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    user-select: none;
    flex-shrink: 0;
    border-right: 1px solid #eeeef6;
    margin-right: 10px;
    line-height: inherit;
}

/* Keep output lines properly flex-aligned with the line number */
.ps-out-line {
    display: flex;
    align-items: flex-start;
}

.ps-line-text {
    flex: 1;
    white-space: pre-wrap;
    word-break: break-all;
}

/* System lines also flex */
.ps-system-line {
    display: flex;
    align-items: center;
}
