/* BYOK.css - Bring Your Own Key Styling - UPDATED WITH SECURITY ENHANCEMENTS */

/* Enhanced API Key Input for Masked Display */
.api-key-input[data-is-masked="true"] {
    background: linear-gradient(135deg, var(--success-25, #fcfffe), var(--success-50));
    border-color: var(--success-300);
    color: var(--success-700);
    font-family: var(--font-mono);
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.api-key-input[data-is-masked="true"]:hover {
    background: var(--success-100);
    border-color: var(--success-400);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.api-key-input[data-is-masked="true"]:focus {
    background: white;
    border-color: var(--orange-400);
    color: var(--gray-900);
    letter-spacing: normal;
    cursor: text;
}

/* Enhanced Success State for Saved Keys */
.api-key-success {
    color: var(--success-600);
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: var(--font-medium);
    padding: var(--space-2);
    background: var(--success-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--success-200);
}

.api-key-success span {
    font-size: var(--text-sm);
}

/* Security Notice for Masked Input */
.api-key-security-notice {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-radius: var(--radius-lg);
    font-size: var(--text-xs);
    color: var(--blue-800);
    margin-top: var(--space-2);
}

.api-key-security-notice::before {
    content: '🛡️';
    font-size: var(--text-sm);
}

/* Interactive States for Masked Input */
.api-key-input-group.masked {
    position: relative;
}

.api-key-input-group.masked::after {
    content: 'Click to edit';
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-xs);
    color: var(--success-500);
    pointer-events: none;
    opacity: 0.7;
    transition: opacity var(--transition-normal);
}

.api-key-input-group.masked:hover::after {
    opacity: 1;
}

.api-key-input[data-is-masked="true"]:focus + .api-key-input-group.masked::after {
    display: none;
}

/* Enhanced Button States for Masked Key */
.api-key-btn-test:disabled.masked-key {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
}

.api-key-btn-save:disabled.masked-key {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
}

/* Tooltip for Masked Key Actions */
.masked-key-tooltip {
    position: relative;
}

.masked-key-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-900);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: var(--z-tooltip);
}

.masked-key-tooltip:hover::after {
    opacity: 1;
}

/* Success Animation for Key Save */
@keyframes keySecured {
    0% {
        transform: scale(1);
        background: var(--success-500);
    }
    50% {
        transform: scale(1.05);
        background: var(--success-400);
    }
    100% {
        transform: scale(1);
        background: var(--success-500);
    }
}

.api-key-input.key-secured {
    animation: keySecured 0.6s ease-out;
}

/* Enhanced Visual Feedback */
.api-key-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    margin-left: var(--space-2);
}

.api-key-status-indicator.secured {
    background: var(--success-100);
    color: var(--success-700);
    border: 1px solid var(--success-300);
}

.api-key-status-indicator.secured::before {
    content: '🔒';
}

.api-key-status-indicator.unsecured {
    background: var(--warning-100);
    color: var(--warning-700);
    border: 1px solid var(--warning-300);
}

.api-key-status-indicator.unsecured::before {
    content: '🔓';
}

/* API Key Settings Button */
.api-key-settings-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 2px solid var(--gray-300);
    background: white;
    border-radius: var(--radius-lg);
    color: var(--gray-700);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-bottom: var(--space-4);
}

.api-key-settings-btn:hover {
    border-color: var(--orange-400);
    background: var(--orange-50);
    color: var(--orange-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.api-key-settings-btn.active {
    border-color: var(--success-500);
    background: var(--success-50);
    color: var(--success-700);
    box-shadow: var(--shadow-md);
}

.api-key-settings-btn.active:hover {
    border-color: var(--success-600);
    background: var(--success-100);
}

.api-key-settings-btn .settings-icon {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-normal);
}

.api-key-settings-btn:hover .settings-icon {
    transform: rotate(90deg);
}

.api-key-settings-btn.active .settings-icon {
    color: var(--success-600);
}

/* Settings Modal */
.api-key-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: calc(var(--z-modal) + 5);
    display: none;
    justify-content: center;
    align-items: center;
    padding: var(--space-4);
    animation: fadeIn var(--transition-normal);
}

.api-key-modal-overlay.active {
    display: flex !important;
}

.api-key-modal {
    background: white;
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-2xl);
    animation: slideUp 0.4s ease-out;
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

/* Modal Header */
.api-key-modal-header {
    padding: var(--space-6) var(--space-8) var(--space-4);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--orange-25, #fefaf8), var(--gray-50));
    flex-shrink: 0;
}

