/**
 * BSV Desktop UI Styles
 * Styles for BSV Desktop Endpoint Management Dialog
 */

/* Status Bar */
.bsv-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: 8px;
}

.bsv-status-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bsv-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.bsv-status-dot.online {
    background: #28a745;
}

.bsv-status-dot.offline {
    background: #dc3545;
}

/* URL Section */
.bsv-url-section {
    margin-bottom: 16px;
}

.bsv-url-label {
    display: block;
    margin-bottom: 4px;
}

.bsv-url-hint {
    display: block;
    margin-top: 4px;
}

/* Endpoints Container */
.bsv-endpoints-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 16px;
}

/* Endpoints Table */
.bsv-endpoints-table {
    width: 100%;
    border-collapse: collapse;
}

.bsv-endpoints-table thead tr {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.bsv-endpoints-table th {
    padding: 8px;
    text-align: left;
    font-size: 12px;
}

.bsv-endpoints-table th.center {
    text-align: center;
}

.bsv-endpoints-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.bsv-endpoints-table tbody tr.even {
    background: var(--bg);
}

.bsv-endpoints-table td {
    padding: 8px;
    font-size: 12px;
}

.bsv-endpoints-table td.number {
    width: 40px;
    text-align: right;
    padding-right: 8px;
    color: var(--muted);
    font-size: 11px;
}

.bsv-endpoints-table td.category {
    color: var(--accent);
}

.bsv-endpoints-table td.method {
    font-family: monospace;
}

.bsv-endpoints-table td.path {
    font-family: monospace;
    font-size: 11px;
    color: var(--muted);
}

.bsv-endpoints-table td.action {
    text-align: center;
}

/* Dialog Content Override */
.bsv-dialog-content {
    width: 900px;
    max-width: 95vw;
}

/* Title Container with GitHub Link */
.bsv-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.bsv-title-container h3 {
    margin: 0;
}

.bsv-github-link {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.2s;
}

.bsv-github-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.bsv-github-link small {
    font-size: 12px;
}

/* Parameter Dialog */
.bsv-param-dialog .dialog-content {
    width: 500px;
    max-width: 90vw;
}

.bsv-endpoint-info {
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
}

.bsv-param-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.bsv-param-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bsv-param-label {
    font-size: 13px;
    font-weight: 500;
}

.bsv-param-label.required::after {
    content: ' *';
    color: #dc3545;
}

.bsv-param-hint {
    font-size: 11px;
    line-height: 1.4;
}

.bsv-param-checkbox {
    width: auto;
    height: 20px;
    cursor: pointer;
}

/* Result Dialog */
.bsv-result-dialog .dialog-content {
    width: 600px;
    max-width: 90vw;
}

.bsv-result-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 16px;
    background: var(--bg);
    border-radius: 8px;
    padding: 16px;
}

