/**
 * External Services Panel Styles
 */

/* Services Grid */
.services-header {
    margin-bottom: 2rem;
}

.services-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    line-height: 1.6;
}

.services-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Service Card */
.service-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.service-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.service-card.connected {
    border-left: 4px solid var(--success-color);
}

.service-card.disconnected {
    border-left: 4px solid var(--text-tertiary);
}

.service-card.error {
    border-left: 4px solid var(--danger-color);
}

.service-card.expired {
    border-left: 4px solid var(--warning-color, #f59e0b);
}

.service-card.connected .status-text {
    color: var(--success-color);
    font-weight: 500;
}

.service-card.error .status-text {
    color: var(--danger-color);
    font-weight: 500;
}

.service-card.expired .status-text {
    color: var(--warning-color, #f59e0b);
    font-weight: 500;
}
.service-card-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.service-icon {
    font-size: 2.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.service-info {
    flex: 1;
    min-width: 0;
}

.service-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.service-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-icon {
    font-size: 1rem;
}

.status-text {
    color: var(--text-secondary);
}

.service-card.connected .status-text {
    color: var(--success-color);
    font-weight: 500;
}

.service-card.error .status-text {
    color: var(--danger-color);
    font-weight: 500;
}

/* Service Card Body */
.service-card-body {
    margin-bottom: 1rem;
}

.service-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.service-capabilities,
.service-scopes {
    margin-top: 1rem;
}

.capabilities-title,
.scopes-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.capabilities-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.capabilities-list li {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
    padding-left: 1.25rem;
    position: relative;
}

.capabilities-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: 600;
}

.scopes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.scope-badge {
    display: inline-block;
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Service Card Actions */
.service-card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.service-card-actions button {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-warning {
    background: var(--warning-color, #f59e0b);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-sm {
    flex: 0 0 auto !important;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.8rem !important;
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c62828;
}

/* Error State */
.error-state {
    text-align: center;
    padding: 3rem 2rem;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .services-grid {
        grid-template-columns: 1fr;
    }

    .service-card-actions {
        flex-direction: column;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .service-card {
        background: #1e1e1e;
    }

    .service-card:hover {
        background: #252525;
    }

    .scope-badge {
        background: #2a2a2a;
    }
}

/* ═══════════════════════════════════════════════════════
   Vast.ai GPU Cloud section
   ═══════════════════════════════════════════════════════ */

.vast-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2.5rem;
}

/* ── Status bar ── */
.vast-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    background: var(--secondary-bg);
    border-left: 4px solid var(--border-color);
}
.vast-status-bar.vast-status-running      { border-left-color: var(--success-color); background: color-mix(in srgb, var(--success-color) 8%, var(--secondary-bg)); }
.vast-status-bar.vast-status-provisioning { border-left-color: #f59e0b; background: color-mix(in srgb, #f59e0b 8%, var(--secondary-bg)); }
.vast-status-bar.vast-status-starting     { border-left-color: #60a5fa; background: color-mix(in srgb, #60a5fa 8%, var(--secondary-bg)); }
.vast-status-bar.vast-status-offline      { border-left-color: var(--text-tertiary); }
.vast-status-bar.vast-status-disabled     { border-left-color: var(--text-tertiary); opacity: 0.7; }

.vast-status-pill {
    font-weight: 700;
    font-size: 0.9375rem;
    min-width: 7rem;
}
.vast-meta {
    color: var(--text-secondary);
    white-space: nowrap;
}
.vast-meta b { color: var(--text-primary); font-weight: 600; }

/* ── Badges ── */
.vast-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 99px;
    vertical-align: middle;
    margin-left: 0.25rem;
}
.vast-badge-ok   { background: color-mix(in srgb, var(--success-color) 18%, transparent); color: var(--success-color); border: 1px solid var(--success-color); }
.vast-badge-warn { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #d97706; border: 1px solid #f59e0b; }

/* ── Form layout ── */
.vast-config-form {
    margin-top: 0.5rem;
}
.vast-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1rem;
}
@media (max-width: 900px) {
    .vast-form-row { grid-template-columns: 1fr; }
}
.vast-form-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.vast-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.vast-form-row-inline {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.75rem !important;
    align-items: flex-end;
}
.vast-form-row-inline > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.vast-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.vast-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.vast-input {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.vast-input:focus {
    outline: none;
    border-color: var(--primary-color);
}
.vast-input-sm {
    width: 7rem;
}
.vast-key-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.vast-key-row .vast-input { flex: 1; }
.vast-textarea {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: 'Courier New', monospace;
    width: 100%;
    resize: vertical;
    box-sizing: border-box;
}
.vast-textarea:focus { outline: none; border-color: var(--primary-color); }

/* ── Action row ── */
.vast-action-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}
.vast-action-row button { min-width: 9rem; }
.vast-action-row button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Small buttons ── */
.vast-btn-sm {
    padding: 0.3rem 0.65rem !important;
    font-size: 0.8rem !important;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.vast-btn-sm:hover { background: var(--hover-bg); }
.vast-btn-xs {
    padding: 0.15rem 0.45rem !important;
    font-size: 0.7rem !important;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: 0.4rem;
    vertical-align: middle;
}
.vast-btn-xs:hover { background: var(--hover-bg); }

/* ── GPU Offers panel ── */
.vast-offers-wrap {
    margin-top: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.vast-offers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--secondary-bg);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}
.vast-offers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8375rem;
}
.vast-offers-table th {
    background: var(--secondary-bg);
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.vast-offers-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.vast-offers-table tr:last-child td { border-bottom: none; }
.vast-offers-table tr:hover td { background: var(--hover-bg); }
.vast-offers-table .center { text-align: center; }
.vast-offers-table .price-good { color: var(--success-color); font-weight: 700; }
.vast-offers-table .price-ok   { color: #f59e0b; font-weight: 600; }
.vast-offers-table .price-high { color: var(--danger-color); }

.vast-offers-loading,
.vast-offers-empty,
.vast-offers-error,
.vast-offers-note {
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.vast-offers-error  { color: var(--danger-color); }
.vast-offers-note   { font-size: 0.75rem; color: var(--text-tertiary); border-top: 1px solid var(--border-color); }

/* Vast.ai live inventory table — surfaces ALL instances Vast.ai shows,
   not just the manager-cached one. */
.vast-live-inventory { padding: 0.5rem 1.25rem 1rem 1.25rem; }
.vast-unmanaged-banner {
    background: color-mix(in srgb, #f59e0b 12%, transparent);
    border-left: 3px solid #f59e0b;
    color: #d97706;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.85em;
    font-weight: 600;
}
.vast-live-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82em;
}
.vast-live-table th,
.vast-live-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.vast-live-table th { color: var(--text-secondary); font-weight: 600; }
.vast-live-table tr:last-child td { border-bottom: none; }

/* Phase 1 — per-service routing matrix */
.vast-routing-matrix {
    padding: 0.75rem 1.25rem 0.5rem 1.25rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}
.vast-routing-title { margin: 0 0 6px 0; font-size: 0.95em; color: var(--text-primary); }
.vast-routing-hint  { font-size: 0.78em; color: var(--text-secondary); margin: 0 0 10px 0; }
.vast-routing-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.vast-routing-table th, .vast-routing-table td {
    padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border-color);
}
.vast-routing-table th { color: var(--text-secondary); font-weight: 600; }
.vast-routing-table tr:last-child td { border-bottom: none; }

.vast-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.vast-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.vast-switch-slider {
    position: relative; width: 36px; height: 18px;
    background: rgba(0,0,0,0.4); border-radius: 12px; transition: background 0.2s;
    flex-shrink: 0;
}
.vast-switch-slider::after {
    content: ""; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; background: #ccc; border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.vast-switch input:checked + .vast-switch-slider { background: color-mix(in srgb, var(--success-color) 35%, rgba(0,0,0,0.4)); }
.vast-switch input:checked + .vast-switch-slider::after { transform: translateX(18px); background: var(--success-color); }
.vast-switch-label { font-size: 0.78em; color: var(--text-secondary); min-width: 36px; }

.vast-badge-neutral { background: color-mix(in srgb, #60a5fa 14%, transparent); color: #60a5fa; border: 1px solid #60a5fa55; }

.vast-fallback-section { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border-color); }
.vast-fallback-header  { font-size: 0.82em; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.vast-fallback-list    { display: flex; flex-direction: column; gap: 4px; }
.vast-fallback-row     { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 0.82em; }

/* Rent-Now form */
.vast-rent-now {
    margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-color);
    padding: 12px 1.25rem;
}
.vast-rent-now-title { font-size: 0.85em; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.vast-rent-now-row   { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