.api-key-modal-header h3 {
    color: var(--gray-900);
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    margin: 0;
    line-height: var(--leading-tight);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.api-key-modal-header .header-icon {
    color: var(--orange-600);
}

/* Modal Content */
.api-key-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6) var(--space-8);
    background: white;
}

/* API Key Input Section */
.api-key-input-section {
    margin-bottom: var(--space-6);
}

.api-key-input-section h4 {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--gray-900);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.api-key-description {
    color: var(--gray-600);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--orange-500);
}

.api-key-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.api-key-input-group {
    position: relative;
}

.api-key-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-family: var(--font-mono);
    color: var(--gray-900);
    background: white;
    transition: all var(--transition-normal);
    resize: vertical;
    min-height: 80px;
    display: block !important; /* Force display */
    visibility: visible !important; /* Force visibility */
    opacity: 1 !important; /* Force opacity */
}

.api-key-input:focus {
    outline: none;
    border-color: var(--orange-400);
    box-shadow: 0 0 0 3px rgba(238, 119, 35, 0.1);
    background: var(--orange-25, #fefaf8);
}

.api-key-input::placeholder {
    color: var(--gray-500);
    font-style: italic;
    font-family: var(--font-family);
}

.api-key-input.error {
    border-color: var(--error-500);
    background: var(--error-25, #fefcfc);
}

.api-key-input.success {
    border-color: var(--success-500);
    background: var(--success-25, #fcfffe);
}

/* Validation Messages */
.api-key-validation {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
}

.api-key-error {
    color: var(--error-600);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.api-key-loading {
    color: var(--orange-600);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.api-key-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--orange-200);
    border-top: 2px solid var(--orange-600);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

/* Help Section */
.api-key-help {
    margin-top: var(--space-6);
    padding: var(--space-4);
    background: var(--blue-50);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--blue-500);
}

.api-key-help h5 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--blue-900);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.api-key-help-steps {
    list-style: none;
    counter-reset: step-counter;
}

.api-key-help-steps li {
    counter-increment: step-counter;
    font-size: var(--text-xs);
    color: var(--blue-800);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-2);
    padding-left: var(--space-6);
    position: relative;
}

.api-key-help-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    background: var(--blue-500);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--font-bold);
}

.api-key-help-link {
    color: var(--blue-600);
    text-decoration: underline;
    font-weight: var(--font-medium);
}

.api-key-help-link:hover {
    color: var(--blue-700);
}