.bsv-result-json {
    margin: 0;
    padding: 0;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Babbage Auth UI */
.bsv-auth-progress {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.bsv-auth-progress.hidden {
    display: none;
}

.bsv-auth-step {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
}

.bsv-auth-info {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
}

.bsv-auth-info p {
    margin: 8px 0;
    font-size: 13px;
}

.bsv-auth-info code {
    font-family: monospace;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Certificate Viewer */
.bsv-cert-viewer .dialog-content {
    width: 700px;
    max-width: 90vw;
}

.bsv-cert-info-section {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(33, 150, 243, 0.1);
    border-left: 3px solid #2196f3;
    border-radius: 4px;
}

.bsv-cert-empty-section {
    text-align: center;
    padding: 24px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 16px;
}

.bsv-cert-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.bsv-cert-empty-section h4 {
    margin: 8px 0;
    font-size: 16px;
}

.bsv-cert-coolcert-info {
    margin-top: 24px;
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: left;
}

.bsv-cert-coolcert-info h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #2196f3;
}

.bsv-cert-howto {
    margin: 16px 0;
    padding: 12px;
    background: rgba(76, 175, 80, 0.05);
    border-left: 3px solid #4caf50;
    border-radius: 4px;
}

.bsv-cert-howto strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.bsv-cert-howto ol {
    margin: 8px 0 0 20px;
    padding: 0;
}

.bsv-cert-howto li {
    margin: 6px 0;
    font-size: 13px;
}

.bsv-cert-howto a {
    color: #2196f3;
    text-decoration: none;
}

.bsv-cert-howto a:hover {
    text-decoration: underline;
}

.bsv-cert-manual-acquire {
    margin: 16px 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

.bsv-cert-manual-acquire strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.bsv-cert-code {
    margin: 8px 0 0 0;
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.bsv-cert-links {
    margin: 16px 0 0 0;
    padding: 12px;
    background: rgba(255, 152, 0, 0.05);
    border-left: 3px solid #ff9800;
    border-radius: 4px;
}

.bsv-cert-links strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
}

.bsv-cert-links ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.bsv-cert-links li {
    margin: 6px 0;
    font-size: 13px;
}

.bsv-cert-links a {
    color: #2196f3;
    text-decoration: none;
}

.bsv-cert-links a:hover {
    text-decoration: underline;
}

.bsv-cert-list {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.bsv-cert-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 3px solid var(--accent);
}

.bsv-cert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.bsv-cert-number {
    color: var(--muted);
    font-size: 11px;
    font-weight: bold;
    width: 30px;
}

.bsv-cert-type {
    font-weight: 500;
    font-size: 14px;
    color: var(--accent);
}

.bsv-cert-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bsv-cert-row {
    display: flex;
    gap: 8px;
    font-size: 12px;
}

.bsv-cert-label {
    font-weight: 500;
    min-width: 80px;
    font-size: 12px;
}

.bsv-cert-value {
    font-family: monospace;
    font-size: 11px;
    word-break: break-all;
}

.bsv-cert-fields {
    margin-top: 4px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.bsv-cert-field-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.bsv-cert-field-key {
    font-weight: 500;
    min-width: 100px;
    color: var(--muted);
}

.bsv-cert-field-value {
    font-family: monospace;
    font-size: 11px;
}

.bsv-cert-keyring-note {
    margin-top: 8px;
    padding: 6px;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 4px;
}

.bsv-cert-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* Network Discovery Dialog */
.bsv-network-dialog .dialog-content {
    width: 700px;
    max-width: 95vw;
}

.bsv-network-current {
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.bsv-network-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.bsv-network-info-row:last-child {
    margin-bottom: 0;
}

.bsv-network-info-row strong {
    min-width: 100px;
}

.bsv-network-info-row code {
    font-family: monospace;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.bsv-network-info-row .status-online {
    color: #28a745;
    font-weight: 500;
}

.bsv-network-info-row .status-offline {
    color: #dc3545;
    font-weight: 500;
}

.bsv-pubkey {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bsv-network-section {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg);
    border-radius: 8px;
}

.bsv-network-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
}

.bsv-scan-results {
    min-height: 40px;
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.bsv-found-hosts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.bsv-host-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.bsv-host-card strong {
    font-family: monospace;
    font-size: 13px;
}

/* Connection Pop-up (Auto-connect on start) */
.bsv-connection-popup {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

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

.bsv-connection-popup.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.bsv-popup-content {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    min-width: 320px;
    max-width: 400px;
    color: #212529;
}

.bsv-popup-content.warning {
    border-left: 4px solid #ff9800;
    background: #fff3cd;
}

.bsv-popup-icon {
    font-size: 32px;
    text-align: center;
    margin-bottom: 8px;
}

.bsv-popup-content h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    text-align: center;
    color: #212529;
    font-weight: 600;
}

.bsv-popup-info {
    margin-bottom: 12px;
    font-size: 13px;
    color: #495057;
}

.bsv-popup-info div {
    margin-bottom: 6px;
}

.bsv-popup-info p {
    color: #495057;
    margin: 6px 0;
}

.bsv-popup-info strong {
    min-width: 80px;
    display: inline-block;
    color: #212529;
}

.bsv-popup-info code {
    font-family: monospace;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    color: #212529;
}

/* Public Key Container */
.bsv-pubkey-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
}

.bsv-pubkey-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px;
    border-radius: 4px;
}

.bsv-popup-pubkey {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 11px;
    word-break: break-all;
    line-height: 1.4;
    color: #212529;
}

/* Copy button in public key row */
.bsv-pubkey-row button {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 14px;
    min-width: 40px;
}

.bsv-popup-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.bsv-popup-content button {
    margin: 0;
}

/* =============================================================================
   RESPONSIVE BSV DESKTOP DIALOGS
   ============================================================================= */

/* Tablet and below */
@media (max-width: 1024px) {
    .bsv-dialog-content {
        width: 95vw;
        max-width: 95vw;
    }

    .bsv-network-dialog .dialog-content {
        width: 95vw;
        max-width: 95vw;
    }

    .bsv-cert-viewer .dialog-content {
        width: 95vw;
        max-width: 95vw;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Endpoints Table - Horizontal Scroll */
    .bsv-endpoints-container {
        max-height: 300px;
        overflow-x: auto;
    }

    .bsv-endpoints-table {
        font-size: 11px;
    }

    .bsv-endpoints-table th,
    .bsv-endpoints-table td {
        padding: 6px 4px;
        font-size: 11px;
    }

    .bsv-endpoints-table td.path {
        font-size: 10px;
    }

    /* Connection Popup - Adjust for mobile */
    .bsv-connection-popup {
        top: 60px;
        right: 10px;
        left: 10px;
    }

    .bsv-popup-content {
        min-width: auto;
        max-width: 100%;
    }

    /* Parameter Dialog - Full width on mobile */
    .bsv-param-dialog .dialog-content {
        width: 95vw;
        max-width: 95vw;
    }

    /* Result Dialog - Full width on mobile */
    .bsv-result-dialog .dialog-content {
        width: 95vw;
        max-width: 95vw;
    }

    .bsv-result-container {
        max-height: 300px;
    }

    .bsv-result-json {
        font-size: 11px;
    }

    /* Certificate Viewer - Stack layout */
    .bsv-cert-card {
        font-size: 12px;
    }

    .bsv-cert-value {
        font-size: 10px;
    }

    /* Network Discovery - Stack inputs */
    .bsv-network-section {
        padding: 12px;
    }

    .bsv-scan-results {
        min-height: 30px;
    }

    /* GitHub Link - Smaller on mobile */
    .bsv-github-link small {
        font-size: 11px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .bsv-dialog-content {
        padding: 16px;
    }

    .bsv-title-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bsv-endpoints-table th,
    .bsv-endpoints-table td {
        padding: 4px 2px;
        font-size: 10px;
    }

    .bsv-connection-popup {
        top: 50px;
    }

    .bsv-popup-content h4 {
        font-size: 14px;
    }

    .bsv-popup-info {
        font-size: 12px;
    }

    .bsv-popup-buttons {
        flex-direction: column;
    }

    .bsv-popup-buttons button {
        width: 100%;
    }
}
