/* Buttons */
button {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent);
    color: var(--bg-dark);
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover { background: var(--accent-dim); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 12px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: transparent; }

.btn-small {
    width: auto;
    padding: 14px 24px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-mini {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.3);
}

.back-link {
    display: block;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 16px;
    cursor: pointer;
    transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}
.message.error {
    display: block;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: var(--error);
}
.message.success {
    display: block;
    background: var(--bg-copied);
    border: 1px solid rgba(0, 212, 170, 0.3);
    color: var(--success);
}
.message.warning {
    display: block;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}
.message.info {
    display: block;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

/* Spinner */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    margin-right: 8px;
}

.btn-loading > svg {
    display: none;
}

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* Modal Styles */
body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 440px;
    transform: scale(0.9);
    transition: transform 0.2s ease;
}
.modal-overlay.active .modal {
    transform: scale(1);
}
.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.build-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.build-spinner-wrap {
    position: relative;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.build-spinner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
}

/* Full white ring — bottom layer */
.build-spinner--outer {
    border-color: #fff;
    z-index: 1;
    animation: build-spin 1.2s linear infinite;
}

/* Half-arc in modal background colour — top layer, spins faster to mask/unmask the white */
.build-spinner--inner {
    border-top-color: var(--bg-card);
    border-right-color: var(--bg-card);
    z-index: 2;
    animation: build-spin 0.85s linear infinite;
}

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

.build-title-x {
    width: 20px;
    height: 20px;
    stroke: var(--error);
}

.build-title-check {
    width: 20px;
    height: 20px;
    stroke: var(--success);
}
.modal-desc {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}
.modal-warning-list {
    margin: 0 0 24px 0;
    padding-left: 20px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.8;
}
.modal-warning-list li {
    margin-bottom: 4px;
}

/* Regenerate Password Success Section */
.regenerate-result-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.regenerate-result-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.regenerate-result-label {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 500;
}

.regenerate-result-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.regenerate-result-password {
    flex: 1;
    font-family: var(--font-mono), 'monospace';
    font-size: 16px;
    color: var(--success);
    background: var(--bg-dark);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--success);
    word-break: break-all;
}

.regenerate-result-connstr {
    flex: 1;
    font-family: var(--font-mono), 'monospace';
    font-size: 11px;
    color: var(--text);
    background: var(--bg-dark);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    word-break: break-all;
    max-height: 80px;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.modal-actions button {
    flex: 1;
    width: auto;
    height: auto;
    padding: 14px 24px;
}
.modal-actions .btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 0;
}
.modal-actions .btn-secondary:hover {
    background: var(--bg-input);
    border-color: var(--accent);
}

/* Modal Close X Button */
.modal-close-x {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.modal-close-x:hover {
    background: var(--bg-input);
    color: var(--text);
}

/* Credentials Modal */
.credentials-modal {
    max-width: 600px;
}
.credentials-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}
.credential-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.credential-item.credential-full {
    grid-column: span 2;
}
.credential-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.credential-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.credential-value {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
    flex: 1;
}
.credential-password {
    font-size: 14px;
    font-weight: 600;
}
.credential-connstr {
    font-size: 11px;
    color: var(--text);
}
.credential-value-row .copy-btn {
    position: static;
    transform: none;
    flex-shrink: 0;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; }
.tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-dark);
}
.tab:hover:not(.active) { border-color: var(--accent); color: var(--accent); }

/* Copy Button */
.copy-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-copied);
}
.copy-btn.copied {
    border-color: var(--success);
    color: var(--success);
    background: var(--bg-copied);
}
.copy-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Textarea */
textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.15);
}

textarea::placeholder {
    color: var(--text-dim);
}

/* Delete Options */
.delete-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}
.delete-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.delete-option:hover {
    border-color: var(--accent);
    background: var(--bg-dark);
}
.delete-option input[type="radio"] {
    width: auto;
    margin: 0;
    margin-top: 2px;
    cursor: pointer;
}
.delete-option input[type="radio"]:checked + div .delete-option-title {
    color: var(--accent);
    font-weight: 600;
}
.delete-option input[type="radio"]:checked ~ div,
.delete-option input[type="radio"]:checked + div {
    color: var(--text);
}
.delete-option-title {
    font-weight: 500;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
}
.delete-option-desc {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.4;
}
.delete-option-desc code {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* PAT Hint */
.pat-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 8px;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.pat-hint a {
    color: var(--accent);
    text-decoration: none;
}
.pat-hint a:hover {
    text-decoration: underline;
}
.pat-hint.hidden-help {
    display: none;
    margin-top: 12px;
}
.pat-hint.hidden-help.show {
    display: block;
}
.pat-obscured {
    -webkit-text-security: disc;
}
.info-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--text-dim);
    text-decoration: none !important;
    cursor: pointer;
}
.info-link:hover {
    color: var(--accent);
}
.info-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Build Progress Modal */
.build-progress-container {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}
.build-progress-log {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    min-height: 200px;
    max-height: 350px;
    overflow-y: auto;
}
.build-log-entry {
    margin-bottom: 8px;
    padding: 4px 0;
    color: var(--text-dim);
}
.build-log-entry:last-child {
    margin-bottom: 0;
}
.build-log-entry.success {
    color: var(--success);
}
.build-log-entry.error {
    color: var(--error);
}
.build-log-entry.info {
    color: var(--accent);
}
.build-log-timestamp {
    color: var(--text-dim);
    opacity: 0.6;
    margin-right: 8px;
}

/* Build Success Banner */
#build-success-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--success);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    z-index: 9999;
}
#build-success-banner.visible {
    display: flex;
}
#build-success-view-logs {
    background: none;
    border: 1px solid white;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 10px;
}
#build-success-view-logs:hover {
    border: 1px solid var(--accent);
    color: var(--accent);
    background: rgba(76, 175, 80, 0.1);
}
#build-success-dismiss {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
}
#build-success-dismiss:hover {
    color: var(--text);
}

/* Code Text List */
ul.code-text {
    list-style: none;
    padding: 0;
    margin: 0;
}
ul.code-text li {
    display: block;
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 8px;
    color: var(--text);
    line-height: 1.5;
}
ul.code-text li:last-child {
    margin-bottom: 0;
}

/* Auth Refresh Indicator */
.auth-refresh-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    animation: slideDown 0.3s ease;
}
.auth-refresh-content {
    display: flex;
    align-items: center;
    gap: 10px;
}
.auth-refresh-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.auth-refresh-text {
    font-size: 13px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.8);
    text-transform: lowercase;
    letter-spacing: 0.3px;
}
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