/* Modal Footer */
.api-key-modal-footer {
    padding: var(--space-4) var(--space-8) var(--space-6);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-25);
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Modal Action Buttons */
.api-key-btn {
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.api-key-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.api-key-btn-cancel {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.api-key-btn-cancel:hover:not(:disabled) {
    background: var(--gray-200);
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

.api-key-btn-test {
    background: var(--blue-500);
    color: white;
    border: 1px solid var(--blue-500);
}

.api-key-btn-test:hover:not(:disabled) {
    background: var(--blue-600);
    border-color: var(--blue-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.api-key-btn-save {
    background: var(--success-500);
    color: white;
    border: 1px solid var(--success-500);
}

.api-key-btn-save:hover:not(:disabled) {
    background: var(--success-600);
    border-color: var(--success-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.api-key-btn-remove {
    background: var(--error-500);
    color: white;
    border: 1px solid var(--error-500);
}

.api-key-btn-remove:hover:not(:disabled) {
    background: var(--error-600);
    border-color: var(--error-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Loading State for Buttons */
.api-key-btn.loading {
    pointer-events: none;
    position: relative;
}

.api-key-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

.api-key-btn.loading .btn-text {
    opacity: 0;
}

/* User Model Selector */
.user-model-selector {
    display: none;
    margin-bottom: var(--space-4);
}

.user-model-selector.active {
    display: block;
}

.user-model-selector-header {
    display: flex;
    align-items: center;
    justify-content: between;
    margin-bottom: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: linear-gradient(135deg, var(--success-50), var(--success-25, #fcfffe));
    border: 1px solid var(--success-200);
    border-radius: var(--radius-lg);
}

.user-model-selector-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
}

.user-model-selector-title h4 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--success-800);
    margin: 0;
}

.user-model-selector-badge {
    background: var(--success-500);
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

/* User Model Cards in Gallery */
.user-model-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background: white;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
}

.user-model-card:hover {
    border-color: var(--orange-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.user-model-card.selected {
    border-color: var(--orange-500);
    background: var(--orange-50);
}

.user-model-card.premium {
    border-color: var(--blue-300);
    background: linear-gradient(135deg, white, var(--blue-25, #fefcff));
}

.user-model-card.premium:hover {
    border-color: var(--blue-400);
}

.user-model-card.premium.selected {
    border-color: var(--blue-500);
    background: var(--blue-50);
}

/* Premium Badge */
.user-model-premium-badge {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

/* Free Badge */
.user-model-free-badge {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: linear-gradient(135deg, var(--success-500), var(--success-600));
    color: white;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--font-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-sm);
}

/* Model Card Content */
.user-model-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.user-model-card-icon {
    font-size: var(--text-2xl);
    flex-shrink: 0;
}

.user-model-card-info {
    flex: 1;
    min-width: 0;
}

.user-model-card-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--gray-900);
    margin-bottom: var(--space-1);
    line-height: var(--leading-tight);
}

.user-model-card-provider {
    font-size: var(--text-xs);
    color: var(--gray-500);
    font-weight: var(--font-medium);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}

.user-model-card-description {
    font-size: var(--text-sm);
    color: var(--gray-600);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-3);
}

.user-model-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.user-model-feature-tag {
    background: var(--gray-100);
    color: var(--gray-700);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: 10px;
    font-weight: var(--font-medium);
    border: 1px solid var(--gray-200);
}

.user-model-card.premium .user-model-feature-tag {
    background: var(--blue-100);
    color: var(--blue-700);
    border-color: var(--blue-200);
}

.user-model-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.user-model-pricing {
    font-size: var(--text-xs);
    color: var(--gray-500);
    font-weight: var(--font-medium);
}

.user-model-pricing.free {
    color: var(--success-600);
    font-weight: var(--font-semibold);
}

.user-model-pricing.premium {
    color: var(--blue-600);
}

/* BYOK Status Indicator */
.byok-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--success-50);
    border: 1px solid var(--success-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: var(--text-xs);
    color: var(--success-800);
}

.byok-status.inactive {
    background: var(--gray-50);
    border-color: var(--gray-200);
    color: var(--gray-600);
}

.byok-status-icon {
    width: 16px;
    height: 16px;
    color: var(--success-600);
}

.byok-status.inactive .byok-status-icon {
    color: var(--gray-500);
}

/* Model Count Info */
.user-model-count {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--orange-50);
    border-left: 4px solid var(--orange-500);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    color: var(--orange-800);
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .api-key-modal {
        max-width: 95vw;
        max-height: 90vh;
        border-radius: var(--radius-xl);
    }
    
    .api-key-modal-header {
        padding: var(--space-4) var(--space-6);
    }
    
    .api-key-modal-header h3 {
        font-size: var(--text-lg);
    }
    
    .api-key-modal-content {
        padding: var(--space-4) var(--space-6);
    }
    
    .api-key-modal-footer {
        padding: var(--space-3) var(--space-6) var(--space-4);
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .api-key-btn {
        width: 100%;
        justify-content: center;
    }
    
    .api-key-settings-btn {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-3);
    }
    
    .user-model-card {
        padding: var(--space-3);
    }
    
    .user-model-card-features {
        gap: var(--space-1);
    }
    
    .user-model-feature-tag {
        font-size: 9px;
        padding: 2px var(--space-1);
    }
    
    /* Responsive Adjustments for Security Features */
    .api-key-input[data-is-masked="true"] {
        font-size: var(--text-xs);
        letter-spacing: 0.5px;
    }
    
    .api-key-input-group.masked::after {
        font-size: 10px;
        right: var(--space-2);
    }
    
    .api-key-security-notice {
        font-size: 11px;
        padding: var(--space-2);
    }
    
    .masked-key-tooltip::after {
        font-size: 10px;
        padding: 2px var(--space-1);
    }
}

@media (max-width: 480px) {
    .api-key-modal-overlay {
        padding: var(--space-2);
    }
    
    .api-key-modal-header {
        padding: var(--space-3) var(--space-4);
    }
    
    .api-key-modal-content {
        padding: var(--space-3) var(--space-4);
    }
    
    .api-key-modal-footer {
        padding: var(--space-3) var(--space-4);
    }
    
    .api-key-input {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-3);
        min-height: 70px;
    }
    
    .api-key-help-steps li {
        font-size: 11px;
        padding-left: var(--space-5);
    }
    
    .api-key-help-steps li::before {
        width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .api-key-modal {
        border: 3px solid var(--gray-800);
    }
    
    .api-key-input {
        border-width: 3px;
    }
    
    .user-model-card {
        border-width: 3px;
    }
    
    .api-key-settings-btn {
        border-width: 3px;
    }
}

/* Dark mode support for masked keys */
@media (prefers-color-scheme: dark) {
    .api-key-input[data-is-masked="true"] {
        background: var(--gray-800);
        border-color: var(--success-600);
        color: var(--success-400);
    }
    
    .api-key-success {
        background: var(--gray-800);
        border-color: var(--success-600);
        color: var(--success-400);
    }
}

/* Print styles - hide sensitive information */
@media print {
    .api-key-modal-overlay,
    .api-key-settings-btn {
        display: none !important;
    }
    
    .api-key-input[data-is-masked="true"] {
        display: none !important;
    }
    
    .api-key-success {
        display: none !important;
    }
    
    .api-key-security-notice::after {
        content: ' [API Key Hidden for Security]';
    }
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* BYOK Locked State Styles - ADD THESE TO byok.css */

/* Locked API Key Input */
.api-key-input.locked {
    background: linear-gradient(135deg, var(--success-25, #fcfffe), var(--success-50)) !important;
    border-color: var(--success-400) !important;
    color: var(--success-700) !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    user-select: none !important;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    position: relative;
}

.api-key-input.locked::placeholder {
    color: var(--success-600) !important;
    font-style: normal !important;
}

/* Locked Input Container */
.api-key-input-group.locked {
    position: relative;
}

.api-key-input-group.locked::before {
    content: '🔒';
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-sm);
    color: var(--success-600);
    pointer-events: none;
    z-index: 2;
}

.api-key-input-group.locked::after {
    content: 'Key is secured - Remove to change';
    position: absolute;
    right: var(--space-8);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-xs);
    color: var(--success-600);
    pointer-events: none;
    opacity: 0.8;
    font-weight: var(--font-medium);
    z-index: 1;
}

/* Locked State Success Message */
.api-key-success.locked {
    background: var(--success-50);
    border-color: var(--success-300);
    color: var(--success-800);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--font-semibold);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    border: 2px solid var(--success-300);
}

.api-key-success.locked::before {
    content: '🔐';
    font-size: var(--text-base);
}

/* Locked State Button Modifications */
.api-key-btn-test.locked-hidden,
.api-key-btn-save.locked-hidden {
    display: none !important;
}

.api-key-btn-remove.locked-active {
    display: block !important;
    background: var(--orange-500);
    border-color: var(--orange-500);
    font-weight: var(--font-semibold);
}

.api-key-btn-remove.locked-active:hover {
    background: var(--orange-600);
    border-color: var(--orange-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Edit Key Button (shown when locked) */
.api-key-btn-edit {
    background: var(--blue-500);
    color: white;
    border: 1px solid var(--blue-500);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.api-key-btn-edit:hover:not(:disabled) {
    background: var(--blue-600);
    border-color: var(--blue-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.api-key-btn-edit.locked-hidden {
    display: none !important;
}

/* Locked State Security Notice */
.api-key-security-notice.locked {
    background: var(--success-50);
    border-color: var(--success-300);
    color: var(--success-800);
}

.api-key-security-notice.locked::before {
    content: '🔐';
}

/* Locked State Modal Header Enhancement */
.api-key-modal-header.locked {
    background: linear-gradient(135deg, var(--success-25, #fcfffe), var(--success-50));
    border-bottom-color: var(--success-200);
}

.api-key-modal-header.locked .header-icon {
    color: var(--success-600);
}

/* Responsive adjustments for locked state */
@media (max-width: 768px) {
    .api-key-input-group.locked::after {
        font-size: 10px;
        right: var(--space-6);
    }
    
    .api-key-input-group.locked::before {
        right: var(--space-2);
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .api-key-input-group.locked::after {
        display: none; /* Hide text on very small screens */
    }
    
    .api-key-input.locked {
        padding-right: var(--space-8); /* Make room for lock icon only */
    }
}

/* High contrast mode support for locked state */
@media (prefers-contrast: high) {
    .api-key-input.locked {
        border-width: 3px !important;
        background: var(--success-100) !important;
    }
    
    .api-key-input-group.locked::before,
    .api-key-input-group.locked::after {
        color: var(--success-800) !important;
        font-weight: var(--font-bold);
    }
}

/* Print styles - ensure locked state is secure */
@media print {
    .api-key-input.locked {
        display: none !important;
    }
    
    .api-key-success.locked::after {
        content: ' [API Key Secured - Hidden for Security]';
        font-weight: var(--font-bold);
    }
}
/* BYOK Button Alignment Fix - Add to byok.css */

/* Enhanced Modal Footer Layout */
.api-key-modal-footer {
    padding: var(--space-4) var(--space-8) var(--space-6);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-25);
    display: flex;
    gap: var(--space-3);
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 80px; /* Ensure consistent height */
}

/* Button Container for Action Buttons */
.api-key-action-buttons {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex-wrap: wrap;
}

/* Consistent Button Sizing */
.api-key-btn {
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    min-width: 120px; /* Consistent minimum width */
    height: 44px; /* Fixed height for alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    white-space: nowrap;
}

/* Cancel Button - Left Side */
.api-key-btn-cancel {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    margin-right: auto; /* Push to left */
}

.api-key-btn-cancel:hover:not(:disabled) {
    background: var(--gray-200);
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

/* Test Button */
.api-key-btn-test {
    background: var(--blue-500);
    color: white;
    border: 1px solid var(--blue-500);
    order: 1;
}

.api-key-btn-test:hover:not(:disabled) {
    background: var(--blue-600);
    border-color: var(--blue-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.api-key-btn-test:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    border-color: var(--gray-300);
    cursor: not-allowed;
    transform: none !important;
}

/* Save Button */
.api-key-btn-save {
    background: var(--success-500);
    color: white;
    border: 1px solid var(--success-500);
    order: 2;
}

.api-key-btn-save:hover:not(:disabled) {
    background: var(--success-600);
    border-color: var(--success-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.api-key-btn-save:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    border-color: var(--gray-300);
    cursor: not-allowed;
    transform: none !important;
}

/* Remove Button */
.api-key-btn-remove {
    background: var(--error-500);
    color: white;
    border: 1px solid var(--error-500);
    order: 3;
    min-width: 180px; /* Wider for "Remove Key to Change" text */
}

.api-key-btn-remove:hover:not(:disabled) {
    background: var(--error-600);
    border-color: var(--error-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Enhanced Remove Button when in locked state */
.api-key-btn-remove.locked-active {
    background: var(--orange-500);
    border-color: var(--orange-500);
    font-weight: var(--font-semibold);
    min-width: 200px;
}

.api-key-btn-remove.locked-active:hover {
    background: var(--orange-600);
    border-color: var(--orange-600);
}

/* Hidden Button State */
.api-key-btn.locked-hidden {
    display: none !important;
}

/* Loading State Enhancement */
.api-key-btn.loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.api-key-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
    color: white;
}

/* Button Text Container */
.btn-text {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-weight: inherit;
}

/* Responsive Design for Buttons */
@media (max-width: 768px) {
    .api-key-modal-footer {
        flex-direction: column;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-6) var(--space-4);
        align-items: stretch;
    }
    
    .api-key-action-buttons {
        flex-direction: column;
        width: 100%;
        gap: var(--space-2);
    }
    
    .api-key-btn {
        width: 100%;
        min-width: auto;
        justify-content: center;
        order: unset !important;
    }
    
    .api-key-btn-cancel {
        margin-right: 0;
        order: 3; /* Move to bottom on mobile */
    }
    
    .api-key-btn-test {
        order: 1;
    }
    
    .api-key-btn-save {
        order: 2;
    }
    
    .api-key-btn-remove {
        order: 1; /* Show at top when in locked state */
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .api-key-modal-footer {
        padding: var(--space-3) var(--space-4);
    }
    
    .api-key-btn {
        font-size: var(--text-xs);
        padding: var(--space-3) var(--space-4);
        height: 40px;
    }
    
    .api-key-btn-remove.locked-active .btn-text {
        font-size: var(--text-xs);
    }
}

/* Enhanced Focus States for Better Accessibility */
.api-key-btn:focus-visible {
    outline: 2px solid var(--orange-500);
    outline-offset: 2px;
    z-index: 1;
}

/* Animation for Button State Changes */
@keyframes buttonSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.api-key-btn-remove.locked-active {
    animation: buttonSlideIn 0.3s ease-out;
}

/* Improved Button Group Layout */
.api-key-modal-footer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-4);
    align-items: center;
}

.api-key-modal-footer .api-key-btn-cancel {
    grid-column: 1;
    justify-self: start;
    margin-right: 0;
}

.api-key-modal-footer .api-key-action-buttons {
    grid-column: 2;
    justify-self: end;
}

/* Special handling for locked state layout */
.api-key-modal-footer.locked-state {
    grid-template-columns: 1fr auto auto;
}

.api-key-modal-footer.locked-state .api-key-btn-cancel {
    grid-column: 1;
}

.api-key-modal-footer.locked-state .api-key-btn-remove {
    grid-column: 2 / 4;
    justify-self: end;
}

/* Ensure proper spacing and alignment */
.api-key-action-buttons > * {
    flex-shrink: 0;
}

/* High contrast mode button improvements */
@media (prefers-contrast: high) {
    .api-key-btn {
        border-width: 2px;
        font-weight: var(--font-semibold);
    }
    
    .api-key-btn:disabled {
        border-width: 2px;
        opacity: 0.7;
    }
}