/* Pixometry WebAdmin Styles */

body {
    background-color: #f5f5f5;
    min-height: 100vh;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

.login-card {
    width: 400px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.login-card .card-header {
    background: #2c3e50;
    color: white;
    text-align: center;
    border-radius: 12px 12px 0 0;
    padding: 1.5rem;
}

/* Navbar */
.text-muted-light {
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    font-weight: 400;
}

/* Channel Overview */
.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.channel-card {
    border-radius: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    border: 2px solid transparent;
}

.channel-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.channel-card.active {
    border-left: 4px solid #5b9a6f;
}

.channel-card.standby {
    border-left: 4px solid #b07070;
    opacity: 0.75;
}

.channel-card .card-body {
    padding: 1rem;
    /* Anchor for absolute children: top-right activity badge + bottom-right
       card-actions both anchor against this. Extra bottom padding leaves
       breathing room above the always-visible action icons so the drop-hint
       doesn't visually crash into them. */
    position: relative;
    padding-bottom: 2.4rem;
}

.channel-type-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Muted, professional channel type colors */
.type-processing { background-color: #4a7c9b; color: #fff; }
.type-routing    { background-color: #8b7355; color: #fff; }
.type-purge      { background-color: #9b5b5b; color: #fff; }
.type-devicelink { background-color: #6b7b8d; color: #fff; }
.type-cropping   { background-color: #5b8a6f; color: #fff; }

/* Channel Groups */
.channel-group-header {
    padding: 0.6rem 1rem;
    background: #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
}

.channel-group-header:hover {
    background: #dee2e6;
}

/* Group action buttons */
.group-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.channel-group-header:hover .group-actions {
    opacity: 1;
}

.btn-group-action {
    background: none;
    border: 1px solid #bbb;
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    color: #555;
    font-size: 0.82rem;
    line-height: 1;
    transition: all 0.15s;
}

.btn-group-action:hover {
    background: #fff;
    color: #2c3e50;
    border-color: #999;
}

.btn-group-action-danger:hover {
    background: #f8d7da;
    color: #9b5b5b;
    border-color: #d4a0a0;
}

.btn-group-action-create:hover {
    background: #d4edda;
    color: #5b8a6f;
    border-color: #8aba9a;
}

/* Modal overlay */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog-centered {
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Channel Config */
.config-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

.config-sidebar {
    width: 240px;
    min-width: 240px;
    overflow-wrap: anywhere;
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    overflow-y: auto;
}

.config-sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.5rem 1rem;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

.config-sidebar .nav-link:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}

.config-sidebar .nav-link.active {
    color: white;
    border-left-color: #3498db;
    background: rgba(255,255,255,0.1);
}

.config-sidebar .nav-link-child {
    padding-left: 2rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.45);
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.config-sidebar .nav-link-child:hover {
    color: rgba(255,255,255,0.8);
}

.config-sidebar .nav-link-child.active {
    color: white;
    border-left-color: #5ba3d9;
    background: rgba(255,255,255,0.08);
}

/* nav-section removed - flat menu without section headers */

.config-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.config-content .form-label {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Toolbar */
.toolbar {
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Status indicator */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background-color: #5b9a6f; }
.status-dot.standby { background-color: #b07070; }

/* Card action buttons — always visible but subtle (opacity 0.45) so new
   users discover the card is editable without having to hover. Promotes
   to full opacity on card hover. Anchored bottom-right of card body so
   it doesn't compete with the activity badge in the top-right corner. */
.card-actions {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    gap: 2px;
    opacity: 0.45;
    transition: opacity 0.15s;
}

.channel-card:hover .card-actions {
    opacity: 1;
}

.btn-card-action {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    color: #6b7b8d;
    font-size: 0.8rem;
    line-height: 1;
    transition: all 0.15s;
}

.btn-card-action:hover {
    background: #e9ecef;
    color: #2c3e50;
    border-color: #adb5bd;
}

.btn-card-action-standby:hover {
    background: #fff3cd;
    color: #8b7355;
    border-color: #c5b08a;
}

.btn-card-action-activate:hover {
    background: #d4edda;
    color: #5b8a6f;
    border-color: #8aba9a;
}

.btn-card-action-danger:hover {
    background: #f8d7da;
    color: #9b5b5b;
    border-color: #d4a0a0;
}

/* Drop hint */
.drop-hint {
    text-align: center;
    font-size: 0.72rem;
    color: #adb5bd;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #dee2e6;
}

/* Drag channel to group */
.channel-group-header.drag-over-group {
    background: #d4edda;
    border: 2px dashed #5b8a6f;
}

/* Drag & drop active state */
.channel-card.drag-over {
    border: 2px dashed #4a7c9b !important;
    background-color: rgba(74, 124, 155, 0.05);
    transform: translateY(-2px);
}

.channel-card.drag-over .drop-hint {
    color: #4a7c9b;
    font-weight: 600;
}

.check-status-link {
    /* Legacy — replaced by .card-activity rows below. Kept harmlessly in case
       any older view ever re-renders it; can be removed once we're sure all
       call sites are gone. */
    display: block;
    text-align: center;
    font-size: 0.72rem;
    color: #0d6efd;
    margin-top: 0.35rem;
    text-decoration: none;
}
.check-status-link:hover {
    text-decoration: underline;
}

/* Channel-card activity badge — pill-shaped button top-right of each card.
   Single-glance signal: colored dot + count of jobs on that channel +
   arrow indicating "this leads somewhere" (→ Results page). Hidden when
   no activity. Three colour states: progress (orange), ready (green),
   failed (red); failed takes priority over ready over progress. See
   ChannelCard.badgeInfo for the state-resolution logic. */
.card-badge {
    /* Absolute top-right of the card body — fixed anchor so the badge sits
       in the same spot regardless of card-actions visibility (hover state)
       or title length. Sits on top of normal card content but above the
       drop-zone overlay (z-index nudge). */
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 2px 8px 2px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    transition: transform 100ms ease-out, box-shadow 100ms ease-out, background-color 100ms ease-out;
    /* Reset button-element defaults */
    background: #fff;
    color: #212529;
}
.card-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.card-badge:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.card-badge:focus-visible { outline: 2px solid #86b7fe; outline-offset: 2px; }

.card-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.card-badge-count { font-variant-numeric: tabular-nums; }
.card-badge-arrow {
    font-size: 0.7rem;
    opacity: 0.65;
    transition: transform 120ms ease-out;
}
.card-badge:hover .card-badge-arrow { transform: translateX(2px); opacity: 1; }

/* State variants — dot colour signals urgency at a glance. */
.card-badge-progress { background: #fff7e6; border-color: #ffd591; color: #874d00; }
.card-badge-progress .card-badge-dot { background: #faad14; }

.card-badge-ready    { background: #f0fbf3; border-color: #b7e4c7; color: #1b5e20; }
.card-badge-ready    .card-badge-dot { background: #2e7d32; }

.card-badge-failed   { background: #fdecea; border-color: #f5c2c0; color: #842029; }
.card-badge-failed   .card-badge-dot { background: #d33b3b; }

/* Segmented control used on Results (Downloads) page to switch between
   "My uploads", "Team uploads", "API uploads". Light, modern, less visual
   noise than Bootstrap's stock nav-tabs. */
.results-segment {
    display: inline-flex;
    background: #eef1f4;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.results-segment-btn {
    appearance: none;
    background: transparent;
    border: 0;
    color: #6c757d;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.results-segment-btn:hover {
    color: #212529;
}
.results-segment-btn.active {
    background: #ffffff;
    color: #212529;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.results-segment-btn:focus-visible {
    outline: 2px solid #86b7fe;
    outline-offset: 1px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 10000;
}

.toast-message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease;
}

.toast-success { background-color: #5b8a6f; }
.toast-error { background-color: #9b5b5b; }
.toast-info { background-color: #4a6c8c; }   /* neutral blue — used for one-time hints */

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Config view drop zone (view-only / trial users) */
.config-drop-zone {
    border: 2px dashed #adb5bd;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    text-align: center;
    color: #6c757d;
    font-size: 0.88rem;
    transition: all 0.2s;
}
.config-drop-zone a {
    color: #4a7c9b;
    text-decoration: underline;
}
.config-drop-zone-active,
.config-drop-zone:hover {
    border-color: #4a7c9b;
    background: rgba(74, 124, 155, 0.05);
    color: #4a7c9b;
}

/* Import drop zone */
.import-zone {
    border: 2px dashed #adb5bd;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: #6c757d;
    transition: all 0.2s;
    cursor: default;
}

.import-zone-active,
.import-zone:hover {
    border-color: #4a7c9b;
    background: rgba(74, 124, 155, 0.05);
    color: #4a7c9b;
}

.import-browse-link {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
}

.import-browse-link:hover {
    color: #2c3e50;
}

/* Image Enhancement panel */
.ie-panel { display: flex; flex-direction: column; gap: 0.6rem; }
.ie-row { display: flex; align-items: center; gap: 0.75rem; }
.ie-label { width: 240px; min-width: 240px; }
.ie-slider { width: 250px; min-width: 250px; max-width: 250px; margin: 0; }
.ie-num { width: 90px !important; min-width: 90px; max-width: 90px; text-align: center; }
.ie-num::placeholder { font-size: 0.78rem; color: #6c757d; }

/* Selective Color Change table */
.sc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.sc-table thead {
    border-bottom: 2px solid #dee2e6;
}

.sc-th {
    padding: 0.4rem 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    color: #6c757d;
    white-space: nowrap;
}

.sc-th-color {
    padding: 0.4rem 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    color: #6c757d;
    width: 120px;
}

.sc-th-mode {
    width: 110px;
}

.sc-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.sc-table tbody tr:hover {
    background: #f8f9fa;
}

.sc-row-active {
    background: #f0f7ff !important;
}

.sc-color-cell {
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    white-space: nowrap;
}

.sc-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.sc-val {
    width: 70px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.25rem 0.3rem;
    font-size: 0.85rem;
    background: #fff;
}

.sc-val:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 2px rgba(13,110,253,0.15);
}

.sc-zero {
    color: #ccc;
}

.sc-mode-cell {
    padding: 0.3rem 0.5rem;
}

.sc-mode-select {
    font-size: 0.8rem !important;
    padding: 0.2rem 1.8rem 0.2rem 0.4rem !important;
    border-color: #dee2e6;
}

/* Curve Editor */
.curve-editor {
    display: inline-block;
    max-width: 320px;
}

.curve-svg {
    width: 300px;
    height: 300px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    cursor: crosshair;
    user-select: none;
}

.curve-bg {
    fill: #fafafa;
    stroke: #dee2e6;
    stroke-width: 1;
}

.curve-grid {
    stroke: #eee;
    stroke-width: 0.5;
    stroke-dasharray: 4 4;
}

.curve-identity {
    stroke: #ddd;
    stroke-width: 1;
    stroke-dasharray: 6 4;
    fill: none;
}

.curve-point {
    cursor: grab;
    stroke: #fff;
    stroke-width: 2;
    opacity: 0.9;
    transition: r 0.1s;
}

.curve-point:hover {
    r: 8;
    opacity: 1;
}

.curve-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.curve-hint {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 2px;
}

.curve-axis-label {
    font-size: 9px;
    fill: #adb5bd;
}

.curve-readout {
    font-size: 11px;
    fill: #495057;
    font-weight: 600;
    font-family: monospace;
}

/* Routing pane */
.routing-dest .form-check-label.fw-semibold { font-size: 0.9rem; }
.routing-pane .card-header { background: #f8f9fa; }
.routing-pane .badge { font-size: 0.75rem; }

/* Channel picker */
.ch-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    margin-top: 2px;
}

.ch-picker-list {
    max-height: 260px;
    overflow-y: auto;
}

.ch-picker-item {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.ch-picker-item:hover,
.ch-picker-active {
    background: #e9ecef;
}

.ch-picker-selected {
    font-weight: 600;
    color: #0d6efd;
}

/* AI Assistant Panel */
.ai-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.ai-panel-open {
    right: 0;
}

.ai-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #212529;
    color: #fff;
    flex-shrink: 0;
}

.ai-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.ai-panel-input {
    padding: 12px;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}

.ai-panel-input textarea {
    resize: none;
    font-size: 0.875rem;
}

.ai-msg {
    margin-bottom: 12px;
}

.ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 95%;
}

.ai-msg-user-bubble {
    background: #0d6efd;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.ai-msg-ai-bubble {
    background: #f1f3f5;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.ai-msg-error .ai-msg-ai-bubble {
    background: #fde8e8;
    color: #c0392b;
}

.ai-msg-system {
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    padding: 4px;
}

.ai-code {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    overflow-x: auto;
    margin: 6px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.ai-msg-ai-bubble code {
    background: #dee2e6;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* Typing animation */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-typing span {
    width: 8px;
    height: 8px;
    background: #adb5bd;
    border-radius: 50%;
    animation: ai-dot 1.4s infinite ease-in-out;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Loading spinner */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Processing log */
.log-row td { background: #1a1a2e !important; }
.processing-log {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 12px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
}
.log-entry {
    display: flex;
    gap: 12px;
    color: #c8c8d0;
}
.log-ts {
    color: #6c6c80;
    white-space: nowrap;
    flex-shrink: 0;
}
.log-msg { color: #e0e0e8; }

/* ── Placeholder text — lighter than typed values ────────────────────
   Bootstrap's default placeholder colour is rgba(33,37,41,0.5) → looks
   close enough to typed text that you have to squint to see "is this
   already set?". We use a noticeably lighter grey (#b8bdc4) so a glance
   tells you "field is empty, this is a hint". Applied to all input/
   textarea/select-search placeholders globally. */
.form-control::placeholder,
.form-control-sm::placeholder,
input::placeholder,
textarea::placeholder {
    color: #b8bdc4;
    opacity: 1; /* override Firefox's default of 0.54 */
}
/* Keep the small-font ie-num override (it sets its own size); just
   lighten its colour to match the rest. */
.ie-num::placeholder { color: #b8bdc4; }

/* Legal documents (Terms of Service inline-rendered HTML).
   Pandoc emits clean but unstyled HTML; these rules give it readable
   typography that matches the rest of the app without depending on
   any particular markdown→HTML converter version. */
.legal-body { font-size: 0.95rem; color: #333; }
.legal-body h1 { font-size: 1.6rem; margin: 1.5rem 0 0.75rem; }
.legal-body h2 { font-size: 1.3rem; margin: 1.75rem 0 0.5rem; padding-top: 0.5rem;
                 border-top: 1px solid #eee; }
.legal-body h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.legal-body h4 { font-size: 1rem;   margin: 1rem 0 0.4rem; font-weight: 600; }
.legal-body p { line-height: 1.65; margin-bottom: 0.85rem; }
.legal-body ul, .legal-body ol { line-height: 1.65; margin-bottom: 0.85rem;
                                  padding-left: 1.5rem; }
.legal-body li { margin-bottom: 0.25rem; }
.legal-body a { color: #0d6efd; text-decoration: underline; }
.legal-body a:hover { color: #0a58ca; }
.legal-body strong { font-weight: 600; }
.legal-body em { font-style: italic; }
.legal-body code { background: #f6f8fa; padding: 0.1em 0.3em; border-radius: 3px;
                   font-size: 0.88em; }
.legal-body blockquote { border-left: 3px solid #ddd; padding-left: 1rem;
                          color: #555; margin: 0.85rem 0; }
/* If pandoc emits tables (rare in plain-text-heavy ToS, but possible) — keep
   them readable. For table-heavy documents we use the PDF landing-page
   pattern instead, see DpaView/SubProcessorsView/PrivacyView. */
.legal-body table { width: 100%; margin: 1rem 0; border-collapse: collapse;
                     font-size: 0.9rem; }
.legal-body th, .legal-body td { border: 1px solid #dee2e6; padding: 0.5rem 0.6rem;
                                  text-align: left; vertical-align: top; }
.legal-body th { background: #f8f9fa; font-weight: 600; }
/* Footnotes (pandoc emits <section class="footnotes">). */
.legal-body .footnotes { margin-top: 2rem; padding-top: 1rem;
                          border-top: 1px solid #ddd; font-size: 0.85rem;
                          color: #666; }
.legal-body .footnotes ol { padding-left: 1.25rem; }
.legal-body sup a { text-decoration: none; }
