/* ==========================================================================
   Deployment Editor
   ========================================================================== */

.deploy-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px;
}

/* Tabs */
.deploy-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-standard);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.deploy-tabs::-webkit-scrollbar {
    display: none;
}

.deploy-tab {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .deploy-tab {
        padding: 10px 12px;
        font-size: 13px;
    }
}

.deploy-tab:hover {
    color: var(--text-primary);
}

.deploy-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Panels */
.deploy-panel {
    display: block;
}

/* Forms */
fieldset {
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

legend {
    font-weight: 600;
    padding: 0 8px;
    color: var(--text-primary);
}

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-row input,
.form-row select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    background: var(--bg-root);
    color: var(--text-primary);
    font-size: 14px;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-row-2col,
.form-row-3col {
    display: grid;
    gap: 12px;
}

.form-row-2col {
    grid-template-columns: 1fr 1fr;
}

.form-row-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row-checkbox {
    display: flex;
    gap: 24px;
    align-items: center;
}

.form-row-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

/* Env vars editor */
#env-vars-editor {
    margin-bottom: 8px;
}

.env-row {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    gap: 8px;
    margin-bottom: 8px;
}

.env-row .btn-remove {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
}

.env-row .btn-remove:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* Download card */
.download-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 24px;
}

.download-card h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.download-card ul {
    margin: 12px 0;
    padding-left: 20px;
}

.download-card code {
    background: var(--bg-root);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

/* Deploy cards */
.deploy-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.deploy-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 20px;
}

.deploy-card h4 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--text-primary);
}

.deploy-card p {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.deploy-requirements {
    font-size: 12px !important;
    color: var(--text-tertiary) !important;
}

.deploy-result {
    margin-top: 12px;
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
}

/* Status indicators */
.status-inline {
    font-size: 13px;
}
.status-ok {
    color: #22c55e;
}
.status-error {
    color: #ef4444;
}
.status-pending {
    color: var(--text-secondary);
    font-style: italic;
}

.deploy-result .status-ok {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 10px;
    border-radius: 6px;
}
.deploy-result .status-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px;
    border-radius: 6px;
}
.deploy-result .status-pending {
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    padding: 10px;
    border-radius: 6px;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    display: inline-block;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-standard);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Responsive */
@media (max-width: 600px) {
    .form-row-2col,
    .form-row-3col {
        grid-template-columns: 1fr;
    }
    .deploy-cards {
        grid-template-columns: 1fr;
    }
    .env-row {
        grid-template-columns: 1fr 1fr;
    }
    .env-row .btn-remove {
        grid-column: 1 / -1;
        justify-self: end;
    }
    .deploy-tab-link {
        margin-left: 0;
    }
}

/* ==========================================================================
   Credential Management Page
   ========================================================================== */

/* Page heading */
.credentials-header {
    margin-bottom: 24px;
}
.credentials-header h2 {
    margin: 0 0 8px;
    color: var(--text-primary);
}
.credentials-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.credentials-back {
    display: inline-block;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}
.credentials-back:hover {
    text-decoration: underline;
}

/* Cards grid (reuses .deploy-cards and .deploy-card from existing CSS) */

