/* API Keys Management Styles for MECE Agent */

/* =====================================================
   Modal Overlay
   ===================================================== */

.api-keys-modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 52, 64, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.api-keys-modal-overlay.active {
    display: flex;
}

/* =====================================================
   Modal Container
   ===================================================== */

.api-keys-modal {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

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

/* =====================================================
   Modal Header
   ===================================================== */

.api-keys-modal-header {
    background: linear-gradient(135deg, #2E3440 0%, #3B4252 100%);
    color: white;
    padding: 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.api-keys-modal-header h2 {
    font-size: 22px;
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.api-keys-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.api-keys-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   Modal Content
   ===================================================== */

.api-keys-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

/* =====================================================
   Info Banner
   ===================================================== */

.api-keys-info {
    background: #E3F2FD;
    border-left: 4px solid #2196F3;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 24px;
    font-size: 14px;
    color: #1565C0;
    line-height: 1.6;
}

.api-keys-info strong {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

/* =====================================================
   Generate Section
   ===================================================== */

.api-keys-generate-section {
    margin-bottom: 32px;
}

.api-keys-generate-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.api-keys-form-group {
    flex: 1;
}

.api-keys-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.api-keys-form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.api-keys-form-group input:focus {
    outline: none;
    border-color: #A3BE8C;
    box-shadow: 0 0 0 3px rgba(163, 190, 140, 0.1);
}

.api-keys-generate-btn {
    background: linear-gradient(135deg, #A3BE8C 0%, #EBCB8B 100%);
    color: #2E3440;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.api-keys-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(163, 190, 140, 0.4);
}

.api-keys-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =====================================================
   New Key Display (shown once)
   ===================================================== */

.api-keys-new-key {
    background: #F0FFF4;
    border: 2px solid #A3BE8C;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    display: none;
}

.api-keys-new-key.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.api-keys-new-key-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #2E7D32;
    font-weight: 600;
    font-size: 15px;
}

.api-keys-new-key-warning {
    background: #FFF3E0;
    border-left: 3px solid #FF9800;
    padding: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #E65100;
    line-height: 1.5;
}

.api-keys-new-key-value {
    background: white;
    border: 1px solid #A3BE8C;
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    word-break: break-all;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.api-keys-new-key-text {
    flex: 1;
    user-select: all;
}

.api-keys-copy-btn {
    background: #A3BE8C;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.api-keys-copy-btn:hover {
    background: #8fa877;
}

.api-keys-copy-btn.copied {
    background: #2E7D32;
}

/* =====================================================
   Keys List
   ===================================================== */

.api-keys-list-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
}

.api-keys-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.api-key-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s;
}

.api-key-item:hover {
    border-color: #A3BE8C;
    box-shadow: 0 2px 8px rgba(163, 190, 140, 0.2);
}

.api-key-item.revoked {
    opacity: 0.6;
    background: #f5f5f5;
}

.api-key-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.api-key-item-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-status-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-key-status-badge.active {
    background: #E8F5E9;
    color: #2E7D32;
}

.api-key-status-badge.revoked {
    background: #FFEBEE;
    color: #C62828;
}

.api-key-item-actions {
    display: flex;
    gap: 8px;
}

.api-key-revoke-btn {
    background: transparent;
    border: 1px solid #BF616A;
    color: #BF616A;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.api-key-revoke-btn:hover {
    background: #BF616A;
    color: white;
}

.api-key-item-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

.api-key-detail-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.api-key-detail-label {
    font-weight: 600;
    color: #555;
    min-width: 100px;
}

.api-key-prefix {
    font-family: 'Courier New', monospace;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    color: #333;
}

/* =====================================================
   Empty State
   ===================================================== */

.api-keys-empty {
    text-align: center;
    padding: 48px 20px;
    color: #999;
}

.api-keys-empty svg {
    opacity: 0.3;
    margin-bottom: 16px;
    color: #ccc;
}

.api-keys-empty p {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
}

.api-keys-empty small {
    font-size: 14px;
    color: #999;
}

/* =====================================================
   Loading State
   ===================================================== */

.api-keys-loading {
    text-align: center;
    padding: 48px 20px;
}

.api-keys-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #A3BE8C;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* =====================================================
   Mobile Responsive
   ===================================================== */

@media (max-width: 768px) {
    .api-keys-modal {
        width: 95%;
        max-height: 90vh;
    }

    .api-keys-modal-header {
        padding: 20px;
    }

    .api-keys-modal-header h2 {
        font-size: 20px;
    }

    .api-keys-modal-content {
        padding: 20px;
    }

    .api-keys-generate-form {
        flex-direction: column;
        align-items: stretch;
    }

    .api-keys-generate-btn {
        width: 100%;
    }

    .api-key-item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .api-key-new-key-value {
        flex-direction: column;
        align-items: stretch;
    }

    .api-keys-copy-btn {
        width: 100%;
    }
}