/* Field rows inside credential cards */
.credential-field {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-standard);
}
.credential-field:last-child {
    border-bottom: none;
}
.credential-field-label {
    flex: 0 0 120px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.credential-field-value {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    font-family: monospace;
    word-break: break-all;
}
.credential-masked {
    color: var(--text-tertiary);
    letter-spacing: 2px;
}
.credential-empty {
    color: var(--text-tertiary);
    font-style: italic;
    font-family: inherit;
}
.credential-field-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    margin-left: 12px;
}
.credential-field-actions button {
    padding: 4px 10px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
}
.credential-field-actions .btn-edit:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.credential-field-actions .btn-delete:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* Inline edit form */
.credential-edit-form {
    display: none;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-standard);
}
.credential-edit-form.active {
    display: flex;
    align-items: center;
    gap: 8px;
}
.credential-edit-form input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    background: var(--bg-root);
    color: var(--text-primary);
    font-size: 14px;
    font-family: monospace;
}
.credential-edit-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.credential-edit-form .btn-save-field {
    padding: 8px 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.credential-edit-form .btn-save-field:hover {
    background: var(--accent-hover);
}
.credential-edit-form .btn-cancel-field {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}
.credential-edit-form .btn-cancel-field:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Field status message */
.credential-status {
    font-size: 12px;
    margin-top: 4px;
}

/* Save/Clear result messages (reuse .status-ok, .status-error from existing CSS) */

/* Responsive */
@media (max-width: 600px) {
    .credential-field {
        flex-wrap: wrap;
    }
    .credential-field-label {
        flex: 0 0 100%;
        margin-bottom: 4px;
    }
    .credential-edit-form.active {
        flex-wrap: wrap;
    }
    .credential-edit-form input {
        flex: 0 0 100%;
    }
}

/* Tab link (opens external page) */
.deploy-tab-link {
    text-decoration: none;
    margin-left: auto;
    opacity: 0.7;
    font-size: 13px;
}
.deploy-tab-link:hover {
    opacity: 1;
    color: var(--accent);
}

/* ==========================================================================
   Alpine.js Transitions & WCAG Additions
   ========================================================================== */

/* 1. Alpine.js transition classes for x-transition directives */
.deploy-panel-transition {
    transition: opacity 0.2s ease, transform 0.15s ease;
}
.deploy-panel-enter {
    opacity: 0;
    transform: translateY(-4px);
}
.deploy-panel-leave {
    opacity: 0;
    position: absolute;
}

.env-row-transition {
    transition: all 0.15s ease;
}
.env-row-enter {
    opacity: 0;
    transform: translateX(-8px);
}

.deploy-result-transition {
    transition: opacity 0.2s ease;
}
.deploy-result-enter {
    opacity: 0;
}

/* 2. Credential page Alpine-ready enhancements */
.credential-status.status-pending {
    color: var(--accent);
    font-style: italic;
}

/* 3. Save status indicator inline transition for Configure tab */
.status-inline {
    transition: opacity 0.2s ease;
}

/* 4. Reduced motion: WCAG 2.2 AA AD-4 */
@media (prefers-reduced-motion: reduce) {
    .deploy-panel-transition,
    .env-row-transition,
    .deploy-result-transition,
    .status-inline {
        transition: none !important;
    }
}

/* 5. Focus management: visible focus rings for Alpine-managed elements */
.deploy-tab:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 6. Deploy card loading state */
.deploy-card.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* 7. Responsive: .env-row grid on small screens */
@media (max-width: 480px) {
    .env-row {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Platform Info Card (shown after selecting a platform)
   ========================================================================== */

.platform-info-card {
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg-surface);
}

.platform-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.platform-info-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.platform-category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.platform-summary {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.5;
}

.platform-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.platform-meta-row strong {
    color: var(--text-secondary);
}

.platform-warnings {
    margin-top: 8px;
}

.platform-warning-item {
    font-size: 12px;
    color: #f59e0b;
    padding: 4px 0;
    line-height: 1.4;
}

.platform-artifacts {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.platform-artifacts code {
    background: var(--bg-root);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 4px;
    color: var(--text-secondary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.field-help {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ==========================================================================
   Platform Library (new platform registry UI)
   ========================================================================== */

.platform-library-section {
    margin-bottom: 24px;
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-surface);
}

.platform-library-section h3 {
    margin: 0 0 12px;
    color: var(--text-primary);
}

.platform-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.platform-search-bar input,
.platform-search-bar select {
    padding: 8px 10px;
    border: 1px solid var(--border-standard);
    border-radius: 4px;
    background: var(--bg-root);
    color: var(--text-primary);
    font-size: 13px;
}

.platform-search-bar input {
    flex: 1;
}

.platform-search-bar select {
    flex: 0 0 180px;
}

.platform-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.platform-card {
    border: 1px solid var(--border-standard);
    border-radius: 6px;
    padding: 12px;
    background: var(--bg-root);
    transition: border-color 0.15s;
}

.platform-card:hover {
    border-color: var(--accent);
}

.platform-card--selected {
    border-color: var(--accent);
    background: rgba(34, 197, 94, 0.05);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.platform-card--recommended {
    border-left: 3px solid var(--accent);
}

.platform-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.platform-card__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.platform-card__summary {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 8px;
    line-height: 1.4;
}

.platform-card__meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.platform-card__meta span {
    background: var(--bg-surface);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge--sm { font-size: 9px; }

.badge--accent {
    background: var(--accent);
    color: #000;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ==========================================================================
   Validation Panel
   ========================================================================== */

.validation-results {
    margin-top: 16px;
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 16px;
    background: var(--bg-surface);
}

.validation-score {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-standard);
}

.validation-group {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 6px;
}

.validation-group h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.validation-group ul {
    margin: 0;
    padding-left: 20px;
}

.validation-group li {
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.4;
}

.validation-group--blocking {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.validation-group--blocking h4 {
    color: #ef4444;
}

.validation-group--warning {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.validation-group--warning h4 {
    color: #f59e0b;
}

.validation-group--info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.validation-group--info h4 {
    color: #3b82f6;
}

/* ==========================================================================
   Artifact Preview
   ========================================================================== */

.artifact-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 16px;
    margin-top: 16px;
    min-height: 400px;
}

.artifact-file-list {
    border: 1px solid var(--border-standard);
    border-radius: 6px;
    padding: 12px;
    background: var(--bg-surface);
    overflow-y: auto;
    max-height: 500px;
}

.artifact-file-list h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.artifact-file-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.artifact-file-list li {
    margin-bottom: 2px;
}

.artifact-file-btn {
    display: block;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    font-family: monospace;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

.artifact-file-btn:hover {
    background: var(--bg-root);
}

.artifact-file-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.artifact-preview-pane {
    border: 1px solid var(--border-standard);
    border-radius: 6px;
    background: var(--bg-root);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.artifact-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-standard);
}

.artifact-file-header code {
    font-size: 13px;
    color: var(--text-primary);
}

.artifact-code {
    flex: 1;
    margin: 0;
    padding: 12px;
    overflow: auto;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-root);
    max-height: 450px;
}

.artifact-code code {
    font-family: inherit;
    font-size: inherit;
}

/* Responsive: artifact layout */
@media (max-width: 768px) {
    .artifact-layout {
        grid-template-columns: 1fr;
    }
    .platform-cards-grid {
        grid-template-columns: 1fr;
    }
    .platform-search-bar {
        flex-direction: column;
    }
    .platform-search-bar select {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .platform-card,
    .artifact-file-btn {
        transition: none;
    }
}
